diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 04be2fe..4a0ed61 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +encoding//bin/lutin=utf-8 encoding//lutin/__init__.py=utf-8 encoding//lutin/builder.py=utf-8 encoding//lutin/depend.py=utf-8 diff --git a/lutin/module.py b/lutin/module.py index ed57cd3..369b9cc 100644 --- a/lutin/module.py +++ b/lutin/module.py @@ -7,7 +7,7 @@ ## ## @license MPL v2.0 (see license file) ## - +import re import sys import os import copy @@ -47,7 +47,8 @@ class Module: ## @param[in] module_name (string) Name of the module ## @param[in] module_type (string) Type of the module: ## - BINARY - ## - BINARY_SHARED + ## - BINARY_SHARED // deprecated ... + ## - BINARY_DYNAMIC ## - BINARY_STAND_ALONE ## - LIBRARY ## - LIBRARY_DYNAMIC @@ -59,6 +60,8 @@ class Module: ## def __init__(self, file, module_name, module_type): ## Remove all variable to prevent error of multiple deffinition of the module ... + if module_type == "BINARY_SHARED": + module_type = "BINARY_DYNAMIC"; debug.verbose("Create a new module : '" + module_name + "' TYPE=" + module_type) self._origin_file = file; self._origin_path = tools.get_current_path(self._origin_file) @@ -591,7 +594,7 @@ class Module: action["action"](target, self, action["data"]); if package_name == None \ and ( self._type == 'BINARY' - or self._type == 'BINARY_SHARED' \ + or self._type == 'BINARY_DYNAMIC' \ or self._type == 'BINARY_STAND_ALONE' \ or self._type == 'PACKAGE' ) : # this is the endpoint binary ... @@ -626,7 +629,7 @@ class Module: local_type = 'LIBRARY' if self._type == 'LIBRARY_STATIC': local_type = 'LIBRARY' - if self._type == 'BINARY_SHARED': + if self._type == 'BINARY_DYNAMIC': local_type = 'BINARY' if self._type == 'BINARY_STAND_ALONE': local_type = 'BINARY' @@ -652,8 +655,8 @@ class Module: debug.print_element("Library(static)", self._name, "-", package_version_string) elif self._type == 'BINARY': debug.print_element("Binary(auto)", self._name, "-", package_version_string) - elif self._type == 'BINARY_SHARED': - debug.print_element("Binary (shared)", self._name, "-", package_version_string) + elif self._type == 'BINARY_DYNAMIC': + debug.print_element("Binary (dynamic)", self._name, "-", package_version_string) elif self._type == 'BINARY_STAND_ALONE': debug.print_element("Binary (stand alone)", self._name, "-", package_version_string) elif self._type == 'PACKAGE': @@ -827,7 +830,7 @@ class Module: except ValueError: debug.error(" UN-SUPPORTED link format: '.jar'") elif self._type == 'BINARY' \ - or self._type == 'BINARY_SHARED' \ + or self._type == 'BINARY_DYNAMIC' \ or self._type == 'BINARY_STAND_ALONE': shared_mode = False if "Android" in target.get_type(): @@ -841,7 +844,7 @@ class Module: break; static_mode = True if target.support_dynamic_link == True: - if self._type == 'BINARY_SHARED': + if self._type == 'BINARY_DYNAMIC': static_mode = False if shared_mode == True: try: @@ -1010,7 +1013,7 @@ class Module: tools.remove_path_and_sub_path(pathbuild) return True elif self._type == 'BINARY' \ - or self._type == 'BINARY_SHARED' \ + or self._type == 'BINARY_DYNAMIC' \ or self._type == 'BINARY_STAND_ALONE' \ or self._type=='PACKAGE': # remove path of the lib ... for this targer @@ -1520,7 +1523,7 @@ class Module: or ( type == 'PACKAGE'\ and "K" not in rules) \ or ( ( type == 'BINARY' \ - or type == 'BINARY_SHARED' \ + or type == 'BINARY_DYNAMIC' \ or type == 'BINARY_STAND_ALONE')\ and "B" not in rules ) : return True @@ -1553,7 +1556,7 @@ class Module: tmp_file.write(' color=lightblue;\n'); tmp_file.write(' ];\n'); elif self._type == 'BINARY' \ - or self._type == 'BINARY_SHARED' \ + or self._type == 'BINARY_DYNAMIC' \ or self._type == 'BINARY_STAND_ALONE': tmp_file.write(' node [\n'); tmp_file.write(' shape=rectangle;\n'); @@ -1816,10 +1819,8 @@ def import_path(path_list): def exist(target, name): global __module_list for mod in __module_list: - return_check = bool(re.match(name, mod[0])); - debug.warning("check exist: " + name + " => " + mod[0]); - #if mod[0] == name: - if return_check: + debug.verbose("check exist: " + name + " => " + mod[0]); + if mod[0] == name: return True; return False @@ -1829,11 +1830,11 @@ def exist(target, name): ## @param[in] name (string) Name of the module ## @return (handle) @ref Module handle ## -def load_module(target, nameg): +def load_module(target, name): global __module_list #debug.warning("Load module: " + str(len(__module_list)) + " => " + str(__module_list)); for mod in __module_list: - if mod[0] == name : + if mod[0] == name: if mod[2]== False: # read GLD file the_module = moduleGLD.load_module_from_GLD(target, mod[0], os.path.dirname(mod[1]), mod[1]) @@ -1902,11 +1903,22 @@ def load_module(target, nameg): ## def list_all_module(): global __module_list - tmpListName = [] + out = [] for mod in __module_list: - if mod[0] not in tmpListName: - tmpListName.append(mod[0]) - return tmpListName + if mod[0] not in out: + out.append(mod[0]) + out.sort() + return out + +## +## @brief List all module with specific filter name +## @param[in] filter (string) regular expression to filter the modules +## @return ([string,...]) List of all module names filter with needed element +## +def list_filtered_module(filter): + list_of_all_module = list_all_module(); + regex = re.compile(filter) + return [xxx for xxx in list_of_all_module if regex.match(xxx)]#list(filter(list_of_all_module,r.match)) ## ## @brief List all module name whith their desc diff --git a/lutin/moduleGLD.py b/lutin/moduleGLD.py index c37156b..32cf0f2 100644 --- a/lutin/moduleGLD.py +++ b/lutin/moduleGLD.py @@ -32,7 +32,7 @@ from xmlrpc.client import boolean def get_module_type_availlable(): return [ 'BINARY', - 'BINARY_SHARED', + 'BINARY_DYNAMIC', 'BINARY_STAND_ALONE', 'LIBRARY', 'LIBRARY_DYNAMIC', diff --git a/lutin/target.py b/lutin/target.py index 08d0eab..1592429 100644 --- a/lutin/target.py +++ b/lutin/target.py @@ -723,121 +723,128 @@ class Target: for mod in self.module_list: mod.clean(self) else: - module_name = name - action_list = actions - for action_name in action_list: - debug.verbose("requested : " + module_name + "?" + action_name + " [START]") - ret = None; - if action_name == "install": - try: - self.install_package(module_name) - except AttributeError: - debug.error("target have no 'install_package' instruction") - elif action_name == "uninstall": - try: - self.un_install_package(module_name) - except AttributeError: - debug.error("target have no 'un_install_package' instruction") - elif action_name[:3] == "run": - """ - if mod.get_type() != "BINARY" \ - and mod.get_type() != "PACKAGE": - debug.error("Can not run other than 'BINARY' ... package='" + mod.get_type() + "' for module='" + module_name + "'") - """ - bin_name = None - if len(action_name) > 3: - if action_name[3] == '%': - bin_name = "" - for elem in action_name[4:]: - if elem == ":": - break; - bin_name += elem - # we have option: - action_name2 = action_name.replace("\:", "1234COLUMN4321") - option_list = action_name2.split(":") - if len(option_list) == 0: - if bin_name != None: - debug.warning("action 'run' wrong options options ... : '" + action_name + "' might be separate with ':'") - option_list = [] + if name.find("*") != -1: + list_of_all_element = module.list_filtered_module(name); + else: + list_of_all_element = [name] + for module_name in list_of_all_element: + action_list = actions + for action_name in action_list: + debug.verbose("requested : " + module_name + "?" + action_name + " [START]") + ret = None; + if action_name == "install": + try: + self.install_package(module_name) + except AttributeError: + debug.error("target have no 'install_package' instruction") + elif action_name == "uninstall": + try: + self.un_install_package(module_name) + except AttributeError: + debug.error("target have no 'un_install_package' instruction") + elif action_name[:3] == "run": + """ + if mod.get_type() != "BINARY" \ + and mod.get_type() != "PACKAGE": + debug.error("Can not run other than 'BINARY' ... pakage='" + mod.get_type() + "' for module='" + module_name + "'") + """ + bin_name = None + if len(action_name) > 3: + if action_name[3] == '%': + bin_name = "" + for elem in action_name[4:]: + if elem == ":": + break; + bin_name += elem + # we have option: + action_name2 = action_name.replace("\:", "1234COLUMN4321") + option_list = action_name2.split(":") + if len(option_list) == 0: + if bin_name != None: + debug.warning("action 'run' wrong options options ... : '" + action_name + "' might be separate with ':'") + option_list = [] + else: + option_list = [] + #try: + self.run(module_name, option_list, bin_name) + #except AttributeError: + # debug.error("target have no 'run' instruction") + elif action_name == "log": + try: + self.show_log(module_name) + except AttributeError: + debug.error("target have no 'show_log' instruction") else: - option_list_tmp = option_list[1:] option_list = [] - for elem in option_list_tmp: - option_list.append(elem.replace("1234COLUMN4321", ":")) + #try: + self.run(module_name, option_list, bin_name) + #except AttributeError: + # debug.error("target have no 'run' instruction") + elif action_name == "log": + try: + self.show_log(module_name) + except AttributeError: + debug.error("target have no 'show_log' instruction") else: - option_list = [] - #try: - self.run(module_name, option_list, bin_name) - #except AttributeError: - # debug.error("target have no 'run' instruction") - elif action_name == "log": - try: - self.show_log(module_name) - except AttributeError: - debug.error("target have no 'show_log' instruction") - else: - present = self.load_if_needed(module_name, optionnal=optionnal) - if present == False \ - and optionnal == True: - ret = [heritage.HeritageList(), False] - else: - debug.warning("compare " + str(self.module_list) + " " + module_name) - for mod in self.module_list: - debug.warning("compare " + mod.get_name() + " == " + module_name) - if mod.get_name() == module_name: - if action_name[:4] == "dump": - debug.info("dump module '" + module_name + "'") - if len(action_name) > 4: - debug.warning("action 'dump' does not support options ... : '" + action_name + "'") - ret = mod.display() - break - elif action_name[:5] == "clean": - debug.info("clean module '" + module_name + "'") - if len(action_name) > 5: - debug.warning("action 'clean' does not support options ... : '" + action_name + "'") - ret = mod.clean(self) - break - elif action_name[:4] == "gcov": - debug.debug("gcov on module '" + module_name + "'") - if len(action_name) > 4: - # we have option: - option_list = action_name.split(":") - if len(option_list) == 0: - debug.warning("action 'gcov' wrong options options ... : '" + action_name + "' might be separate with ':'") - option_list = [] - else: - option_list = option_list[1:] - else: - option_list = [] - if "output" in option_list: - ret = mod.gcov(self, generate_output=True) - else: - ret = mod.gcov(self, generate_output=False) - break - elif action_name[:5] == "build": - if len(action_name) > 5: - debug.warning("action 'build' does not support options ... : '" + action_name + "'") - debug.debug("build module '" + module_name + "'") - if optionnal == True: - ret = [mod.build(self, package_name), True] - else: - ret = mod.build(self, package_name) - break - if optionnal == True \ - and ret == None: + present = self.load_if_needed(module_name, optionnal=optionnal) + if present == False \ + and optionnal == True: ret = [heritage.HeritageList(), False] - break - if ret == None: - debug.error("not know module name : '" + module_name + "' to '" + action_name + "' it") - debug.verbose("requested : " + module_name + "?" + action_name + " [STOP]") - if len(action_list) == 1: - return ret + else: + for mod in self.module_list: + debug.verbose("compare " + mod.get_name() + " == " + module_name) + if mod.get_name() == module_name: + if action_name[:4] == "dump": + debug.info("dump module '" + module_name + "'") + if len(action_name) > 4: + debug.warning("action 'dump' does not support options ... : '" + action_name + "'") + ret = mod.display() + break + elif action_name[:5] == "clean": + debug.info("clean module '" + module_name + "'") + if len(action_name) > 5: + debug.warning("action 'clean' does not support options ... : '" + action_name + "'") + ret = mod.clean(self) + break + elif action_name[:4] == "gcov": + debug.debug("gcov on module '" + module_name + "'") + if len(action_name) > 4: + # we have option: + option_list = action_name.split(":") + if len(option_list) == 0: + debug.warning("action 'gcov' wrong options options ... : '" + action_name + "' might be separate with ':'") + option_list = [] + if "output" in option_list: + ret = mod.gcov(self, generate_output=True) + else: + ret = mod.gcov(self, generate_output=False) + break + elif action_name[:5] == "build": + if len(action_name) > 5: + debug.warning("action 'build' does not support options ... : '" + action_name + "'") + debug.debug("build module '" + module_name + "'") + if optionnal == True: + ret = [mod.build(self, package_name), True] + else: + ret = mod.build(self, package_name) + break + # at the end of the build selected... + if optionnal == True \ + and ret == None: + ret = [heritage.HeritageList(), False] + break + if ret == None: + debug.error("not know module name : '" + module_name + "' to '" + action_name + "' it") + debug.verbose("requested : " + module_name + "?" + action_name + " [STOP]") + if len(action_list) == 1 and len(list_of_all_element) == 1: + return ret + # end of all element processing... ## ## @brief Add action to do for package specific part when build upper element ## @param[in] name_of_state (string) a state to call action ## - BINARY - ## - BINARY_SHARED + ## - BINARY_DYNAMIC ## - BINARY_STAND_ALONE ## - LIBRARY ## - LIBRARY_DYNAMIC @@ -883,7 +890,7 @@ class Target: elif module.get_type() == 'BINARY' \ or module.get_type() == 'BINARY_STAND_ALONE': self.make_package_binary(pkg_name, pkg_properties, base_pkg_path, heritage_list, static = True) - elif module.get_type() == 'BINARY_SHARED': + elif module.get_type() == 'BINARY_DYNAMIC': self.make_package_binary(pkg_name, pkg_properties, base_pkg_path, heritage_list, static = False) elif module.get_type() == 'PACKAGE': self.make_package_binary(pkg_name, pkg_properties, base_pkg_path, heritage_list, static = False)