[DEV] correct some builder interface

This commit is contained in:
Edouard DUPIN 2015-06-22 23:16:08 +02:00
parent 2bb4e2d377
commit db0c2a8e11
5 changed files with 143 additions and 9 deletions

View File

@ -211,9 +211,11 @@ class Module:
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: if self.type in target.action_on_state:
for action in target.action_on_state[self.type]: for lvl in range(0,100):
elem = action(target, self, package_name); for level, action_name, action in target.action_on_state[self.type]:
if level == lvl:
debug.debug("level=" + str(level) + " Do Action : " + action_name)
elem = action(target, self, package_name);
if self.type != 'PREBUILD': if self.type != 'PREBUILD':
# build local sources in a specific order : # build local sources in a specific order :
@ -602,8 +604,10 @@ class Module:
debug.error("not know pkg element : '" + variable + "'") debug.error("not know pkg element : '" + variable + "'")
def pkg_add(self, variable, value): def pkg_add(self, variable, value):
# TODO : Check values... if variable in self.package_prop:
self.package_prop[variable].append(value) self.package_prop[variable].append(value)
else:
self.package_prop[variable] = [value]
def ext_project_add_module(self, target, projectMng, added_module = []): def ext_project_add_module(self, target, projectMng, added_module = []):
if self.name in added_module: if self.name in added_module:

View File

@ -31,6 +31,7 @@ class System:
self.export_libs_ld=[] self.export_libs_ld=[]
self.export_libs_ld_shared=[] self.export_libs_ld_shared=[]
self.export_src=[] self.export_src=[]
self.action_on_state={}
def append_and_check(self, listout, newElement, order): def append_and_check(self, listout, newElement, order):
for element in listout: for element in listout:
@ -66,6 +67,11 @@ class System:
def add_export_SRC(self, list): def add_export_SRC(self, list):
self.append_to_internalList(self.export_src, list) self.append_to_internalList(self.export_src, list)
def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None):
if name_of_state not in self.action_on_state:
self.action_on_state[name_of_state] = [[level, name, action]]
else:
self.action_on_state[name_of_state].append([level, name, action])
@ -79,7 +85,11 @@ def createModuleFromSystem(target, dict):
myModule.add_export_flag('m', dict["system"].export_flags_m) myModule.add_export_flag('m', dict["system"].export_flags_m)
myModule.add_export_flag('mm', dict["system"].export_flags_mm) myModule.add_export_flag('mm', dict["system"].export_flags_mm)
myModule.add_src_file(dict["system"].export_src) myModule.add_src_file(dict["system"].export_src)
# add the currrent module at the
for elem in dict["system"].action_on_state:
level, name, action = dict["system"].action_on_state[elem]
target.add_action(elem, level, name, action)
return myModule return myModule

View File

@ -432,11 +432,12 @@ class Target:
return [heritage.HeritageList(), False] return [heritage.HeritageList(), False]
debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it") debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it")
def add_action(self, name_of_state="PACKAGE", action=None): def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None):
debug.verbose("add action : " + name)
if name_of_state not in self.action_on_state: if name_of_state not in self.action_on_state:
self.action_on_state[name_of_state] = [action] self.action_on_state[name_of_state] = [[level, name, action]]
else: else:
self.action_on_state[name_of_state].append(action) self.action_on_state[name_of_state].append([level, name, action])
targetList=[] targetList=[]

View File

