diff --git a/lutin/tools.py b/lutin/tools.py index bc6722f..f545e06 100644 --- a/lutin/tools.py +++ b/lutin/tools.py @@ -410,4 +410,29 @@ def get_maintainer_from_file_or_direct(path_module, filename_or_author): # comment ... continue out.append(elem) - return out \ No newline at end of file + return out + + + +def remove_element(data, to_remove): + base_data = [] + for elem in data: + if type(elem) == list: + for elem2 in elem: + base_data.append(elem2) + else: + base_data.append(elem) + base_remove = [] + for elem in to_remove: + if type(elem) == list: + for elem2 in elem: + base_remove.append(elem2) + else: + base_remove.append(elem) + out = [] + for elem in base_data: + if elem not in base_remove: + out.append(elem) + return out; + + diff --git a/lutin/z_builder/lutinBuilder_c.py b/lutin/z_builder/lutinBuilder_c.py index 5d59344..9808699 100644 --- a/lutin/z_builder/lutinBuilder_c.py +++ b/lutin/z_builder/lutinBuilder_c.py @@ -85,19 +85,30 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module cmd.append(get_version_compilation_flags(flags, depancy.flags)) except: pass - try: - cmd.append(target.global_flags["c"]) - except: - pass - try: - cmd.append(depancy.flags["c"]) - except: - pass + list_flags = []; + if "c" in target.global_flags: + list_flags.append(target.global_flags["c"]) + if "c" in depancy.flags: + list_flags.append(depancy.flags["c"]) for view in ["local", "export"]: - try: - cmd.append(flags[view]["c"]) - except: - pass + if view in flags: + if "c" in flags[view]: + list_flags.append(flags[view]["c"]) + # get blacklist of flags + list_flags_blacklist = []; + if "c-remove" in target.global_flags: + list_flags_blacklist.append(target.global_flags["c-remove"]) + if "c-remove" in depancy.flags: + list_flags_blacklist.append(depancy.flags["c-remove"]) + for view in ["local", "export"]: + if view in flags: + if "c-remove" in flags[view]: + list_flags_blacklist.append(flags[view]["c-remove"]) + # apply blacklisting of data and add it on the cmdLine + clean_flags = tools.remove_element(list_flags, list_flags_blacklist) + #debug.warning("plop " + str(list_flags_blacklist) + " " + str(list_flags) + " --> " + str(clean_flags) ) + cmd.append(clean_flags); + cmd.append("-c") cmd.append("-MMD") cmd.append("-MP") diff --git a/lutin/z_builder/lutinBuilder_cpp.py b/lutin/z_builder/lutinBuilder_cpp.py index cf91994..50dac42 100644 --- a/lutin/z_builder/lutinBuilder_cpp.py +++ b/lutin/z_builder/lutinBuilder_cpp.py @@ -54,12 +54,6 @@ def get_output_type(): def get_support_multithreading(): return True -def remove_element(data, to_remove): - out = [] - for elem in data: - if elem not in to_remove: - out.append(elem) - return out; ## ## @brief Commands for running gcc to compile a C++ file in object file. @@ -94,48 +88,36 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module except: pass list_flags = []; - try: + if "c" in target.global_flags: list_flags.append(target.global_flags["c"]) - except: - pass - try: + if "c++" in target.global_flags: list_flags.append(target.global_flags["c++"]) - except: - pass for type in ["c", "c++"]: - try: + if type in depancy.flags: list_flags.append(depancy.flags[type]) - except: - pass for view in ["local", "export"]: - for type in ["c", "c++"]: - try: - list_flags.append(flags[view][type]) - except: - pass + if view in flags: + for type in ["c", "c++"]: + if type in flags[view]: + list_flags.append(flags[view][type]) # get blacklist of flags list_flags_blacklist = []; - try: + if "c-remove" in target.global_flags: list_flags_blacklist.append(target.global_flags["c-remove"]) - except: - pass - try: + if "c++-remove" in target.global_flags: list_flags_blacklist.append(target.global_flags["c++-remove"]) - except: - pass for type in ["c-remove", "c++-remove"]: - try: + if type in depancy.flags: list_flags_blacklist.append(depancy.flags[type]) - except: - pass for view in ["local", "export"]: - for type in ["c-remove", "c++-remove"]: - try: - list_flags_blacklist.append(flags[view][type]) - except: - pass + if view in flags: + for type in ["c-remove", "c++-remove"]: + if type in flags[view]: + list_flags_blacklist.append(flags[view][type]) # apply blacklisting of data and add it on the cmdLine - cmd.append(remove_element(list_flags, list_flags_blacklist)); + clean_flags = tools.remove_element(list_flags, list_flags_blacklist) + #debug.warning("plop " + str(list_flags_blacklist) + " " + str(list_flags) + " --> " + str(clean_flags) ) + cmd.append(clean_flags); cmd.append(["-c", "-MMD", "-MP"]) cmd.append(file_src) # Create cmd line diff --git a/lutin/z_system/lutinSystem_MacOs_c.py b/lutin/z_system/lutinSystem_MacOs_c.py new file mode 100644 index 0000000..87a4344 --- /dev/null +++ b/lutin/z_system/lutinSystem_MacOs_c.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +## +## @author Edouard DUPIN +## +## @copyright 2012, Edouard DUPIN, all right reserved +## +## @license APACHE v2.0 (see license file) +## + +from lutin import debug +from lutin import system +from lutin import tools +from lutin import env +import os + +class System(system.System): + def __init__(self, target): + system.System.__init__(self) + # create some HELP: + self.set_help("C: Generic C library") + self.add_flag("c-remove","-nodefaultlibs") + self.set_valid(True) + diff --git a/lutin/z_system/lutinSystem_MacOs_cxx.py b/lutin/z_system/lutinSystem_MacOs_cxx.py index 8a70fd3..6ab0647 100644 --- a/lutin/z_system/lutinSystem_MacOs_cxx.py +++ b/lutin/z_system/lutinSystem_MacOs_cxx.py @@ -21,6 +21,7 @@ class System(system.System): self.set_help("CXX: Generic C++ library") self.set_valid(True) # no check needed ==> just add this: + self.add_depend("c") self.add_flag("c++","-D__STDCPP_LLVM__") self.add_flag("c++-remove","-nostdlib") self.add_flag("need-libstdc++", True)