diff --git a/lutin/env.py b/lutin/env.py index d280d56..1cf40e7 100644 --- a/lutin/env.py +++ b/lutin/env.py @@ -84,6 +84,14 @@ def print_pretty(myString, force=False): "cf", "-C" ] + elif end_with(cmdApplication, ["aapt"]) == True: + baseElementList = [ + "-M", + "-F", + "-I", + "-S", + "-J" + ] for element in baseElementList: tmpcmdLine = tmpcmdLine.replace(element+'\n\t', element+' ') for element in ["<", "<<", ">", ">>"]: diff --git a/lutin/module.py b/lutin/module.py index 99a00bb..df4d00a 100644 --- a/lutin/module.py +++ b/lutin/module.py @@ -88,7 +88,6 @@ class Module: "VERSION_CODE" : "", "NAME" : set("no-name"), # name of the application "ANDROID_MANIFEST" : "", # By default generate the manifest - "ANDROID_JAVA_FILES" : ["DEFAULT"], # when user want to create his own services and activities "ANDROID_RESOURCES" : [], "ANDROID_APPL_TYPE" : "APPL", # the other mode is "WALLPAPER" ... and later "WIDGET" "ANDROID_WALLPAPER_PROPERTIES" : [], # To create properties of the wallpaper (no use of EWOL display) @@ -194,7 +193,7 @@ class Module: self.sub_heritage_list = heritage.HeritageList() # optionnal dependency : for dep, option, export in self.depends_optionnal: - inherit_list, isBuilt = target.build_optionnal(dep, package_name) + inherit_list, isBuilt = target.build(dep, package_name, True) if isBuilt == True: self.local_heritage.add_depends(dep); # TODO : Add optionnal Flags ... @@ -206,7 +205,8 @@ class Module: # add at the heritage list : self.sub_heritage_list.add_heritage_list(inherit_list) for dep in self.depends: - inherit_list = target.build(dep, package_name) + debug.debug("module: '" + str(self.name) + "' request: '" + dep + "'") + inherit_list = target.build(dep, package_name, False) # add at the heritage list : self.sub_heritage_list.add_heritage_list(inherit_list) # do sub library action for automatic generating ... @@ -215,10 +215,33 @@ class Module: elem = action(target, self, package_name); - - # build local sources in a specific order : - for extention_local in self.extention_order_build: - list_file = tools.filter_extention(self.src, [extention_local]) + if self.type != 'PREBUILD': + # build local sources in a specific order : + for extention_local in self.extention_order_build: + list_file = tools.filter_extention(self.src, [extention_local]) + for file in list_file: + #debug.info(" " + self.name + " <== " + file); + fileExt = file.split(".")[-1] + try: + tmp_builder = builder.get_builder(fileExt); + resFile = tmp_builder.compile(file, + package_name, + target, + self.sub_heritage_list, + flags = self.flags, + path = self.path, + name = self.name, + basic_folder = self.origin_folder) + if resFile["action"] == "add": + list_sub_file_needed_to_build.append(resFile["file"]) + elif resFile["action"] == "path": + self.add_path(resFile["path"], type='c') + else: + debug.error("an not do action for : " + str(resFile)) + except ValueError: + debug.warning(" UN-SUPPORTED file format: '" + self.origin_folder + "/" + file + "'") + # now build the other : + list_file = tools.filter_extention(self.src, self.extention_order_build, invert=True) for file in list_file: #debug.info(" " + self.name + " <== " + file); fileExt = file.split(".")[-1] @@ -240,35 +263,13 @@ class Module: debug.error("an not do action for : " + str(resFile)) except ValueError: debug.warning(" UN-SUPPORTED file format: '" + self.origin_folder + "/" + file + "'") - # now build the other : - list_file = tools.filter_extention(self.src, self.extention_order_build, invert=True) - for file in list_file: - #debug.info(" " + self.name + " <== " + file); - fileExt = file.split(".")[-1] - try: - tmp_builder = builder.get_builder(fileExt); - resFile = tmp_builder.compile(file, - package_name, - target, - self.sub_heritage_list, - flags = self.flags, - path = self.path, - name = self.name, - basic_folder = self.origin_folder) - if resFile["action"] == "add": - list_sub_file_needed_to_build.append(resFile["file"]) - elif resFile["action"] == "path": - self.add_path(resFile["path"], type='c') - else: - debug.error("an not do action for : " + str(resFile)) - except ValueError: - debug.warning(" UN-SUPPORTED file format: '" + self.origin_folder + "/" + file + "'") - # when multiprocess availlable, we need to synchronize here ... - multiprocess.pool_synchrosize() + # when multiprocess availlable, we need to synchronize here ... + multiprocess.pool_synchrosize() # generate end point: if self.type=='PREBUILD': debug.print_element("Prebuild", self.name, "==>", "find") + self.local_heritage.add_sources(self.src) elif self.type=='LIBRARY': try: tmp_builder = builder.get_builder_with_output("a"); @@ -323,6 +324,7 @@ class Module: self.sub_heritage_list, name = "lib" + self.name, basic_folder = self.origin_folder) + self.local_heritage.add_sources(resFile) except ValueError: debug.error(" UN-SUPPORTED link format: '.so'") try: @@ -355,7 +357,11 @@ class Module: target.copy_to_staging(self.name) if target.endGeneratePackage==True: # generate the package with his properties ... - target.make_package(self.name, self.package_prop, self.origin_folder + "/..") + if target.name=="Android": + self.sub_heritage_list.add_heritage(self.local_heritage) + target.make_package(self.name, self.package_prop, self.origin_folder + "/..", self.sub_heritage_list) + else: + target.make_package(self.name, self.package_prop, self.origin_folder + "/..") else: debug.error("Dit not know the element type ... (impossible case) type=" + self.type) diff --git a/lutin/system.py b/lutin/system.py index e9096c7..f3284b9 100644 --- a/lutin/system.py +++ b/lutin/system.py @@ -30,6 +30,7 @@ class System: self.export_flags_ld_shared=[] self.export_libs_ld=[] self.export_libs_ld_shared=[] + self.export_src=[] def append_and_check(self, listout, newElement, order): for element in listout: @@ -62,6 +63,9 @@ class System: def add_export_flag_MM(self, list): self.append_to_internalList(self.export_flags_mm, list) + def add_export_SRC(self, list): + self.append_to_internalList(self.export_src, list) + @@ -74,6 +78,7 @@ def createModuleFromSystem(target, dict): myModule.add_export_flag('c++', dict["system"].export_flags_xx) myModule.add_export_flag('m', dict["system"].export_flags_m) myModule.add_export_flag('mm', dict["system"].export_flags_mm) + myModule.add_src_file(dict["system"].export_src) # add the currrent module at the return myModule @@ -114,6 +119,7 @@ def import_path(path): "loaded":False, "exist":False, "module":None}] + debug.debug("list system=" + str(systemList)) def display(): global systemList @@ -123,8 +129,9 @@ def display(): debug.info(" '" + data["name"] +"' in " + data["path"]) -def exist(lib_name, target_name) : +def exist(lib_name, target_name, target) : global systemList + debug.verbose("exist= " + lib_name + " in " + target_name) if target_name not in systemList: return False for data in systemList[target_name]: @@ -137,7 +144,8 @@ def exist(lib_name, target_name) : theSystem = __import__(__startSystemName + target_name + "_" + data["name"]) #create the system module try: - data["system"] = theSystem.System() + debug.info("call : " + data["name"]) + data["system"] = theSystem.System(target) data["exist"] = data["system"].valid except: debug.debug("Not find: '" + data["name"] + "'") diff --git a/lutin/target.py b/lutin/target.py index f61fa98..c23ec8c 100644 --- a/lutin/target.py +++ b/lutin/target.py @@ -345,23 +345,19 @@ class Target: for elem in self.moduleList: if elem.name == name: return True - if optionnal == False: + # TODO : Check internal module and system module ... + # need to import the module (or the system module ...) + exist = system.exist(name, self.name, self) + if exist == True: + system.load(self, name, self.name) + return True; + # try to find in the local Modules: + exist = module.exist(self, name) + if exist == True: module.load_module(self, name) - return True + return True; else: - # TODO : Check internal module and system module ... - # need to import the module (or the system module ...) - exist = system.exist(name, self.name) - if exist == True: - system.load(self, name, self.name) - return True; - # try to find in the local Modules: - exist = module.exist(self, name) - if exist == True: - module.load_module(self, name) - return True; - else: - return False; + return False; def load_all(self): listOfAllTheModule = module.list_all_module() @@ -374,19 +370,7 @@ class Target: mod.ext_project_add_module(self, projectMng, addedModule) return - def build_optionnal(self, moduleName, packagesName=None): - present = self.load_if_needed(moduleName, optionnal=True) - if present == False: - return [heritage.HeritageList(), False] - # clean requested - for mod in self.moduleList: - if mod.name == moduleName: - debug.debug("build module '" + moduleName + "'") - return [mod.build(self, None), True] - debug.warning("not know module name : '" + moduleName + "' to '" + "build" + "' it") - return [heritage.HeritageList(), False] - - def build(self, name, packagesName=None): + def build(self, name, packagesName=None, optionnal=False): if name == "dump": debug.info("dump all") self.load_all() @@ -417,7 +401,7 @@ class Target: actionName = gettedElement[1] else : actionName = "build" - debug.verbose("requested : " + moduleName + "-" + actionName) + debug.verbose("requested : " + moduleName + "?" + actionName) if actionName == "install": self.build(moduleName + "?build") self.install_package(moduleName) @@ -426,7 +410,10 @@ class Target: elif actionName == "log": self.Log(moduleName) else: - self.load_if_needed(moduleName) + present = self.load_if_needed(moduleName, optionnal=optionnal) + if present == False \ + and optionnal == True: + return [heritage.HeritageList(), False] # clean requested for mod in self.moduleList: if mod.name == moduleName: @@ -438,7 +425,11 @@ class Target: return mod.clean(self) elif actionName == "build": debug.debug("build module '" + moduleName + "'") + if optionnal == True: + return [mod.build(self, None), True] return mod.build(self, None) + if optionnal == True: + return [heritage.HeritageList(), False] debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it") def add_action(self, name_of_state="PACKAGE", action=None): diff --git a/lutin/z_builder/lutinBuilder_java.py b/lutin/z_builder/lutinBuilder_java.py index 1df0888..6af1667 100644 --- a/lutin/z_builder/lutinBuilder_java.py +++ b/lutin/z_builder/lutinBuilder_java.py @@ -65,8 +65,7 @@ def compile(file, binary, target, depancy, flags, path, name, basic_folder): out += ":" out += elem cmd.append(out) - # todo : Remplace this with class_extern = [] and add a dependency with android framework ... - class_extern = [target.folder_sdk + "/platforms/android-" + str(target.boardId) + "/android.jar"] + class_extern = [] upper_jar = tools.filter_extention(depancy.src, ["jar"]) #debug.warning("ploppppp = " + str(upper_jar)) for elem in upper_jar: diff --git a/lutin/z_builder/lutinBuilder_libraryDynamic.py b/lutin/z_builder/lutinBuilder_libraryDynamic.py index b7cb74d..da666de 100644 --- a/lutin/z_builder/lutinBuilder_libraryDynamic.py +++ b/lutin/z_builder/lutinBuilder_libraryDynamic.py @@ -99,3 +99,4 @@ def link(file, binary, target, depancy, name, basic_folder): # write cmd line only after to prevent errors ... multiprocess.store_command(cmdLine, file_cmd) #debug.print_element("SharedLib", self.name, "==>", tmpList[1]) + return file_dst diff --git a/lutin/z_system/lutinSystem_Android_SDK.py b/lutin/z_system/lutinSystem_Android_SDK.py new file mode 100644 index 0000000..d56dfdc --- /dev/null +++ b/lutin/z_system/lutinSystem_Android_SDK.py @@ -0,0 +1,24 @@ +#!/usr/bin/python +## +## @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 +import os + +class System(system.System): + def __init__(self, target): + system.System.__init__(self) + # create some HELP: + self.help="SDK: Android SDK basic interface java\n" + self.valid = True + # todo : create a searcher of the presence of the library: + self.add_export_SRC(target.folder_sdk + "/platforms/android-" + str(target.boardId) + "/android.jar") + + diff --git a/lutin/z_system/lutinSystem_IOs_CoreAudio.py b/lutin/z_system/lutinSystem_IOs_CoreAudio.py index a9156bd..87a533b 100644 --- a/lutin/z_system/lutinSystem_IOs_CoreAudio.py +++ b/lutin/z_system/lutinSystem_IOs_CoreAudio.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="CoreAudio : Ios interface for audio (all time present, just system interface)" diff --git a/lutin/z_system/lutinSystem_Linux_alsa.py b/lutin/z_system/lutinSystem_Linux_alsa.py index dbaca61..78ab40e 100644 --- a/lutin/z_system/lutinSystem_Linux_alsa.py +++ b/lutin/z_system/lutinSystem_Linux_alsa.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="ALSA : Advanced Linux Sound Architecture\n Can be install with the package:\n - libasound2-dev" diff --git a/lutin/z_system/lutinSystem_Linux_boost.py b/lutin/z_system/lutinSystem_Linux_boost.py index 1b8db73..c25c6da 100644 --- a/lutin/z_system/lutinSystem_Linux_boost.py +++ b/lutin/z_system/lutinSystem_Linux_boost.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="BOOST : Boost interface (need when we have not all c++ feature\n Can be install with the package:\n - libboost-all-dev" diff --git a/lutin/z_system/lutinSystem_Linux_jack.py b/lutin/z_system/lutinSystem_Linux_jack.py index 8fd95ae..27764f7 100644 --- a/lutin/z_system/lutinSystem_Linux_jack.py +++ b/lutin/z_system/lutinSystem_Linux_jack.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="JACK : Jack Low-Latency Audio Server\n Can be install with the package:\n - libjack-jackd2-dev (new)\n - libjack-dev (old)" diff --git a/lutin/z_system/lutinSystem_Linux_oss.py b/lutin/z_system/lutinSystem_Linux_oss.py index aa30e40..f636e55 100644 --- a/lutin/z_system/lutinSystem_Linux_oss.py +++ b/lutin/z_system/lutinSystem_Linux_oss.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="OSS : Linux Open Sound System\n Can be install with the package:\n - ... TODO ..." diff --git a/lutin/z_system/lutinSystem_Linux_pulse.py b/lutin/z_system/lutinSystem_Linux_pulse.py index 83b1fb7..0a5fce6 100644 --- a/lutin/z_system/lutinSystem_Linux_pulse.py +++ b/lutin/z_system/lutinSystem_Linux_pulse.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="PULSE : The Linux PulseAudio\n Can be install with the package:\n - libpulse-dev" diff --git a/lutin/z_system/lutinSystem_Linux_z.py b/lutin/z_system/lutinSystem_Linux_z.py index b8bf383..5ae9b78 100644 --- a/lutin/z_system/lutinSystem_Linux_z.py +++ b/lutin/z_system/lutinSystem_Linux_z.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="Z : z library \n Can be install with the package:\n - zlib1g-dev" diff --git a/lutin/z_system/lutinSystem_MacOs_CoreAudio.py b/lutin/z_system/lutinSystem_MacOs_CoreAudio.py index 1723e82..88bec41 100644 --- a/lutin/z_system/lutinSystem_MacOs_CoreAudio.py +++ b/lutin/z_system/lutinSystem_MacOs_CoreAudio.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="CoreAudio : MacOs interface for audio (all time present, just system interface)" diff --git a/lutin/z_system/lutinSystem_Windows_ds.py b/lutin/z_system/lutinSystem_Windows_ds.py index dd903c7..9cfc6e7 100644 --- a/lutin/z_system/lutinSystem_Windows_ds.py +++ b/lutin/z_system/lutinSystem_Windows_ds.py @@ -13,7 +13,7 @@ from lutin import tools import os class System(system.System): - def __init__(self): + def __init__(self, target): system.System.__init__(self) # create some HELP: self.help="DirectSound : Direct sound API for windows audio interface" diff --git a/lutin/z_target/lutinTarget_Android.py b/lutin/z_target/lutinTarget_Android.py index 75493fb..ac22f08 100644 --- a/lutin/z_target/lutinTarget_Android.py +++ b/lutin/z_target/lutinTarget_Android.py @@ -192,7 +192,7 @@ class Target(target.Target): def get_staging_folder_data(self, binaryName): return self.get_staging_folder(binaryName) + self.folder_data - def make_package(self, pkgName, pkgProperties, basePkgPath): + def make_package(self, pkgName, pkgProperties, basePkgPath, heritage): # http://alp.developpez.com/tutoriels/debian/creer-paquet/ debug.debug("------------------------------------------------------------------------") debug.info("Generate package '" + pkgName + "'") @@ -262,6 +262,7 @@ class Target(target.Target): debug.error("an error occured when getting the tools for android") androidToolPath += dirnames[0] + "/" + # this is to create resource file for android ... (we did not use aset in jar with ewol ... adModResouceFolder = "" if "ADMOD_ID" in pkgProperties: adModResouceFolder = " -S " + self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/res/ " @@ -273,25 +274,17 @@ class Target(target.Target): + adModResouceFolder \ + "-J " + self.get_staging_folder(pkgName) + "/src/ " multiprocess.run_command(cmdLine) - #aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library} - # -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}] tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/build/classes/noFile") debug.print_element("pkg", "*.class", "<==", "*.java") - # more information with : -Xlint - # + self.file_finalAbstraction + " "\ # this generate ex: out/Android/debug/staging/tethys/src/com/edouarddupin/tethys/edn.java - #generate android java files: filesString="" - for element in pkgProperties["ANDROID_JAVA_FILES"]: - if element=="DEFAULT": - # this is deprecated ... - else: - filesString += element + " " + """ + old : if "ADMOD_ID" in pkgProperties: + # TODO : check this I do not think it is really usefull ... ==> write for IDE only ... filesString += self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/src/android/UnusedStub.java " - if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0: filesString += self.folder_javaProject + pkgNameApplicationName + "Settings.java " @@ -307,6 +300,23 @@ class Target(target.Target): + self.file_finalAbstraction + " " \ + self.get_staging_folder(pkgName) + "/src/R.java " multiprocess.run_command(cmdLine) + """ + debug.verbose("heritage .so=" + str(tools.filter_extention(heritage.src, ["so"]))) + debug.verbose("heritage .jar=" + str(tools.filter_extention(heritage.src, ["jar"]))) + + class_extern = "" + upper_jar = tools.filter_extention(heritage.src, ["jar"]) + #debug.warning("ploppppp = " + str(upper_jar)) + for elem in upper_jar: + if len(class_extern) > 0: + class_extern += ":" + class_extern += elem + # create enpoint element : + cmdLine = "javac " \ + + "-d " + self.get_staging_folder(pkgName) + "/build/classes " \ + + "-classpath " + class_extern + " " \ + + self.get_staging_folder(pkgName) + "/src/R.java " + multiprocess.run_command(cmdLine) debug.print_element("pkg", ".dex", "<==", "*.class") cmdLine = androidToolPath + "dx " \ @@ -316,6 +326,11 @@ class Target(target.Target): if "ADMOD_ID" in pkgProperties: cmdLine += self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar " + # add element to dexification: + for elem in upper_jar: + # remove android sdk: + if elem[-len("android.jar"):] != "android.jar": + cmdLine += elem + " " multiprocess.run_command(cmdLine) @@ -404,7 +419,7 @@ class Target(target.Target): if self.config["mode"] == "debug": pkgNameApplicationName += "debug" cmdLine = self.folder_sdk + "/platform-tools/adb uninstall " + pkgNameApplicationName - Rmultiprocess.unCommand(cmdLine) + Rmultiprocess.run_command(cmdLine) def Log(self, pkgName): debug.debug("------------------------------------------------------------------------")