@ -0,0 +1,115 @@
#!/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="ADMOD: Android SDK ad-mod interface (auto-create interface for admod)\n"
# todo : Check if present ...
self.valid = True
# todo : create a searcher of the presence of the library:
self.add_export_SRC(target.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar")
self.add_action("PACKAGE", 10, "admod-auto-wrapper", tool_generate_main_java_class)
##################################################################
##
## Android specific section
##
##################################################################
def tool_generate_main_java_class(target, module, package_name):
if "ADMOD_ID" not in module.package_prop:
debug.warning("Missing parameter ADMOD_ID wen you resuested dependency of ADMOD")
return
module.package_prop["RIGHT"].append("INTERNET")
module.package_prop["RIGHT"].append("ACCESS_NETWORK_STATE")
module.pkg_add("GENERATE_SECTION__IMPORT", [
"import com.google.android.gms.ads.AdRequest;",
"import com.google.android.gms.ads.AdSize;",
"import com.google.android.gms.ads.AdView;",
"import android.widget.LinearLayout;",
"import android.widget.Button;"
])
module.pkg_add("GENERATE_SECTION__DECLARE", [
"/** The view to show the ad. */",
"private AdView adView;",
"private LinearLayout mLayout = null;"
])
list_create = [
"mLayout = new LinearLayout(this);"
"mLayout.setOrientation(android.widget.LinearLayout.VERTICAL);",
"LinearLayout.LayoutParams paramsWindows = new LinearLayout.LayoutParams(",
" LinearLayout.LayoutParams.FILL_PARENT,",
" LinearLayout.LayoutParams.FILL_PARENT);",
"",
"setContentView(mLayout, paramsWindows);",
"",
"LinearLayout.LayoutParams paramsAdds = new LinearLayout.LayoutParams(",
" LinearLayout.LayoutParams.FILL_PARENT,",
" LinearLayout.LayoutParams.WRAP_CONTENT);",
"paramsAdds.weight = 0;",
"",
"LinearLayout.LayoutParams paramsGLView = new LinearLayout.LayoutParams(",
" LinearLayout.LayoutParams.FILL_PARENT,",
" LinearLayout.LayoutParams.FILL_PARENT);",
"paramsGLView.weight = 1;",
"paramsGLView.height = 0;",
"",
"mLayout.setGravity(android.view.Gravity.TOP);",
"",
"// Create an adds.",
"adView = new AdView(this);",
"adView.setAdSize(AdSize.SMART_BANNER);",
"adView.setAdUnitId(\"" + module.package_prop["ADMOD_ID"] + "\");",
"",
"// Create an ad request. Check logcat output for the hashed device ID to get test ads on a physical device.",
"AdRequest adRequest = new AdRequest.Builder()",
" .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)",
" .build();",
"",
"// Add the AdView to the view hierarchy. The view will have no size until the ad is loaded."]
if "ADMOD_POSITION" in module.package_prop \
and module.package_prop["ADMOD_POSITION"] == "top":
list_create.append("mLayout.addView(adView, paramsAdds);")
list_create.append("mLayout.addView(mGLView, paramsGLView);")
else:
list_create.append("mLayout.addView(mGLView, paramsGLView);")
list_create.append("mLayout.addView(adView, paramsAdds);")
list_create.append("")
list_create.append("// Start loading the ad in the background.")
list_create.append("adView.loadAd(adRequest);")
module.pkg_add("GENERATE_SECTION__ON_CREATE", list_create)
module.pkg_add("GENERATE_SECTION__ON_RESUME", [
"if (adView != null) {",
" adView.resume();",
"}"
])
module.pkg_add("GENERATE_SECTION__ON_PAUSE", [
"if (adView != null) {",
" adView.pause();",
"}"
])
module.pkg_add("GENERATE_SECTION__ON_DESTROY", [
"// Destroy the AdView.",
"if (adView != null) {",
" adView.destroy();",
"}"
])

View File

@ -17,8 +17,12 @@ class System(system.System):
system.System.__init__(self) system.System.__init__(self)
# create some HELP: # create some HELP:
self.help="SDK: Android SDK basic interface java\n" self.help="SDK: Android SDK basic interface java\n"
# TODO : Check if the android sdk android.jar is present ...
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_SRC(target.folder_sdk + "/platforms/android-" + str(target.boardId) + "/android.jar") self.add_export_SRC(target.folder_sdk + "/platforms/android-" + str(target.boardId) + "/android.jar")
self.add_export_flag_LD("-ldl")
self.add_export_flag_LD("-llog")
self.add_export_flag_LD("-landroid")