[DEV] reintegrate Android interfac package builder (bug on DATA)

This commit is contained in:
Edouard DUPIN 2015-09-17 22:07:20 +02:00
parent dc921d651b
commit f1d6ad6ce8
4 changed files with 122 additions and 37 deletions

View File

@ -347,7 +347,16 @@ class Module:
# add at the heritage list : # add at the heritage list :
self.sub_heritage_list.add_heritage_list(inherit_list) self.sub_heritage_list.add_heritage_list(inherit_list)
# do sub library action for automatic generating ... # 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 lvl in range(0,100):
for level, action_name, action in target.action_on_state[self.type]: for level, action_name, action in target.action_on_state[self.type]:
if level == lvl: if level == lvl:
@ -356,21 +365,21 @@ class Module:
# ---------------------------------------------------- # ----------------------------------------------------
# -- Generic library help -- # -- Generic library help --
# ---------------------------------------------------- # ----------------------------------------------------
if self.type=='PREBUILD': if self.type == 'PREBUILD':
debug.print_element("Prebuild", self.name, "", "") debug.print_element("Prebuild", self.name, "", "")
if self.type=='LIBRARY': if self.type == 'LIBRARY':
debug.print_element("Library", self.name, "", "") debug.print_element("Library", self.name, "", "")
if self.type=='LIBRARY_DYNAMIC': if self.type == 'LIBRARY_DYNAMIC':
debug.print_element("Library(dynamic)", self.name, "", "") debug.print_element("Library(dynamic)", self.name, "", "")
if self.type=='LIBRARY_STATIC': if self.type == 'LIBRARY_STATIC':
debug.print_element("Library(static)", self.name, "", "") debug.print_element("Library(static)", self.name, "", "")
if self.type=='BINARY': if self.type == 'BINARY':
debug.print_element("Binary(auto)", self.name, "", "") debug.print_element("Binary(auto)", self.name, "", "")
if self.type=='BINARY_SHARED': if self.type == 'BINARY_SHARED':
debug.print_element("Binary (shared)", self.name, "", "") 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, "", "") debug.print_element("Binary (stand alone)", self.name, "", "")
if self.type=='PACKAGE': if self.type == 'PACKAGE':
debug.print_element("Package", self.name, "", "") debug.print_element("Package", self.name, "", "")
# ---------------------------------------------------- # ----------------------------------------------------
# -- Sources compilation -- # -- Sources compilation --
@ -492,6 +501,9 @@ class Module:
# abstract GUI interface ... # abstract GUI interface ...
shared_mode = True shared_mode = True
break; break;
static_mode = True
if self.type == 'BINARY_SHARED':
static_mode = False
if shared_mode == True: if shared_mode == True:
try: try:
tmp_builder = builder.get_builder_with_output("so"); tmp_builder = builder.get_builder_with_output("so");
@ -501,7 +513,8 @@ class Module:
target, target,
self.sub_heritage_list, self.sub_heritage_list,
name = self.name, name = self.name,
basic_path = self.origin_path) basic_path = self.origin_path,
static = static_mode)
self.local_heritage.add_sources(res_file) self.local_heritage.add_sources(res_file)
except ValueError: except ValueError:
debug.error(" UN-SUPPORTED link format: '.so'") debug.error(" UN-SUPPORTED link format: '.so'")
@ -521,9 +534,6 @@ class Module:
else: else:
try: try:
tmp_builder = builder.get_builder_with_output("bin"); 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, res_file = tmp_builder.link(list_sub_file_needed_to_build,
package_name, package_name,
target, target,

View File

@ -38,14 +38,25 @@ def get_output_type():
## ##
## @brief Commands for running gcc to link a shared library. ## @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") file_src, file_dst, file_depend, file_cmd, file_warning = target.generate_file(binary, name, basic_path, file, "lib-shared")
list_static = []
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 #get all parent dynamic libs
list_dynamic = depancy.src['dynamic'] list_dynamic = depancy.src['dynamic']
# get only parent shared that is not static # get only parent shared that is not static
list_static = []
for elem in depancy.src['static']: for elem in depancy.src['static']:
if elem[:-len(target.suffix_lib_static)] + target.suffix_lib_dynamic not in depancy.src['dynamic']: lib_name = elem[:-len(target.suffix_lib_static)] + target.suffix_lib_dynamic
if lib_name not in depancy.src['dynamic']:
list_static.append(elem) list_static.append(elem)
#create command Line #create command Line
cmd = [ cmd = [

View File

@ -77,11 +77,15 @@ class Target(target.Target):
debug.info("Gcc x86 path does not exist !!!") debug.info("Gcc x86 path does not exist !!!")
# TODO : Set it back in the package only ... # TODO : Set it back in the package only ...
#self.path_bin="/mustNotCreateBinary" #self.path_bin="mustNotCreateBinary"
#self.path_lib="/data/lib/armeabi" #self.path_lib="data/lib/armeabi"
#self.path_data="/data/assets" #self.path_data="data/assets"
#self.path_doc="/doc" #self.path_doc="doc"
#self.suffix_package='.pkg' #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 ...) # board id at 15 is for android 4.0.3 and more ... (note: API 14 has been removed ...)
self.boardId = 15 self.boardId = 15
@ -214,17 +218,77 @@ class Target(target.Target):
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
debug.info("Generate package '" + pkg_name + "'") debug.info("Generate package '" + pkg_name + "'")
debug.debug("------------------------------------------------------------------------") 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 pkg_name_application_name = pkg_name
if self.config["mode"] == "debug": if self.config["mode"] == "debug":
pkg_name_application_name += "debug" pkg_name_application_name += "debug"
# FINAL_path_JAVA_PROJECT # FINAL_path_JAVA_PROJECT
self.path_javaProject= self.get_staging_path(pkg_name) \ self.path_java_project = os.path.join(self.get_staging_path(pkg_name),
+ "/src/" \ "src",
+ pkg_properties["COMPAGNY_TYPE"] \ pkg_properties["COMPAGNY_TYPE"],
+ "/" + pkg_properties["COMPAGNY_NAME2"] \ pkg_properties["COMPAGNY_NAME2"],
+ "/" + pkg_name_application_name + "/" pkg_name_application_name)
#FINAL_FILE_ABSTRACTION #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 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") debug.print_element("pkg", "absractionFile", "<==", "dynamic file")
# Create path : # Create path :
tools.create_directory_of_file(self.file_finalAbstraction) tools.create_directory_of_file(self.file_final_abstraction)
# Create file : # Create file :
# java ==> done by ewol wrapper ... (and compiled in the normal compilation system ==> must be find in the dependency list of jar ... # 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 ... # 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 " 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: 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 = "" adModJarFile = ""
if "ADMOD_ID" in pkg_properties: 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" \ + "-classpath " + self.path_sdk + "/platforms/android-" + str(self.boardId) + "/android.jar" \
+ adModJarFile + " " \ + adModJarFile + " " \
+ filesString \ + filesString \
+ self.file_finalAbstraction + " " \ + self.file_final_abstraction + " " \
+ self.get_staging_path(pkg_name) + "/src/R.java " + self.get_staging_path(pkg_name) + "/src/R.java "
multiprocess.run_command(cmdLine) multiprocess.run_command(cmdLine)
""" """
debug.verbose("heritage .so=" + str(tools.filter_extention(heritage_list.src, ["so"]))) debug.verbose("heritage .so=" + str(tools.filter_extention(heritage_list.src['dynamic'], ["so"])))
debug.verbose("heritage .jar=" + str(tools.filter_extention(heritage_list.src, ["jar"]))) debug.verbose("heritage .jar=" + str(tools.filter_extention(heritage_list.src['src'], ["jar"])))
class_extern = "" 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)) #debug.warning("ploppppp = " + str(upper_jar))
for elem in upper_jar: for elem in upper_jar:
if len(class_extern) > 0: if len(class_extern) > 0:

View File

@ -118,7 +118,7 @@ class Target(target.Target):
target_outpath_data = os.path.join(target_outpath, self.pkg_path_data) target_outpath_data = os.path.join(target_outpath, self.pkg_path_data)
tools.create_directory_of_file(target_outpath_data) tools.create_directory_of_file(target_outpath_data)
debug.debug("heritage for " + str(pkg_name) + ":") 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)) debug.debug("sub elements: " + str(heritage.name))
path_src = self.get_build_path_data(heritage.name) path_src = self.get_build_path_data(heritage.name)
debug.verbose(" has directory: " + path_src) debug.verbose(" has directory: " + path_src)