From f1d6ad6ce807910980d1bb1ff6072f68600bd252 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 17 Sep 2015 22:07:20 +0200 Subject: [PATCH] [DEV] reintegrate Android interfac package builder (bug on DATA) --- lutin/module.py | 36 ++++--- .../z_builder/lutinBuilder_libraryDynamic.py | 25 +++-- lutin/z_target/lutinTarget_Android.py | 96 +++++++++++++++---- lutin/z_target/lutinTarget_Linux.py | 2 +- 4 files changed, 122 insertions(+), 37 deletions(-) diff --git a/lutin/module.py b/lutin/module.py index ea3e519..8c5257c 100644 --- a/lutin/module.py +++ b/lutin/module.py @@ -347,7 +347,16 @@ class Module: # add at the heritage list : self.sub_heritage_list.add_heritage_list(inherit_list) # do sub library action for automatic generating ... - if self.type in target.action_on_state: + local_type = self.type + if self.type == 'LIBRARY_DYNAMIC': + local_type = 'LIBRARY' + if self.type == 'LIBRARY_STATIC': + local_type = 'LIBRARY' + if self.type == 'BINARY_SHARED': + local_type = 'BINARY' + if self.type == 'BINARY_STAND_ALONE': + local_type = 'BINARY' + if local_type in target.action_on_state: for lvl in range(0,100): for level, action_name, action in target.action_on_state[self.type]: if level == lvl: @@ -356,21 +365,21 @@ class Module: # ---------------------------------------------------- # -- Generic library help -- # ---------------------------------------------------- - if self.type=='PREBUILD': + if self.type == 'PREBUILD': debug.print_element("Prebuild", self.name, "", "") - if self.type=='LIBRARY': + if self.type == 'LIBRARY': debug.print_element("Library", self.name, "", "") - if self.type=='LIBRARY_DYNAMIC': + if self.type == 'LIBRARY_DYNAMIC': debug.print_element("Library(dynamic)", self.name, "", "") - if self.type=='LIBRARY_STATIC': + if self.type == 'LIBRARY_STATIC': debug.print_element("Library(static)", self.name, "", "") - if self.type=='BINARY': + if self.type == 'BINARY': debug.print_element("Binary(auto)", self.name, "", "") - if self.type=='BINARY_SHARED': + if self.type == 'BINARY_SHARED': debug.print_element("Binary (shared)", self.name, "", "") - if self.type=='BINARY_STAND_ALONE': + if self.type == 'BINARY_STAND_ALONE': debug.print_element("Binary (stand alone)", self.name, "", "") - if self.type=='PACKAGE': + if self.type == 'PACKAGE': debug.print_element("Package", self.name, "", "") # ---------------------------------------------------- # -- Sources compilation -- @@ -492,6 +501,9 @@ class Module: # abstract GUI interface ... shared_mode = True break; + static_mode = True + if self.type == 'BINARY_SHARED': + static_mode = False if shared_mode == True: try: tmp_builder = builder.get_builder_with_output("so"); @@ -501,7 +513,8 @@ class Module: target, self.sub_heritage_list, name = self.name, - basic_path = self.origin_path) + basic_path = self.origin_path, + static = static_mode) self.local_heritage.add_sources(res_file) except ValueError: debug.error(" UN-SUPPORTED link format: '.so'") @@ -521,9 +534,6 @@ class Module: else: try: tmp_builder = builder.get_builder_with_output("bin"); - static_mode = True - if self.type == 'BINARY_SHARED': - static_mode = False res_file = tmp_builder.link(list_sub_file_needed_to_build, package_name, target, diff --git a/lutin/z_builder/lutinBuilder_libraryDynamic.py b/lutin/z_builder/lutinBuilder_libraryDynamic.py index efdfd66..deea1b7 100644 --- a/lutin/z_builder/lutinBuilder_libraryDynamic.py +++ b/lutin/z_builder/lutinBuilder_libraryDynamic.py @@ -38,15 +38,26 @@ def get_output_type(): ## ## @brief Commands for running gcc to link a shared library. ## -def link(file, binary, target, depancy, name, basic_path): +def link(file, binary, target, depancy, name, basic_path, static=False): file_src, file_dst, file_depend, file_cmd, file_warning = target.generate_file(binary, name, basic_path, file, "lib-shared") - #get all parent dynamic libs - list_dynamic = depancy.src['dynamic'] - # get only parent shared that is not static list_static = [] - for elem in depancy.src['static']: - if elem[:-len(target.suffix_lib_static)] + target.suffix_lib_dynamic not in depancy.src['dynamic']: - list_static.append(elem) + list_dynamic = [] + if static == True: + #get all parent static libs + list_static = depancy.src['static'] + # get only parent shared that is not static + for elem in depancy.src['dynamic']: + lib_name = elem[:-len(target.suffix_lib_dynamic)] + target.suffix_lib_static + if lib_name not in depancy.src['static']: + list_dynamic.append(elem) + else: + #get all parent dynamic libs + list_dynamic = depancy.src['dynamic'] + # get only parent shared that is not static + for elem in depancy.src['static']: + lib_name = elem[:-len(target.suffix_lib_static)] + target.suffix_lib_dynamic + if lib_name not in depancy.src['dynamic']: + list_static.append(elem) #create command Line cmd = [ target.xx, diff --git a/lutin/z_target/lutinTarget_Android.py b/lutin/z_target/lutinTarget_Android.py index 0166207..505de9d 100644 --- a/lutin/z_target/lutinTarget_Android.py +++ b/lutin/z_target/lutinTarget_Android.py @@ -77,11 +77,15 @@ class Target(target.Target): debug.info("Gcc x86 path does not exist !!!") # TODO : Set it back in the package only ... - #self.path_bin="/mustNotCreateBinary" - #self.path_lib="/data/lib/armeabi" - #self.path_data="/data/assets" - #self.path_doc="/doc" + #self.path_bin="mustNotCreateBinary" + #self.path_lib="data/lib/armeabi" + #self.path_data="data/assets" + #self.path_doc="doc" #self.suffix_package='.pkg' + self.pkg_path_data = "data/assets" + self.pkg_path_bin = "mustNotCreateBinary" + self.pkg_path_lib = "data/lib/armeabi" + self.pkg_path_license = "license" # board id at 15 is for android 4.0.3 and more ... (note: API 14 has been removed ...) self.boardId = 15 @@ -214,17 +218,77 @@ class Target(target.Target): debug.debug("------------------------------------------------------------------------") debug.info("Generate package '" + pkg_name + "'") debug.debug("------------------------------------------------------------------------") + + #output path + target_outpath = self.get_staging_path(pkg_name) + tools.create_directory_of_file(target_outpath) + + # TODO : Remove : + static = True + ## Create share datas + if static == True: + target_outpath_data = os.path.join(target_outpath, self.pkg_path_data, pkg_name) + else: + target_outpath_data = os.path.join(target_outpath, self.pkg_path_data) + tools.create_directory_of_file(target_outpath_data) + 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_path_data(heritage.name) + debug.verbose(" has directory: " + path_src) + if os.path.isdir(path_src): + if static == True: + debug.debug(" need copy: " + path_src + " to " + target_outpath_data) + #copy all data: + tools.copy_anything(path_src, target_outpath_data, recursive=True, force_identical=True) + else: + debug.debug(" need copy: " + os.path.dirname(path_src) + " to " + target_outpath_data) + #copy all data: + tools.copy_anything(os.path.dirname(path_src), target_outpath_data, recursive=True, force_identical=True) + + ## copy binary files + # in Android Package wa have no binary element, only shared object ... + + + ## Create libraries + target_outpath_lib = os.path.join(target_outpath, self.pkg_path_lib) + tools.create_directory_of_file(target_outpath_lib) + # copy application lib: (needed to lunch ...) + file_src = self.get_build_file_dynamic(pkg_name) + if os.path.isfile(file_src): + debug.debug(" need copy: " + file_src + " to " + target_outpath_lib) + tools.copy_file(file_src, os.path.join(target_outpath_lib, os.path.basename(file_src)) ) + # copy other if needed: + if static == False: + #copy all shared libs... + debug.verbose("libs for " + str(pkg_name) + ":") + for heritage in heritage_list.list_heritage: + debug.debug("sub elements: " + str(heritage.name)) + file_src = self.get_build_file_dynamic(heritage.name) + debug.verbose(" has directory: " + file_src) + if os.path.isfile(file_src): + debug.debug(" need copy: " + file_src + " to " + target_outpath_lib) + #copy all data: + # TODO : We can have a problem when writing over library files ... + tools.copy_file(file_src, os.path.join(target_outpath_lib, os.path.basename(file_src)) ) + + + + + + + pkg_name_application_name = pkg_name if self.config["mode"] == "debug": pkg_name_application_name += "debug" # FINAL_path_JAVA_PROJECT - self.path_javaProject= self.get_staging_path(pkg_name) \ - + "/src/" \ - + pkg_properties["COMPAGNY_TYPE"] \ - + "/" + pkg_properties["COMPAGNY_NAME2"] \ - + "/" + pkg_name_application_name + "/" + self.path_java_project = os.path.join(self.get_staging_path(pkg_name), + "src", + pkg_properties["COMPAGNY_TYPE"], + pkg_properties["COMPAGNY_NAME2"], + pkg_name_application_name) #FINAL_FILE_ABSTRACTION - self.file_finalAbstraction = self.path_javaProject + "/" + pkg_name_application_name + ".java" + self.file_final_abstraction = os.path.join(self.path_java_project, pkg_name_application_name + ".java") compleatePackageName = pkg_properties["COMPAGNY_TYPE"]+"."+pkg_properties["COMPAGNY_NAME2"]+"." + pkg_name_application_name @@ -235,7 +299,7 @@ class Target(target.Target): debug.print_element("pkg", "absractionFile", "<==", "dynamic file") # Create path : - tools.create_directory_of_file(self.file_finalAbstraction) + tools.create_directory_of_file(self.file_final_abstraction) # Create file : # java ==> done by ewol wrapper ... (and compiled in the normal compilation system ==> must be find in the dependency list of jar ... @@ -303,7 +367,7 @@ class Target(target.Target): # TODO : check this I do not think it is really usefull ... ==> write for IDE only ... filesString += self.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/src/android/UnusedStub.java " if len(pkg_properties["ANDROID_WALLPAPER_PROPERTIES"])!=0: - filesString += self.path_javaProject + pkg_name_application_name + "Settings.java " + filesString += self.path_java_project + pkg_name_application_name + "Settings.java " adModJarFile = "" if "ADMOD_ID" in pkg_properties: @@ -314,15 +378,15 @@ class Target(target.Target): + "-classpath " + self.path_sdk + "/platforms/android-" + str(self.boardId) + "/android.jar" \ + adModJarFile + " " \ + filesString \ - + self.file_finalAbstraction + " " \ + + self.file_final_abstraction + " " \ + self.get_staging_path(pkg_name) + "/src/R.java " multiprocess.run_command(cmdLine) """ - debug.verbose("heritage .so=" + str(tools.filter_extention(heritage_list.src, ["so"]))) - debug.verbose("heritage .jar=" + str(tools.filter_extention(heritage_list.src, ["jar"]))) + debug.verbose("heritage .so=" + str(tools.filter_extention(heritage_list.src['dynamic'], ["so"]))) + debug.verbose("heritage .jar=" + str(tools.filter_extention(heritage_list.src['src'], ["jar"]))) class_extern = "" - upper_jar = tools.filter_extention(heritage_list.src, ["jar"]) + upper_jar = tools.filter_extention(heritage_list.src['src'], ["jar"]) #debug.warning("ploppppp = " + str(upper_jar)) for elem in upper_jar: if len(class_extern) > 0: diff --git a/lutin/z_target/lutinTarget_Linux.py b/lutin/z_target/lutinTarget_Linux.py index 0077bdf..36ddb68 100644 --- a/lutin/z_target/lutinTarget_Linux.py +++ b/lutin/z_target/lutinTarget_Linux.py @@ -118,7 +118,7 @@ class Target(target.Target): target_outpath_data = os.path.join(target_outpath, self.pkg_path_data) tools.create_directory_of_file(target_outpath_data) debug.debug("heritage for " + str(pkg_name) + ":") - for heritage in heritage_list.list_heritage: + for heritage in heritage_list.lissourcet_heritage: debug.debug("sub elements: " + str(heritage.name)) path_src = self.get_build_path_data(heritage.name) debug.verbose(" has directory: " + path_src)