From 0e7458cc06b42f5fc5232da31c4a9af80b9fbf9b Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 23 Nov 2016 22:08:43 +0100 Subject: [PATCH] [DEV] integrate PACKAGE generation and run binary inside --- bin/lutin | 1 + lutin/heritage.py | 7 +- lutin/module.py | 28 ++++++- lutin/target.py | 105 +++++++++++++++++-------- lutin/z_builder/lutinBuilder_binary.py | 4 +- lutin/z_target/lutinTarget_IOs.py | 2 +- lutin/z_target/lutinTarget_Linux.py | 8 +- lutin/z_target/lutinTarget_MacOs.py | 2 +- lutin/z_target/lutinTarget_Web.py | 2 +- lutin/z_target/lutinTarget_Windows.py | 2 +- 10 files changed, 115 insertions(+), 46 deletions(-) diff --git a/bin/lutin b/bin/lutin index 50d2196..fe85c49 100755 --- a/bin/lutin +++ b/bin/lutin @@ -163,6 +163,7 @@ def usage(full=False): for elem in mod["maintainer"]: print(" " + str(elem)) print(" ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all") + print(" ex: " + sys.argv[0] + " -cclang -mdebug zeus-package-base?build?run%zeus-launcher:--srv=user:--elog-level=5") exit(0) def check_boolean(value): diff --git a/lutin/heritage.py b/lutin/heritage.py index 32ee04f..def0b75 100644 --- a/lutin/heritage.py +++ b/lutin/heritage.py @@ -157,7 +157,10 @@ class HeritageList: ## @return (string) string of str() convertion ## def __repr__(self): - return "{HeritageList:" + str(self.list_heritage) + "}" + dep = [] + for elem in reversed(self.list_heritage): + dep.append(str(elem.name)) + return "{HeritageList: " + str(dep) + "}" class heritage: def __init__(self, module, target): @@ -258,6 +261,6 @@ class heritage: ## @return (string) string of str() convertion ## def __repr__(self): - return "{Heritage:" + str(self.name) + " ... }" + return "{Heritage:" + str(self.name) + " depend on: " + str(reversed(self.depends)) + " ... }" diff --git a/lutin/module.py b/lutin/module.py index a3cf27b..b097e8e 100644 --- a/lutin/module.py +++ b/lutin/module.py @@ -801,6 +801,21 @@ class Module: except ValueError: debug.error("UN-SUPPORTED link format: '.jar'") else: + # try to build the binary with dependency of .so and the standalone binary (Not package dependent) + if target.support_dynamic_link == True: + try: + tmp_builder = builder.get_builder_with_output("bin"); + res_file = tmp_builder.link(list_sub_file_needed_to_build, + package_name, + target, + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path, + static = True) + #self._local_heritage.add_sources(res_file) + except ValueError: + debug.error("UN-SUPPORTED link format: '.bin'") try: tmp_builder = builder.get_builder_with_output("bin"); res_file = tmp_builder.link(list_sub_file_needed_to_build, @@ -810,7 +825,8 @@ class Module: flags = self._flags, name = self._name, basic_path = self._origin_path, - static = static_mode) + static = False) + #self._local_heritage.add_sources(res_file) except ValueError: debug.error("UN-SUPPORTED link format: '.bin'") elif self._type == "PACKAGE": @@ -886,13 +902,17 @@ class Module: # ---------------------------------------------------- if self._type[:6] == 'BINARY' \ or self._type == 'PACKAGE': + debug.verbose("Request creating of package : " + str(self._name)) + debug.extreme_verbose("Heritage : " + str(self._local_heritage)) + # TODO : Do package for library ... if target.end_generate_package == True: # generate the package with his properties ... if "Android" in target.get_type(): self._sub_heritage_list.add_heritage(self._local_heritage) - target.make_package(self._name, self._package_prop, os.path.join(self._origin_path, ".."), self._sub_heritage_list) - else: - target.make_package(self._name, self._package_prop, os.path.join(self._origin_path, ".."), self._sub_heritage_list) + elif self._type == 'PACKAGE': + self._sub_heritage_list.add_heritage(self._local_heritage) + debug.extreme_verbose("HeritageList : " + str(self._sub_heritage_list)) + target.make_package(self._name, self._package_prop, os.path.join(self._origin_path, ".."), self._sub_heritage_list) # return local dependency ... return copy.deepcopy(self._sub_heritage_list) diff --git a/lutin/target.py b/lutin/target.py index 163ad7d..a3f4b64 100644 --- a/lutin/target.py +++ b/lutin/target.py @@ -469,8 +469,10 @@ class Target: ## @param[in] name (string) Name of the module ## @return (string) The path ## - def get_build_file_bin(self, name): - return os.path.join(self.get_build_path_bin(name), name + self.suffix_binary) + def get_build_file_bin(self, name, static): + if static == True: + return os.path.join(self.get_build_path_bin(name), name + "_static" + self.suffix_binary) + return os.path.join(self.get_build_path_bin(name), name + "_dynamic" + self.suffix_binary) ## ## @brief Get the path filename of the build static library name @@ -721,12 +723,20 @@ class Target: except AttributeError: debug.error("target have no 'un_install_package' instruction") elif action_name[:3] == "run": + 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: - debug.warning("action 'run' wrong options options ... : '" + action_name + "' might be separate with ':'") + if bin_name != None: + debug.warning("action 'run' wrong options options ... : '" + action_name + "' might be separate with ':'") option_list = [] else: option_list_tmp = option_list[1:] @@ -736,7 +746,7 @@ class Target: else: option_list = [] #try: - self.run(module_name, option_list) + self.run(module_name, option_list, bin_name) #except AttributeError: # debug.error("target have no 'run' instruction") elif action_name == "log": @@ -843,19 +853,18 @@ class Target: if module.get_type() == 'PREBUILD': #nothing to do ... return - if module.get_type() == 'LIBRARY' \ - or module.get_type() == 'LIBRARY_DYNAMIC' \ - or module.get_type() == 'LIBRARY_STATIC': + elif module.get_type() == 'LIBRARY' \ + or module.get_type() == 'LIBRARY_DYNAMIC' \ + or module.get_type() == 'LIBRARY_STATIC': debug.info("Can not create package for library"); return - if module.get_type() == 'BINARY' \ - or module.get_type() == 'BINARY_STAND_ALONE': + 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) - if module.get_type() == 'BINARY_SHARED': + elif module.get_type() == 'BINARY_SHARED': + 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) - if module.get_type() == 'PACKAGE': - debug.info("Can not create package for package"); - return debug.debug("make_package [STOP]") return @@ -919,26 +928,60 @@ class Target: def make_package_binary_bin(self, path_package, pkg_name, base_pkg_path, heritage_list, static): debug.debug("make_package_binary_bin [START]") copy_list={} + # creata basic output path path_package_bin = os.path.join(path_package, self.pkg_path_bin) tools.create_directory_of_file(path_package_bin) - path_src = self.get_build_file_bin(pkg_name) - path_dst = os.path.join(path_package_bin, pkg_name + self.suffix_binary) - debug.verbose("path_dst: " + str(path_dst)) - tools.copy_file(path_src, - path_dst, - in_list=copy_list) - try: - path_src = self.get_build_file_bin(pkg_name) + # Local module binary + path_src = self.get_build_file_bin(pkg_name, static) + if os.path.exists(path_src) == True: + try: + path_dst = os.path.join(path_package_bin, pkg_name + self.suffix_binary) + debug.verbose("path_dst: " + str(path_dst)) + tools.copy_file(path_src, + path_dst, + in_list=copy_list) + except: + debug.extreme_verbose("can not find : " + path_src) + pass + path_src = self.get_build_file_bin(pkg_name, static) + path_src = path_src[:len(path_src)-4] + "js" + if os.path.exists(path_src) == True: + try: + path_dst = os.path.join(path_package_bin, pkg_name + self.suffix_binary2) + debug.verbose("path_dst: " + str(path_dst)) + tools.copy_file(path_src, + path_dst, + in_list=copy_list) + except: + debug.extreme_verbose("can not find : " + path_src) + pass + # heritage binary + debug.debug("heritage for " + str(pkg_name) + ":") + for heritage in heritage_list.list_heritage: + debug.debug("sub elements: " + str(heritage.name)) + path_src = self.get_build_file_bin(heritage.name, static) + if os.path.exists(path_src) == True: + try: + path_dst = os.path.join(path_package_bin, heritage.name + self.suffix_binary) + debug.verbose("path_dst: " + str(path_dst)) + tools.copy_file(path_src, + path_dst, + in_list=copy_list) + except: + debug.extreme_verbose("can not find : " + path_src) + pass + path_src = self.get_build_file_bin(heritage.name, static) path_src = path_src[:len(path_src)-4] + "js" - path_dst = os.path.join(path_package_bin, pkg_name + self.suffix_binary2) - debug.verbose("path_dst: " + str(path_dst)) - tools.copy_file(path_src, - path_dst, - in_list=copy_list) - except: - debug.extreme_verbose("can not find : " + path_src) - pass - + if os.path.exists(path_src) == True: + try: + path_dst = os.path.join(path_package_bin, heritage.name + self.suffix_binary2) + debug.verbose("path_dst: " + str(path_dst)) + tools.copy_file(path_src, + path_dst, + in_list=copy_list) + except: + debug.extreme_verbose("can not find : " + path_src) + pass #real copy files ret_copy = tools.copy_list(copy_list) ret_remove = False @@ -1068,7 +1111,7 @@ class Target: debug.debug("------------------------------------------------------------------------") debug.error("action not implemented ...") - def run(self, pkg_name, option_list): + def run(self, pkg_name, option_list, binary_name = None): debug.debug("------------------------------------------------------------------------") debug.info("-- Run package '" + pkg_name + "' + option: " + str(option_list)) debug.debug("------------------------------------------------------------------------") diff --git a/lutin/z_builder/lutinBuilder_binary.py b/lutin/z_builder/lutinBuilder_binary.py index 80c6759..d87d8b7 100644 --- a/lutin/z_builder/lutinBuilder_binary.py +++ b/lutin/z_builder/lutinBuilder_binary.py @@ -59,7 +59,7 @@ def get_support_multithreading(): ## def link(file, binary, target, depancy, flags, name, basic_path, static = False): file_src = file - file_dst = target.get_build_file_bin(binary) + file_dst = target.get_build_file_bin(name, static) file_depend = file_dst + target.suffix_dependence file_cmd = file_dst + target.suffix_cmd_line file_warning = file_dst + target.suffix_warning @@ -128,7 +128,7 @@ def link(file, binary, target, depancy, flags, name, basic_path, static = False) cmd.append("-Wl,-R$ORIGIN/../lib/") except: pass - cmd.append("-Wl,-rpath,\"\$ORIGIN/../lib\"") + cmd.append("-Wl,-rpath,\"$ORIGIN/../lib\"") try: cmd.append(flags["local"]["link"]) except: diff --git a/lutin/z_target/lutinTarget_IOs.py b/lutin/z_target/lutinTarget_IOs.py index 7ed4a10..e3a1e60 100644 --- a/lutin/z_target/lutinTarget_IOs.py +++ b/lutin/z_target/lutinTarget_IOs.py @@ -462,7 +462,7 @@ class Target(target.Target): cmdLine = "tail -f ~/Library/Logs/iOS\ Simulator/7.1/system.log" multiprocess.run_command_no_lock_out(cmdLine) - def run(self, pkg_name, option_list): + def run(self, pkg_name, option_list, binary_name = None): debug.debug("------------------------------------------------------------------------") debug.info("-- Run package '" + pkg_name + "' + option: " + str(option_list)) debug.debug("------------------------------------------------------------------------") diff --git a/lutin/z_target/lutinTarget_Linux.py b/lutin/z_target/lutinTarget_Linux.py index b39c217..d644a3f 100644 --- a/lutin/z_target/lutinTarget_Linux.py +++ b/lutin/z_target/lutinTarget_Linux.py @@ -162,11 +162,13 @@ class Target(target.Target): # remove executable link version: tools.remove_file(target_bin_link) - def run(self, pkg_name, option_list): + def run(self, pkg_name, option_list, binary_name = None): + if binary_name == None: + binary_name = pkg_name; debug.debug("------------------------------------------------------------------------") - debug.info("-- Run package '" + pkg_name + "' + option: " + str(option_list)) + debug.info("-- Run package '" + pkg_name + "' executable: '" + binary_name + "' + option: " + str(option_list)) debug.debug("------------------------------------------------------------------------") - appl_path = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app", "bin", pkg_name) + appl_path = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app", "bin", binary_name) cmd = appl_path + " " for elem in option_list: cmd += elem + " " diff --git a/lutin/z_target/lutinTarget_MacOs.py b/lutin/z_target/lutinTarget_MacOs.py index 5c6e531..fa95d48 100644 --- a/lutin/z_target/lutinTarget_MacOs.py +++ b/lutin/z_target/lutinTarget_MacOs.py @@ -173,7 +173,7 @@ class Target(target.Target): if os.path.exists("/Applications/" + pkg_name + ".app") == True: shutil.rmtree("/Applications/" + pkg_name + ".app") - def run(self, pkg_name, option_list): + def run(self, pkg_name, option_list, binary_name = None): debug.debug("------------------------------------------------------------------------") debug.info("-- Run package '" + pkg_name + "'") debug.debug("------------------------------------------------------------------------") diff --git a/lutin/z_target/lutinTarget_Web.py b/lutin/z_target/lutinTarget_Web.py index 3ec0ecc..df8e9aa 100644 --- a/lutin/z_target/lutinTarget_Web.py +++ b/lutin/z_target/lutinTarget_Web.py @@ -213,7 +213,7 @@ class Target(lutinTarget_Linux.Target): # remove executable link version: tools.remove_file(target_bin_link) - def run(self, pkg_name, option_list): + def run(self, pkg_name, option_list, binary_name = None): debug.debug("------------------------------------------------------------------------") debug.info("-- Run package '" + pkg_name + "' + option: " + str(option_list)) debug.debug("------------------------------------------------------------------------") diff --git a/lutin/z_target/lutinTarget_Windows.py b/lutin/z_target/lutinTarget_Windows.py index 8c23624..0f6401c 100644 --- a/lutin/z_target/lutinTarget_Windows.py +++ b/lutin/z_target/lutinTarget_Windows.py @@ -196,7 +196,7 @@ class Target(target.Target): debug.warning(" ==> TODO") #sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package - def run(self, pkg_name, option_list): + def run(self, pkg_name, option_list, binary_name = None): debug.debug("------------------------------------------------------------------------") debug.info("-- Run package '" + pkg_name + "' + option: " + str(option_list)) debug.debug("------------------------------------------------------------------------")