[DEV] continue re-integration of android
This commit is contained in:
parent
c73a7a0df6
commit
a4ddf8e81b
@ -81,7 +81,8 @@ def print_pretty(myString, force=False):
|
||||
]
|
||||
elif end_with(cmdApplication, ["jar"]) == True:
|
||||
baseElementList = [
|
||||
"cf"
|
||||
"cf",
|
||||
"-C"
|
||||
]
|
||||
for element in baseElementList:
|
||||
tmpcmdLine = tmpcmdLine.replace(element+'\n\t', element+' ')
|
||||
|
@ -53,21 +53,7 @@ class Module:
|
||||
self.flags = {"export":{},
|
||||
"local":{}
|
||||
}
|
||||
"""
|
||||
self.export_flags_ld = []
|
||||
self.export_flags_cc = []
|
||||
self.export_flags_xx = []
|
||||
self.export_flags_m = []
|
||||
self.export_flags_mm = []
|
||||
# list of all flags:
|
||||
self.flags_ld = []
|
||||
self.flags_cc = []
|
||||
self.flags_xx = []
|
||||
self.flags_m = []
|
||||
self.flags_mm = []
|
||||
self.flags_s = []
|
||||
self.flags_ar = []
|
||||
"""
|
||||
self.extention_order_build = ["java", "javah"] # all is not set here is done in the provided order ...
|
||||
# sources list:
|
||||
self.src = []
|
||||
# copy files and folders:
|
||||
@ -203,7 +189,6 @@ class Module:
|
||||
else :
|
||||
# TODO : Set it better ...
|
||||
None
|
||||
|
||||
# build dependency before
|
||||
list_sub_file_needed_to_build = []
|
||||
self.sub_heritage_list = heritage.HeritageList()
|
||||
@ -224,9 +209,17 @@ class Module:
|
||||
inherit_list = target.build(dep, package_name)
|
||||
# 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:
|
||||
for action in target.action_on_state[self.type]:
|
||||
elem = action(target, self, package_name);
|
||||
|
||||
# build local sources
|
||||
for file in self.src:
|
||||
|
||||
|
||||
# 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:
|
||||
@ -239,7 +232,35 @@ class Module:
|
||||
path = self.path,
|
||||
name = self.name,
|
||||
basic_folder = self.origin_folder)
|
||||
list_sub_file_needed_to_build.append(resFile)
|
||||
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]
|
||||
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 ...
|
||||
@ -274,7 +295,7 @@ class Module:
|
||||
basic_folder = self.origin_folder)
|
||||
self.local_heritage.add_sources(resFile)
|
||||
except ValueError:
|
||||
debug.error(" UN-SUPPORTED link format: '.jat'")
|
||||
debug.error(" UN-SUPPORTED link format: '.jar'")
|
||||
elif self.type=='BINARY':
|
||||
try:
|
||||
tmp_builder = builder.get_builder_with_output("bin");
|
||||
@ -296,15 +317,27 @@ class Module:
|
||||
try:
|
||||
tmp_builder = builder.get_builder_with_output("so");
|
||||
list_file = tools.filter_extention(list_sub_file_needed_to_build, tmp_builder.get_input_type())
|
||||
debug.info("plopppp " + str(list_file))
|
||||
resFile = tmp_builder.link(list_file,
|
||||
package_name,
|
||||
target,
|
||||
self.sub_heritage_list,
|
||||
name = "libewol",
|
||||
name = "lib" + self.name,
|
||||
basic_folder = self.origin_folder)
|
||||
except ValueError:
|
||||
debug.error(" UN-SUPPORTED link format: '.so'")
|
||||
try:
|
||||
tmp_builder = builder.get_builder_with_output("jar");
|
||||
list_file = tools.filter_extention(list_sub_file_needed_to_build, tmp_builder.get_input_type())
|
||||
if len(list_file) > 0:
|
||||
resFile = tmp_builder.link(list_file,
|
||||
package_name,
|
||||
target,
|
||||
self.sub_heritage_list,
|
||||
name = self.name,
|
||||
basic_folder = self.origin_folder)
|
||||
self.local_heritage.add_sources(resFile)
|
||||
except ValueError:
|
||||
debug.error(" UN-SUPPORTED link format: '.jar'")
|
||||
else:
|
||||
try:
|
||||
tmp_builder = builder.get_builder_with_output("bin");
|
||||
|
@ -82,6 +82,7 @@ class Target:
|
||||
self.suffix_binary=''
|
||||
self.suffix_package='.deb'
|
||||
|
||||
self.folder_generate_code="/generate_header"
|
||||
self.folder_arch="/" + self.name
|
||||
|
||||
if "debug" == self.config["mode"]:
|
||||
@ -112,6 +113,8 @@ class Target:
|
||||
|
||||
self.sysroot=""
|
||||
|
||||
self.action_on_state={}
|
||||
|
||||
def update_folder_tree(self):
|
||||
self.folder_out="/out/" + self.name + "_" + self.config["arch"] + "_" + self.config["bus-size"] + "/" + self.config["mode"]
|
||||
self.folder_final="/final/" + self.config["compilator"]
|
||||
@ -210,9 +213,15 @@ class Target:
|
||||
|
||||
|
||||
def get_full_name_source(self, basePath, file):
|
||||
if file[0] == '/':
|
||||
if tools.os.path.isfile(file):
|
||||
return file
|
||||
return basePath + "/" + file
|
||||
|
||||
def get_full_name_cmd(self, moduleName, basePath, file):
|
||||
if file[0] == '/':
|
||||
if tools.os.path.isfile(file):
|
||||
return file + self.suffix_cmdLine
|
||||
return self.get_build_folder(moduleName) + "/" + file + self.suffix_cmdLine
|
||||
|
||||
def get_full_name_destination(self, moduleName, basePath, file, suffix, remove_suffix=False):
|
||||
@ -302,6 +311,12 @@ class Target:
|
||||
debug.debug("Add nodule for Taget : " + newModule.name)
|
||||
self.moduleList.append(newModule)
|
||||
|
||||
def get_module(self, name):
|
||||
for mod in self.buildDone:
|
||||
if mod.name == name:
|
||||
return mod
|
||||
debug.error("the module '" + str(name) + "'does not exist/already build")
|
||||
return None
|
||||
|
||||
# return inherit packages ...
|
||||
"""
|
||||
@ -426,6 +441,12 @@ class Target:
|
||||
return mod.build(self, None)
|
||||
debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it")
|
||||
|
||||
def add_action(self, name_of_state="PACKAGE", action=None):
|
||||
if name_of_state not in self.action_on_state:
|
||||
self.action_on_state[name_of_state] = [action]
|
||||
else:
|
||||
self.action_on_state[name_of_state].append(action)
|
||||
|
||||
|
||||
targetList=[]
|
||||
__startTargetName="lutinTarget_"
|
||||
|
@ -146,13 +146,35 @@ def copy_anything_target(target, src, dst):
|
||||
target.add_file_staging(root+"/"+cycleFile, newDst+cycleFile)
|
||||
|
||||
|
||||
def filter_extention(list_files, extentions):
|
||||
def filter_extention(list_files, extentions, invert=False):
|
||||
out = []
|
||||
for ext in extentions:
|
||||
for file in list_files:
|
||||
in_list = False
|
||||
for ext in extentions:
|
||||
if file[-len(ext):] == ext:
|
||||
in_list = True
|
||||
if in_list == True \
|
||||
and invert == False:
|
||||
out.append(file)
|
||||
elif in_list == False \
|
||||
and invert == True:
|
||||
out.append(file)
|
||||
return out
|
||||
|
||||
|
||||
def move_if_needed(src, dst):
|
||||
if not os.path.isfile(src):
|
||||
debug.error("request move if needed, but file does not exist: '" + str(src) + "' to '" + str(dst) + "'")
|
||||
return
|
||||
src_data = file_read_data(src)
|
||||
if os.path.isfile(dst):
|
||||
# file exist ==> must check ...
|
||||
dst_data = file_read_data(dst)
|
||||
if src_data == dst_data:
|
||||
# nothing to do ...
|
||||
return
|
||||
file_write_data(dst, src_data)
|
||||
remove_file(src)
|
||||
|
||||
|
||||
|
||||
|
@ -87,12 +87,12 @@ def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["c", name, "<==", file]
|
||||
# process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
||||
|
||||
def get_version_compilation_flags(flags, dependency_flags):
|
||||
|
@ -94,12 +94,12 @@ def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["c++", name, "<==", file]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
||||
def get_version_compilation_flags(flags, dependency_flags):
|
||||
try:
|
||||
|
@ -43,12 +43,18 @@ def link(file, binary, target, depancy, name, basic_folder):
|
||||
#create command Line
|
||||
cmd = [
|
||||
target.jar,
|
||||
"cf", file_dst
|
||||
"cf", file_dst,
|
||||
]
|
||||
try:
|
||||
cmd.append(file_src)
|
||||
except:
|
||||
pass
|
||||
for file in file_src:
|
||||
path = ""
|
||||
for elem in ["org/", "com/"]:
|
||||
pos = file.find(elem);
|
||||
if pos > 0:
|
||||
path = file[:pos]
|
||||
file = file[pos:]
|
||||
cmd.append("-C")
|
||||
cmd.append(path)
|
||||
cmd.append(file)
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
"""
|
||||
# check the dependency for this file :
|
||||
|
@ -65,19 +65,31 @@ 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"]
|
||||
upper_jar = tools.filter_extention(depancy.src, ["jar"])
|
||||
#debug.warning("ploppppp = " + str(upper_jar))
|
||||
for elem in upper_jar:
|
||||
class_extern.append(elem)
|
||||
if len(class_extern) > 0:
|
||||
cmd.append("-classpath")
|
||||
out = ""
|
||||
for elem in class_extern:
|
||||
if len(out) > 0:
|
||||
out += ":"
|
||||
out += elem
|
||||
cmd.append(out)
|
||||
|
||||
# dependency : + "-classpath " + self.folder_sdk + "/platforms/android-" + str(self.boardId) + "/android.jar" \
|
||||
cmd.append("-classpath " + target.folder_sdk + "/platforms/android-" + str(target.boardId) + "/android.jar")
|
||||
cmd.append(file_src)
|
||||
# Create cmd line
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
|
||||
# check the dependency for this file :
|
||||
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["java", name, "<==", file]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
||||
|
@ -46,26 +46,28 @@ def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||
# create the command line befor requesting start:
|
||||
cmd = [
|
||||
target.javah,
|
||||
"-d", target.get_build_folder(name) + "/tmp_header"
|
||||
"-d", target.get_build_folder(name) + target.folder_generate_code
|
||||
]
|
||||
|
||||
if debug.get_level() >= 4:
|
||||
if debug.get_level() >= 5:
|
||||
cmd.append("-verbose")
|
||||
|
||||
cmd.append("-classpath")
|
||||
cmd.append(target.get_build_folder(name))
|
||||
file = file[:-5]
|
||||
cmd.append(file)
|
||||
class_to_build = file[:-6]
|
||||
cmd.append(class_to_build)
|
||||
# Create cmd line
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
|
||||
file_dst = target.get_build_folder(name) + "/tmp_header/" + class_to_build.replace(".", "_") + ".h"
|
||||
# check the dependency for this file :
|
||||
#if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||
# return file_dst
|
||||
#tools.create_directory_of_file(file_dst)
|
||||
comment = ["javah", name, "<==", file]
|
||||
comment = ["javah", class_to_build.replace(".", "_") + ".h", "<==", class_to_build]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
debug.verbose("file= " + file_dst)
|
||||
#return file_dst
|
||||
return None
|
||||
return {"action":"path", "path":target.get_build_folder(name) + target.folder_generate_code}
|
||||
|
||||
|
@ -94,10 +94,10 @@ def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if False==depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["m", name, "<==", file]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
||||
|
@ -94,9 +94,9 @@ def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||
cmdLine=tools.list_to_str(cmd)
|
||||
# check the dependency for this file :
|
||||
if False==depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
tools.create_directory_of_file(file_dst)
|
||||
comment = ["m++", name, "<==", file]
|
||||
#process element
|
||||
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||
return file_dst
|
||||
return {"action":"add", "file":file_dst}
|
||||
|
@ -220,115 +220,7 @@ class Target(target.Target):
|
||||
# Create folder :
|
||||
tools.create_directory_of_file(self.file_finalAbstraction)
|
||||
# Create file :
|
||||
tmpFile = open(self.file_finalAbstraction, 'w')
|
||||
if pkgProperties["ANDROID_APPL_TYPE"]=="APPL":
|
||||
tmpFile.write( "/**\n")
|
||||
tmpFile.write( " * @author Edouard DUPIN, Kevin BILLONNEAU\n")
|
||||
tmpFile.write( " * @copyright 2011, Edouard DUPIN, all right reserved\n")
|
||||
tmpFile.write( " * @license APACHE v2.0 (see license file)\n")
|
||||
tmpFile.write( " * @note This file is autogenerate ==> see documantation to generate your own\n")
|
||||
tmpFile.write( " */\n")
|
||||
tmpFile.write( "package "+ compleatePackageName + ";\n")
|
||||
tmpFile.write( "import org.ewol.EwolActivity;\n")
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( "import com.google.android.gms.ads.AdRequest;\n")
|
||||
tmpFile.write( "import com.google.android.gms.ads.AdSize;\n")
|
||||
tmpFile.write( "import com.google.android.gms.ads.AdView;\n")
|
||||
tmpFile.write( "import android.widget.LinearLayout;\n")
|
||||
tmpFile.write( "import android.widget.Button;\n")
|
||||
tmpFile.write( "public class " + pkgNameApplicationName + " extends EwolActivity {\n")
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( " /** The view to show the ad. */\n")
|
||||
tmpFile.write( " private AdView adView;\n")
|
||||
tmpFile.write( " private LinearLayout mLayout = null;\n")
|
||||
tmpFile.write( " public void onCreate(android.os.Bundle savedInstanceState) {\n")
|
||||
tmpFile.write( " super.onCreate(savedInstanceState);\n")
|
||||
tmpFile.write( " initApkPath(\"" + pkgProperties["COMPAGNY_TYPE"]+"\", \""+pkgProperties["COMPAGNY_NAME2"]+"\", \"" + pkgNameApplicationName + "\");\n")
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( " mLayout = new LinearLayout(this);\n")
|
||||
tmpFile.write( " mLayout.setOrientation(android.widget.LinearLayout.VERTICAL);\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams paramsWindows = new LinearLayout.LayoutParams(\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT);\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " setContentView(mLayout, paramsWindows);\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams paramsAdds = new LinearLayout.LayoutParams(\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.WRAP_CONTENT);\n")
|
||||
tmpFile.write( " paramsAdds.weight = 0;\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams paramsGLView = new LinearLayout.LayoutParams(\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT,\n")
|
||||
tmpFile.write( " LinearLayout.LayoutParams.FILL_PARENT);\n")
|
||||
tmpFile.write( " paramsGLView.weight = 1;\n")
|
||||
tmpFile.write( " paramsGLView.height = 0;\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " mLayout.setGravity(android.view.Gravity.TOP);\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " // Create an adds.\n")
|
||||
tmpFile.write( " adView = new AdView(this);\n")
|
||||
tmpFile.write( " adView.setAdSize(AdSize.SMART_BANNER);\n")
|
||||
tmpFile.write( " adView.setAdUnitId(\"" + pkgProperties["ADMOD_ID"] + "\");\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " // Create an ad request. Check logcat output for the hashed device ID to get test ads on a physical device.\n")
|
||||
tmpFile.write( " AdRequest adRequest = new AdRequest.Builder()\n")
|
||||
tmpFile.write( " .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)\n")
|
||||
tmpFile.write( " .build();\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " // Add the AdView to the view hierarchy. The view will have no size until the ad is loaded.\n")
|
||||
if "ADMOD_POSITION" in pkgProperties.keys() \
|
||||
and pkgProperties["ADMOD_POSITION"] == "top":
|
||||
tmpFile.write( " mLayout.addView(adView, paramsAdds);\n")
|
||||
tmpFile.write( " mLayout.addView(mGLView, paramsGLView);\n")
|
||||
else:
|
||||
tmpFile.write( " mLayout.addView(mGLView, paramsGLView);\n")
|
||||
tmpFile.write( " mLayout.addView(adView, paramsAdds);\n")
|
||||
tmpFile.write( " \n")
|
||||
tmpFile.write( " // Start loading the ad in the background.\n")
|
||||
tmpFile.write( " adView.loadAd(adRequest);\n")
|
||||
tmpFile.write( " }\n")
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( " @Override protected void onResume() {\n")
|
||||
tmpFile.write( " super.onResume();\n")
|
||||
tmpFile.write( " if (adView != null) {\n")
|
||||
tmpFile.write( " adView.resume();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " @Override protected void onPause() {\n")
|
||||
tmpFile.write( " if (adView != null) {\n")
|
||||
tmpFile.write( " adView.pause();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " super.onPause();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " @Override protected void onDestroy() {\n")
|
||||
tmpFile.write( " // Destroy the AdView.\n")
|
||||
tmpFile.write( " if (adView != null) {\n")
|
||||
tmpFile.write( " adView.destroy();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " super.onDestroy();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( "}\n")
|
||||
else :
|
||||
# wallpaper mode ...
|
||||
tmpFile.write( "/**\n")
|
||||
tmpFile.write( " * @author Edouard DUPIN, Kevin BILLONNEAU\n")
|
||||
tmpFile.write( " * @copyright 2011, Edouard DUPIN, all right reserved\n")
|
||||
tmpFile.write( " * @license APACHE v2.0 (see license file)\n")
|
||||
tmpFile.write( " * @note This file is autogenerate ==> see documantation to generate your own\n")
|
||||
tmpFile.write( " */\n")
|
||||
tmpFile.write( "package "+ compleatePackageName + ";\n")
|
||||
tmpFile.write( "import org.ewol.EwolWallpaper;\n")
|
||||
tmpFile.write( "public class " + pkgNameApplicationName + " extends EwolWallpaper {\n")
|
||||
tmpFile.write( " public static final String SHARED_PREFS_NAME = \"" + pkgNameApplicationName + "settings\";\n")
|
||||
tmpFile.write( " public Engine onCreateEngine() {\n")
|
||||
tmpFile.write( " Engine tmpEngine = super.onCreateEngine();\n")
|
||||
tmpFile.write( " initApkPath(\"" + pkgProperties["COMPAGNY_TYPE"]+"\", \""+pkgProperties["COMPAGNY_NAME2"]+"\", \"" + pkgNameApplicationName + "\");\n")
|
||||
tmpFile.write( " return tmpEngine;\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( "}\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
# java ==> done by ewol wrapper ... (and compiled in the normal compilation system ==> must be find in the dependency list of jar ...
|
||||
|
||||
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/drawable/icon.png");
|
||||
if "ICON" in pkgProperties.keys() \
|
||||
@ -345,222 +237,7 @@ class Target(target.Target):
|
||||
debug.print_element("pkg", "AndroidManifest.xml", "<==", pkgProperties["ANDROID_MANIFEST"])
|
||||
tools.copy_file(pkgProperties["ANDROID_MANIFEST"], self.get_staging_folder(pkgName) + "/AndroidManifest.xml", force=True)
|
||||
else:
|
||||
if "VERSION_CODE" not in pkgProperties:
|
||||
pkgProperties["VERSION_CODE"] = "1"
|
||||
debug.print_element("pkg", "AndroidManifest.xml", "<==", "package configurations")
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/AndroidManifest.xml", 'w')
|
||||
tmpFile.write( '<?xml version="1.0" encoding="utf-8"?>\n')
|
||||
tmpFile.write( '<!-- Manifest is autoGenerated with Ewol ... do not patch it-->\n')
|
||||
tmpFile.write( '<manifest xmlns:android="http://schemas.android.com/apk/res/android" \n')
|
||||
tmpFile.write( ' package="' + compleatePackageName + '" \n')
|
||||
tmpFile.write( ' android:versionCode="'+pkgProperties["VERSION_CODE"]+'" \n')
|
||||
tmpFile.write( ' android:versionName="'+pkgProperties["VERSION"]+'"> \n')
|
||||
tmpFile.write( ' <uses-feature android:glEsVersion="0x00020000" android:required="true" />\n')
|
||||
tmpFile.write( ' <uses-sdk android:minSdkVersion="' + str(self.boardId) + '" \n')
|
||||
tmpFile.write( ' android:targetSdkVersion="' + str(self.boardId) + '" /> \n')
|
||||
if pkgProperties["ANDROID_APPL_TYPE"]=="APPL":
|
||||
tmpFile.write( ' <application android:label="' + pkgNameApplicationName + '" \n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon" \n')
|
||||
if self.config["mode"] == "debug":
|
||||
tmpFile.write( ' android:debuggable="true" \n')
|
||||
tmpFile.write( ' >\n')
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( ' <meta-data android:name="com.google.android.gms.version" \n')
|
||||
tmpFile.write( ' android:value="@integer/google_play_services_version"/>\n')
|
||||
|
||||
tmpFile.write( ' <activity android:name=".' + pkgNameApplicationName + '" \n')
|
||||
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
|
||||
if self.config["mode"] == "debug":
|
||||
tmpFile.write("-debug")
|
||||
tmpFile.write( '"\n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon" \n')
|
||||
tmpFile.write( ' android:hardwareAccelerated="true" \n')
|
||||
tmpFile.write( ' android:configChanges="keyboard|keyboardHidden|orientation|screenSize"> \n')
|
||||
tmpFile.write( ' <intent-filter> \n')
|
||||
tmpFile.write( ' <action android:name="android.intent.action.MAIN" /> \n')
|
||||
tmpFile.write( ' <category android:name="android.intent.category.LAUNCHER" /> \n')
|
||||
tmpFile.write( ' </intent-filter> \n')
|
||||
tmpFile.write( ' </activity> \n')
|
||||
if "ADMOD_ID" in pkgProperties:
|
||||
tmpFile.write( ' <activity android:name="com.google.android.gms.ads.AdActivity"\n')
|
||||
tmpFile.write( ' android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>\n')
|
||||
|
||||
tmpFile.write( ' </application>\n')
|
||||
else:
|
||||
tmpFile.write( ' <application android:label="' + pkgNameApplicationName + '" \n')
|
||||
tmpFile.write( ' android:permission="android.permission.BIND_WALLPAPER" \n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon"\n')
|
||||
tmpFile.write( ' >\n')
|
||||
tmpFile.write( ' <service android:name=".' + pkgNameApplicationName + '" \n')
|
||||
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
|
||||
if self.config["mode"] == "debug":
|
||||
tmpFile.write("-debug")
|
||||
tmpFile.write( '"\n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon"\n')
|
||||
tmpFile.write( ' >\n')
|
||||
tmpFile.write( ' <intent-filter>\n')
|
||||
tmpFile.write( ' <action android:name="android.service.wallpaper.WallpaperService" />\n')
|
||||
tmpFile.write( ' </intent-filter>\n')
|
||||
tmpFile.write( ' <meta-data android:name="android.service.wallpaper"\n')
|
||||
tmpFile.write( ' android:resource="@xml/' + pkgNameApplicationName + '_resource" />\n')
|
||||
tmpFile.write( ' </service>\n')
|
||||
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||
tmpFile.write( ' <activity android:label="Setting"\n')
|
||||
tmpFile.write( ' android:name=".' + pkgNameApplicationName + 'Settings"\n')
|
||||
tmpFile.write( ' android:theme="@android:style/Theme.Light.WallpaperSettings"\n')
|
||||
tmpFile.write( ' android:exported="true"\n')
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( ' android:icon="@drawable/icon"\n')
|
||||
tmpFile.write( ' >\n')
|
||||
tmpFile.write( ' </activity>\n')
|
||||
tmpFile.write( ' </application>\n')
|
||||
# write package autorisations :
|
||||
if True==self.check_right_package(pkgProperties, "WRITE_EXTERNAL_STORAGE"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "CAMERA"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.CAMERA" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.CAMERA" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "INTERNET"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.INTERNET" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.INTERNET" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "ACCESS_NETWORK_STATE"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.ACCESS_NETWORK_STATE" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "MODIFY_AUDIO_SETTINGS"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "READ_CALENDAR"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.READ_CALENDAR" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.READ_CALENDAR" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "READ_CONTACTS"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.READ_CONTACTS" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.READ_CONTACTS" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "READ_FRAME_BUFFER"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.READ_FRAME_BUFFER" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "READ_PROFILE"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.READ_PROFILE" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.READ_PROFILE" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "RECORD_AUDIO"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.RECORD_AUDIO" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.RECORD_AUDIO" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "SET_ORIENTATION"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.SET_ORIENTATION" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.SET_ORIENTATION" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "VIBRATE"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.VIBRATE" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.VIBRATE" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "ACCESS_COARSE_LOCATION"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> \n')
|
||||
if True==self.check_right_package(pkgProperties, "ACCESS_FINE_LOCATION"):
|
||||
tmpFile.write( ' <permission android:name="android.permission.ACCESS_FINE_LOCATION" /> \n')
|
||||
tmpFile.write( ' <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> \n')
|
||||
tmpFile.write( '</manifest>\n\n')
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
# end generating android manifest
|
||||
|
||||
if pkgProperties["ANDROID_APPL_TYPE"]!="APPL":
|
||||
#create the Wallpaper sub files : (main element for the application
|
||||
debug.print_element("pkg", pkgNameApplicationName + "_resource.xml", "<==", "package configurations")
|
||||
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_resource.xml")
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_resource.xml", 'w')
|
||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||
tmpFile.write( "<wallpaper xmlns:android=\"http://schemas.android.com/apk/res/android\"\n")
|
||||
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||
tmpFile.write( " android:settingsActivity=\""+compleatePackageName + "."+ pkgNameApplicationName + "Settings\"\n")
|
||||
if "ICON" in pkgProperties.keys():
|
||||
tmpFile.write( " android:thumbnail=\"@drawable/icon\"\n")
|
||||
tmpFile.write( " />\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
# create wallpaper setting if needed (class and config file)
|
||||
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||
tools.create_directory_of_file(self.folder_javaProject + pkgNameApplicationName + "Settings.java")
|
||||
debug.print_element("pkg", self.folder_javaProject + pkgNameApplicationName + "Settings.java", "<==", "package configurations")
|
||||
tmpFile = open(self.folder_javaProject + pkgNameApplicationName + "Settings.java", 'w');
|
||||
tmpFile.write( "package " + compleatePackageName + ";\n")
|
||||
tmpFile.write( "\n")
|
||||
tmpFile.write( "import " + compleatePackageName + ".R;\n")
|
||||
tmpFile.write( "\n")
|
||||
tmpFile.write( "import android.content.SharedPreferences;\n")
|
||||
tmpFile.write( "import android.os.Bundle;\n")
|
||||
tmpFile.write( "import android.preference.PreferenceActivity;\n")
|
||||
tmpFile.write( "\n")
|
||||
tmpFile.write( "public class " + pkgNameApplicationName + "Settings extends PreferenceActivity implements SharedPreferences.OnSharedPreferenceChangeListener\n")
|
||||
tmpFile.write( "{\n")
|
||||
tmpFile.write( " @Override protected void onCreate(Bundle icicle) {\n")
|
||||
tmpFile.write( " super.onCreate(icicle);\n")
|
||||
tmpFile.write( " getPreferenceManager().setSharedPreferencesName("+ pkgNameApplicationName + ".SHARED_PREFS_NAME);\n")
|
||||
tmpFile.write( " addPreferencesFromResource(R.xml."+ pkgNameApplicationName + "_settings);\n")
|
||||
tmpFile.write( " getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " @Override protected void onResume() {\n")
|
||||
tmpFile.write( " super.onResume();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " @Override protected void onDestroy() {\n")
|
||||
tmpFile.write( " getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);\n")
|
||||
tmpFile.write( " super.onDestroy();\n")
|
||||
tmpFile.write( " }\n")
|
||||
tmpFile.write( " public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,String key) { }\n")
|
||||
tmpFile.write( "}\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
debug.print_element("pkg", self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml", "<==", "package configurations")
|
||||
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml")
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml", 'w');
|
||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||
tmpFile.write( "<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\"\n")
|
||||
tmpFile.write( " android:title=\"Settings\"\n")
|
||||
tmpFile.write( " android:key=\"" + pkgNameApplicationName + "_settings\">\n")
|
||||
WALL_haveArray = False
|
||||
for WALL_type, WALL_key, WALL_title, WALL_summary, WALL_other in pkgProperties["ANDROID_WALLPAPER_PROPERTIES"]:
|
||||
debug.info("find : '" + WALL_type + "'");
|
||||
if WALL_type == "list":
|
||||
debug.info(" create : LIST");
|
||||
tmpFile.write( " <ListPreference android:key=\"" + pkgNameApplicationName + "_" + WALL_key + "\"\n")
|
||||
tmpFile.write( " android:title=\"" + WALL_title + "\"\n")
|
||||
tmpFile.write( " android:summary=\"" + WALL_summary + "\"\n")
|
||||
tmpFile.write( " android:entries=\"@array/" + pkgNameApplicationName + "_" + WALL_key + "_names\"\n")
|
||||
tmpFile.write( " android:entryValues=\"@array/" + pkgNameApplicationName + "_" + WALL_key + "_prefix\"/>\n")
|
||||
WALL_haveArray=True
|
||||
elif WALL_type == "bool":
|
||||
debug.info(" create : CHECKBOX");
|
||||
tmpFile.write( " <CheckBoxPreference android:key=\"" + pkgNameApplicationName + "_" + WALL_key + "\"\n")
|
||||
tmpFile.write( " android:title=\"" + WALL_title + "\"\n")
|
||||
tmpFile.write( " android:summary=\"" + WALL_summary + "\"\n")
|
||||
tmpFile.write( " android:summaryOn=\"" + WALL_other[0] + "\"\n")
|
||||
tmpFile.write( " android:summaryOff=\"" + WALL_other[1] + "\"/>\n")
|
||||
tmpFile.write( "</PreferenceScreen>\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
if WALL_haveArray==True:
|
||||
for WALL_type, WALL_key, WALL_title, WALL_summary, WALL_other in pkgProperties["ANDROID_WALLPAPER_PROPERTIES"]:
|
||||
if WALL_type == "list":
|
||||
debug.print_element("pkg", self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml", "<==", "package configurations")
|
||||
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml")
|
||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml", 'w');
|
||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||
tmpFile.write( "<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n")
|
||||
tmpFile.write( " <string-array name=\"" + pkgNameApplicationName + "_" + WALL_key + "_names\">\n")
|
||||
for WALL_subKey, WALL_display in WALL_other:
|
||||
tmpFile.write( " <item>" + WALL_display + "</item>\n")
|
||||
tmpFile.write( " </string-array>\n")
|
||||
tmpFile.write( " <string-array name=\"" + pkgNameApplicationName + "_" + WALL_key + "_prefix\">\n")
|
||||
for WALL_subKey, WALL_display in WALL_other:
|
||||
tmpFile.write( " <item>" + WALL_subKey + "</item>\n")
|
||||
tmpFile.write( " </string-array>\n")
|
||||
tmpFile.write( "</resources>\n")
|
||||
tmpFile.flush()
|
||||
tmpFile.close()
|
||||
|
||||
debug.error("missing parameter 'ANDROID_MANIFEST' in the properties ... ")
|
||||
|
||||
#add properties on wallpaper :
|
||||
# myModule.pkg_add("ANDROID_WALLPAPER_PROPERTIES", ["list", key, title, summary, [["key","value display"],["key2","value display 2"]])
|
||||
@ -608,14 +285,7 @@ class Target(target.Target):
|
||||
filesString=""
|
||||
for element in pkgProperties["ANDROID_JAVA_FILES"]:
|
||||
if element=="DEFAULT":
|
||||
filesString += self.folder_ewol + "/android/src/org/ewol/EwolAudioTask.java "
|
||||
filesString += self.folder_ewol + "/android/src/org/ewol/EwolCallback.java "
|
||||
filesString += self.folder_ewol + "/android/src/org/ewol/EwolConstants.java "
|
||||
filesString += self.folder_ewol + "/android/src/org/ewol/Ewol.java "
|
||||
filesString += self.folder_ewol + "/android/src/org/ewol/EwolRendererGL.java "
|
||||
filesString += self.folder_ewol + "/android/src/org/ewol/EwolSurfaceViewGL.java "
|
||||
filesString += self.folder_ewol + "/android/src/org/ewol/EwolActivity.java "
|
||||
filesString += self.folder_ewol + "/android/src/org/ewol/EwolWallpaper.java "
|
||||
# this is deprecated ...
|
||||
else:
|
||||
filesString += element + " "
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user