[DEV] Update lutin API (try stabilize)

This commit is contained in:
Edouard DUPIN 2015-10-14 21:39:43 +02:00
parent 4b091e964a
commit 14fcfc1d54
10 changed files with 347 additions and 128 deletions

View File

@ -19,12 +19,13 @@ import lutin.env as env
import lutin.multiprocess as multiprocess import lutin.multiprocess as multiprocess
myArgs = arguments.LutinArg() myArgs = arguments.LutinArg()
myArgs.add(arguments.ArgDefine("h", "help", desc="display this help")) myArgs.add(arguments.ArgDefine("h", "help", desc="Display this help"))
myArgs.add(arguments.ArgDefine("H", "HELP", desc="Display this help (with all compleate information)"))
myArgs.add_section("option", "Can be set one time in all case") myArgs.add_section("option", "Can be set one time in all case")
myArgs.add(arguments.ArgDefine("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"],["6","extreme_verbose"]], desc="display makefile debug level (verbose) default =2")) myArgs.add(arguments.ArgDefine("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"],["6","extreme_verbose"]], desc="display makefile debug level (verbose) default =2"))
myArgs.add(arguments.ArgDefine("C", "color", desc="display makefile output in color")) myArgs.add(arguments.ArgDefine("C", "color", desc="Display makefile output in color"))
myArgs.add(arguments.ArgDefine("B", "force-build", desc="Force the rebuild without checking the dependency")) myArgs.add(arguments.ArgDefine("B", "force-build", desc="Force the rebuild without checking the dependency"))
myArgs.add(arguments.ArgDefine("P", "pretty", desc="print the debug has pretty display")) myArgs.add(arguments.ArgDefine("P", "pretty", desc="Print the debug has pretty display"))
myArgs.add(arguments.ArgDefine("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously")) myArgs.add(arguments.ArgDefine("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously"))
myArgs.add(arguments.ArgDefine("s", "force-strip", desc="Force the stripping of the compile elements")) myArgs.add(arguments.ArgDefine("s", "force-strip", desc="Force the stripping of the compile elements"))
myArgs.add(arguments.ArgDefine("w", "warning", desc="Store warning in a file build file")) myArgs.add(arguments.ArgDefine("w", "warning", desc="Store warning in a file build file"))
@ -32,15 +33,15 @@ myArgs.add(arguments.ArgDefine("w", "warning", desc="Store warning in a file bui
myArgs.add_section("properties", "keep in the sequency of the cible") myArgs.add_section("properties", "keep in the sequency of the cible")
myArgs.add(arguments.ArgDefine("t", "target", haveParam=True, desc="Select a target (by default the platform is the computer that compile this) To know list : 'lutin.py --list-target'")) myArgs.add(arguments.ArgDefine("t", "target", haveParam=True, desc="Select a target (by default the platform is the computer that compile this) To know list : 'lutin.py --list-target'"))
myArgs.add(arguments.ArgDefine("c", "compilator", list=[["clang",""],["gcc",""]], desc="Compile with clang or Gcc mode (by default gcc will be used)")) myArgs.add(arguments.ArgDefine("c", "compilator", list=[["clang",""],["gcc",""]], desc="Compile with clang or Gcc mode (by default gcc will be used)"))
myArgs.add(arguments.ArgDefine("", "compilator-version", haveParam=True, desc="with travis we need to specify the name of the version if we want to compile with gcc 4.9 ==> --compilator-version=4.9")) myArgs.add(arguments.ArgDefine("", "compilator-version", haveParam=True, desc="With travis we need to specify the name of the version if we want to compile with gcc 4.9 ==> --compilator-version=4.9"))
myArgs.add(arguments.ArgDefine("m", "mode", list=[["debug",""],["release",""]], desc="Compile in release or debug mode (default release)")) myArgs.add(arguments.ArgDefine("m", "mode", list=[["debug",""],["release",""]], desc="Compile in release or debug mode (default release)"))
myArgs.add(arguments.ArgDefine("a", "arch", list=[["auto","Automatic choice"],["arm","Arm processer"],["x86","Generic PC : AMD/Intel"],["ppc","Power PC"]], desc="Architecture to compile")) myArgs.add(arguments.ArgDefine("a", "arch", list=[["auto","Automatic choice"],["arm","Arm processer"],["x86","Generic PC : AMD/Intel"],["ppc","Power PC"]], desc="Architecture to compile"))
myArgs.add(arguments.ArgDefine("b", "bus", list=[["auto","Automatic choice"],["32","32 bits"],["64","64 bits"]], desc="Adressing size (Bus size)")) myArgs.add(arguments.ArgDefine("b", "bus", list=[["auto","Automatic choice"],["32","32 bits"],["64","64 bits"]], desc="Adressing size (Bus size)"))
myArgs.add(arguments.ArgDefine("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)")) myArgs.add(arguments.ArgDefine("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)"))
myArgs.add(arguments.ArgDefine("g", "gcov", desc="Enable code coverage intrusion in code")) myArgs.add(arguments.ArgDefine("g", "gcov", desc="Enable code coverage intrusion in code"))
myArgs.add(arguments.ArgDefine("", "simulation", desc="simulater mode (availlable only for IOS)")) myArgs.add(arguments.ArgDefine("", "simulation", desc="Simulater mode (availlable only for IOS)"))
myArgs.add(arguments.ArgDefine("", "list-target", desc="list all availlables targets ==> for auto completion")) myArgs.add(arguments.ArgDefine("", "list-target", desc="List all availlables targets ==> for auto completion"))
myArgs.add(arguments.ArgDefine("", "list-module", desc="list all availlables module ==> for auto completion")) myArgs.add(arguments.ArgDefine("", "list-module", desc="List all availlables module ==> for auto completion"))
myArgs.add_section("cible", "generate in order set") myArgs.add_section("cible", "generate in order set")
localArgument = myArgs.parse() localArgument = myArgs.parse()
@ -48,7 +49,7 @@ localArgument = myArgs.parse()
""" """
display the help of this makefile display the help of this makefile
""" """
def usage(): def usage(full=False):
color = debug.get_color_set() color = debug.get_color_set()
# generic argument displayed : # generic argument displayed :
myArgs.display() myArgs.display()
@ -63,19 +64,86 @@ def usage():
print(" Parse all the code of the library with the gcov resolution") print(" Parse all the code of the library with the gcov resolution")
listOfAllModule = module.list_all_module_with_desc() listOfAllModule = module.list_all_module_with_desc()
for mod in listOfAllModule: for mod in listOfAllModule:
print(" " + color['green'] + mod[0] + color['default']) data_print = " "
if mod[1] != "": if full == False:
print(" " + mod[1]) if mod["type"][:6] == "BINARY":
data_print += color['blue']
if mod["sub-type"] == "":
data_print += "* "
elif mod["sub-type"] == "TEST":
data_print += "T "
elif mod["sub-type"] == "TOOLS":
data_print += "U "
elif mod["sub-type"] == "SAMPLE":
data_print += "S "
else:
data_print += " "
elif mod["type"] == "PACKAGE":
data_print += color['red'] + "# "
elif mod["type"][:7] == "LIBRARY":
data_print += color['yellow'] + " "
else:
data_print += color['default'] + " "
else:
data_print += color['green']
data_print += mod["name"] + color['default']
if full == False:
data_print += "\r\t\t\t\t\t\t\t"
if mod["license"] != "":
data_print += color['yellow'] + " [" + mod["license"] + "]" + color['default']
if mod["version"] != []:
version_ID = tools.version_to_string(mod["version"])
data_print += color['blue'] + " (" + version_ID + ")" + color['default']
"""
if mod["compagny-type"] != "" \
and mod["compagny-name"] != "":
data_print += color['purple'] + " " + mod["compagny-type"] + "/" + mod["compagny-name"] + color['default']
elif mod["compagny-name"] != "":
data_print += color['purple'] + " " + mod["compagny-name"] + color['default']
"""
print(data_print)
if mod["description"] != "":
print(" " + mod["description"])
if full == True:
if mod["type"] != "":
print(" Type: " + mod["type"])
if mod["sub-type"] != "":
print(" Sub-Type: " + mod["sub-type"])
if mod["version"] != []:
version_ID = ""
for id in mod["version"]:
if len(version_ID) != 0:
if type(id) == str:
version_ID+="-"
else:
version_ID+="."
version_ID += str(id)
print(" version: " + color['blue'] + version_ID + color['default'])
if mod["compagny-type"] != "" \
and mod["compagny-name"] != "":
print(" compagny: " + color['purple'] + mod["compagny-type"] + "/" + mod["compagny-name"] + color['default'])
elif mod["compagny-name"] != "":
print(" compagny: " + color['purple'] + mod["compagny-name"] + color['default'])
if mod["license"] != "":
print(" license: " + color['yellow'] + mod["license"] + color['default'])
if mod["maintainer"] != []:
print(" maintainers:")
for elem in mod["maintainer"]:
print(" " + str(elem))
print(" ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all") print(" ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all")
exit(0) exit(0)
# preparse the argument to get the verbose element for debug mode # preparse the argument to get the verbose element for debug mode
def parseGenericArg(argument, active): def parseGenericArg(argument, active):
if argument.get_option_name() == "help": if argument.get_option_name() == "help":
#display help
if active==False: if active==False:
usage() usage()
return True return True
if argument.get_option_name() == "HELP":
if active==False:
usage(True)
return True
if argument.get_option_name() == "list-module": if argument.get_option_name() == "list-module":
if active==False: if active==False:
listOfModule = module.list_all_module() listOfModule = module.list_all_module()

View File

@ -19,6 +19,7 @@ from . import heritage
from . import builder from . import builder
from . import multiprocess from . import multiprocess
from . import image from . import image
from . import license
class Module: class Module:
@ -31,15 +32,15 @@ class Module:
## - files ## - files
## - ... ## - ...
## ##
def __init__(self, file, moduleName, moduleType): def __init__(self, file, module_name, moduleType):
## Remove all variable to prevent error of multiple deffinition of the module ... ## Remove all variable to prevent error of multiple deffinition of the module ...
debug.verbose("Create a new module : '" + moduleName + "' TYPE=" + moduleType) debug.verbose("Create a new module : '" + module_name + "' TYPE=" + moduleType)
self.origin_file='' self.origin_file=''
self.origin_path='' self.origin_path=''
# type of the module: # type of the module:
self.type='LIBRARY' self.type='LIBRARY'
# Name of the module # Name of the module
self.name=moduleName self.name=module_name
# Dependency list: # Dependency list:
self.depends = [] self.depends = []
# Dependency list (optionnal module): # Dependency list (optionnal module):
@ -75,7 +76,7 @@ class Module:
or moduleType == 'PREBUILD': or moduleType == 'PREBUILD':
self.type=moduleType self.type=moduleType
else : else :
debug.error('for module "%s"' %moduleName) debug.error('for module "%s"' %module_name)
debug.error(' ==> error : "%s" ' %moduleType) debug.error(' ==> error : "%s" ' %moduleType)
raise 'Input value error' raise 'Input value error'
self.origin_file = file; self.origin_file = file;
@ -90,7 +91,7 @@ class Module:
"SECTION" : set([]), "SECTION" : set([]),
"PRIORITY" : set(""), "PRIORITY" : set(""),
"DESCRIPTION" : set(""), "DESCRIPTION" : set(""),
"VERSION" : set("0.0.0"), "VERSION" : [0,0,0],
"VERSION_CODE" : "", "VERSION_CODE" : "",
"NAME" : set("no-name"), # name of the application "NAME" : set("no-name"), # name of the application
"ANDROID_MANIFEST" : "", # By default generate the manifest "ANDROID_MANIFEST" : "", # By default generate the manifest
@ -98,8 +99,28 @@ class Module:
"ANDROID_APPL_TYPE" : "APPL", # the other mode is "WALLPAPER" ... and later "WIDGET" "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) "ANDROID_WALLPAPER_PROPERTIES" : [], # To create properties of the wallpaper (no use of EWOL display)
"RIGHT" : [], "RIGHT" : [],
"LICENSE" : "", # by default: no license
"ADMOD_POSITION" : "top" "ADMOD_POSITION" : "top"
} }
self.package_prop_default = { "COMPAGNY_TYPE" : True,
"COMPAGNY_NAME" : True,
"COMPAGNY_NAME2" : True,
"MAINTAINER" : True,
#"ICON" : True,
"SECTION" : True,
"PRIORITY" : True,
"DESCRIPTION" : True,
"VERSION" : True,
"VERSION_CODE" : True,
"NAME" : True,
"ANDROID_MANIFEST" : True,
"ANDROID_RESOURCES" : True,
"ANDROID_APPL_TYPE" : True,
"ANDROID_WALLPAPER_PROPERTIES" : True,
"RIGHT" : True,
"LICENSE" : True,
"ADMOD_POSITION" : True
}
self.sub_heritage_list = None self.sub_heritage_list = None
def get_type(self): def get_type(self):
@ -460,7 +481,6 @@ class Module:
self.local_heritage.add_lib_static(res_file) self.local_heritage.add_lib_static(res_file)
except ValueError: except ValueError:
debug.error(" UN-SUPPORTED link format: '.a'") debug.error(" UN-SUPPORTED link format: '.a'")
"""
if self.type == 'LIBRARY' \ if self.type == 'LIBRARY' \
or self.type == 'LIBRARY_DYNAMIC': or self.type == 'LIBRARY_DYNAMIC':
try: try:
@ -476,7 +496,6 @@ class Module:
self.local_heritage.add_lib_dynamic(res_file) self.local_heritage.add_lib_dynamic(res_file)
except ValueError: except ValueError:
debug.error(" UN-SUPPORTED link format: '.so'/'.dynlib'/'.dll'") debug.error(" UN-SUPPORTED link format: '.so'/'.dynlib'/'.dll'")
"""
try: try:
tmp_builder = builder.get_builder_with_output("jar"); tmp_builder = builder.get_builder_with_output("jar");
list_file = tools.filter_extention(list_sub_file_needed_to_build, tmp_builder.get_input_type()) list_file = tools.filter_extention(list_sub_file_needed_to_build, tmp_builder.get_input_type())
@ -591,10 +610,19 @@ class Module:
# -- install header -- # -- install header --
# ---------------------------------------------------- # ----------------------------------------------------
debug.debug("install headers ...") debug.debug("install headers ...")
copy_list={}
include_path = target.get_build_path_include(self.name)
for file in self.header: for file in self.header:
src_path = os.path.join(self.origin_path, file) src_path = os.path.join(self.origin_path, file["src"])
dst_path = os.path.join(target.get_build_path_include(self.name), file) dst_path = os.path.join(include_path, file["dst"])
tools.copy_file(src_path, dst_path, force_identical=True); tools.copy_file(src_path,
dst_path,
force_identical=True,
in_list=copy_list)
#real copy files
tools.copy_list(copy_list)
# remove unneded files (NOT folder ...)
tools.clean_directory(include_path, copy_list)
# ---------------------------------------------------- # ----------------------------------------------------
# -- install data -- # -- install data --
@ -664,13 +692,17 @@ class Module:
# add elements... # add elements...
self.append_to_internal_list(listout[module], list, order) self.append_to_internal_list(listout[module], list, order)
def append_to_internal_list(self, listout, list, order=False): def append_to_internal_list(self, out_list, in_list, order=False):
if type(list) == type(str()): if type(in_list) == str:
self.append_and_check(listout, list, order) self.append_and_check(out_list, in_list, order)
else: elif type(in_list) == list:
# mulyiple imput in the list ... # mulyiple imput in the list ...
for elem in list: for elem in in_list:
self.append_and_check(listout, elem, order) self.append_and_check(out_list, elem, order)
elif type(in_list) == dict:
self.append_and_check(out_list, in_list, order)
else:
debug.warning("can not add in list other than {list/dict/str} : " + str(type(in_list)))
def add_module_depend(self, list): def add_module_depend(self, list):
self.append_to_internal_list(self.depends, list, True) self.append_to_internal_list(self.depends, list, True)
@ -688,49 +720,59 @@ class Module:
def compile_flags(self, type, list): def compile_flags(self, type, list):
self.append_to_internal_list2(self.flags["local"], type, list) self.append_to_internal_list2(self.flags["local"], type, list)
def compile_version_XX(self, version, same_as_api=True, gnu=False): def compile_version(self, compilator_type, version, same_as_api=True, gnu=False):
cpp_version_list = [1999, 2003, 2011, 2014, 2017] if compilator_type == "c++" \
if version not in cpp_version_list: or compilator_type == "C++":
debug.error("can not select CPP version : " + str(version) + " not in " + str(cpp_version_list)) cpp_version_list = [1999, 2003, 2011, 2014, 2017]
# select API version: if version not in cpp_version_list:
api_version = 1999 debug.error("can not select CPP version : " + str(version) + " not in " + str(cpp_version_list))
if same_as_api == True: # select API version:
api_version = version api_version = 1999
self.flags["local"]["c++-version"] = { "version":version, if same_as_api == True:
"gnu":gnu api_version = version
} self.flags["local"]["c++-version"] = { "version":version,
self.flags["export"]["c++-version"] = api_version "gnu":gnu
if gnu == True and same_as_api == True: }
debug.warning("Can not propagate the gnu extention of the CPP vesion for API"); self.flags["export"]["c++-version"] = api_version
if gnu == True and same_as_api == True:
def compile_version_CC(self, version, same_as_api=True, gnu=False): debug.warning("Can not propagate the gnu extention of the CPP vesion for API");
c_version_list = [1989, 1990, 1999, 2011] elif compilator_type == "c" \
if version not in c_version_list: or compilator_type == "C":
debug.error("can not select C version : " + str(version) + " not in " + str(c_version_list)) c_version_list = [1989, 1990, 1999, 2011]
# select API version: if version not in c_version_list:
api_version = 1999 debug.error("can not select C version : " + str(version) + " not in " + str(c_version_list))
if same_as_api == True: # select API version:
api_version = version api_version = 1999
self.flags["local"]["c-version"] = { "version":version, if same_as_api == True:
"gnu":gnu api_version = version
} self.flags["local"]["c-version"] = { "version":version,
self.flags["export"]["c-version"] = api_version "gnu":gnu
if gnu == True and same_as_api == True: }
debug.warning("Can not propagate the gnu extention of the C vesion for API"); self.flags["export"]["c-version"] = api_version
if gnu == True and same_as_api == True:
debug.warning("Can not propagate the gnu extention of the C vesion for API");
else:
debug.warning("Can not set version of compilator:" + str(compilator_type));
def add_src_file(self, list): def add_src_file(self, list):
self.append_to_internal_list(self.src, list, True) self.append_to_internal_list(self.src, list, True)
def add_header_file(self, list, rm_path=""): def add_header_file(self, list, destination_path=None):
if rm_path != "": if destination_path != None:
debug.warning("remove the basic path ...") debug.verbose("Change destination PATH: " + str(destination_path))
self.append_to_internal_list(self.header, list, True) new_list = []
for elem in list:
if destination_path != None:
new_list.append({"src":elem,
"dst":os.path.join(destination_path, os.path.basename(elem))})
else:
new_list.append({"src":elem,
"dst":elem})
self.append_to_internal_list(self.header, new_list, True)
# TODO : Maybe do sothing with this ...
def add_export_path(self, list, type='c'): def add_export_path(self, list, type='c'):
self.append_to_internal_list2(self.path["export"], type, list) self.append_to_internal_list2(self.path["export"], type, list)
def copy_image(self, source, destination='', sizeX=-1, sizeY=-1): def copy_image(self, source, destination='', sizeX=-1, sizeY=-1):
self.image_to_copy.append([source, destination, sizeX, sizeY]) self.image_to_copy.append([source, destination, sizeX, sizeY])
@ -791,21 +833,26 @@ class Module:
# edu : Education # edu : Education
# pri : Private # pri : Private
# museum : ... # museum : ...
if value not in ["com", "net", "org", "gov", "mil", "edu", "pri", "museum"]: if value not in ["", "com", "net", "org", "gov", "mil", "edu", "pri", "museum"]:
debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'") debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'")
else: else:
self.package_prop[variable] = value self.package_prop[variable] = value
self.package_prop_default[variable] = False
elif "COMPAGNY_NAME" == variable: elif "COMPAGNY_NAME" == variable:
self.package_prop[variable] = value self.package_prop[variable] = value
self.package_prop_default[variable] = False
val2 = value.lower() val2 = value.lower()
val2 = val2.replace(' ', '') val2 = val2.replace(' ', '')
val2 = val2.replace('-', '') val2 = val2.replace('-', '')
val2 = val2.replace('_', '') val2 = val2.replace('_', '')
self.package_prop["COMPAGNY_NAME2"] = val2 self.package_prop["COMPAGNY_NAME2"] = val2
self.package_prop_default["COMPAGNY_NAME2"] = False
elif "ICON" == variable: elif "ICON" == variable:
self.package_prop[variable] = value self.package_prop[variable] = value
self.package_prop_default[variable] = False
elif "MAINTAINER" == variable: elif "MAINTAINER" == variable:
self.package_prop[variable] = value self.package_prop[variable] = value
self.package_prop_default[variable] = False
elif "SECTION" == variable: elif "SECTION" == variable:
# project section : (must be separate by coma # project section : (must be separate by coma
# refer to : http://packages.debian.org/sid/ # refer to : http://packages.debian.org/sid/
@ -818,6 +865,7 @@ class Module:
# perl php python ruby science shells sound tex # perl php python ruby science shells sound tex
# text utils vcs video virtual web x11 xfce zope ... # text utils vcs video virtual web x11 xfce zope ...
self.package_prop[variable] = value self.package_prop[variable] = value
self.package_prop_default[variable] = False
elif "PRIORITY" == variable: elif "PRIORITY" == variable:
#list = ["required","important","standard","optional","extra"] #list = ["required","important","standard","optional","extra"]
#if isinstance(value, list): #if isinstance(value, list):
@ -825,36 +873,34 @@ class Module:
debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'") debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'")
else: else:
self.package_prop[variable] = value self.package_prop[variable] = value
elif "DESCRIPTION" == variable: self.package_prop_default[variable] = False
self.package_prop[variable] = value elif variable in ["DESCRIPTION",
elif "VERSION" == variable: "VERSION",
self.package_prop[variable] = value "VERSION_CODE",
elif "VERSION_CODE" == variable: "NAME",
self.package_prop[variable] = value "ANDROID_MANIFEST",
elif "NAME" == variable: "ANDROID_JAVA_FILES",
self.package_prop[variable] = value "RIGHT",
elif "ANDROID_MANIFEST" == variable: "ANDROID_RESOURCES",
self.package_prop[variable] = value "ANDROID_APPL_TYPE",
elif "ANDROID_JAVA_FILES" == variable: "ADMOD_ID",
self.package_prop[variable] = value "APPLE_APPLICATION_IOS_ID",
elif "RIGHT" == variable: "LICENSE"]:
self.package_prop[variable] = value
elif "ANDROID_RESOURCES" == variable:
self.package_prop[variable] = value
elif "ANDROID_APPL_TYPE" == variable:
self.package_prop[variable] = value
elif "ADMOD_ID" == variable:
self.package_prop[variable] = value
elif "APPLE_APPLICATION_IOS_ID" == variable:
self.package_prop[variable] = value self.package_prop[variable] = value
self.package_prop_default[variable] = False
elif "ADMOD_POSITION" == variable: elif "ADMOD_POSITION" == variable:
if value in ["top", "bottom"]: if value in ["top", "bottom"]:
self.package_prop[variable] = value self.package_prop[variable] = value
self.package_prop_default[variable] = False
else: else:
debug.error("not know pkg element : '" + variable + "' with value : '" + value + "' must be [top|bottom]") debug.error("not know pkg element : '" + variable + "' with value : '" + value + "' must be [top|bottom]")
else: else:
debug.error("not know pkg element : '" + variable + "'") debug.error("not know pkg element : '" + variable + "'")
def pkg_set_if_default(self, variable, value):
if self.package_prop_default[variable] == True:
self.pkg_set(variable, value)
def pkg_add(self, variable, value): def pkg_add(self, variable, value):
if variable in self.package_prop: if variable in self.package_prop:
self.package_prop[variable].append(value) self.package_prop[variable].append(value)
@ -882,11 +928,11 @@ class Module:
moduleList=[] module_list=[]
__start_module_name="lutin_" __start_module_name="lutin_"
def import_path(path): def import_path(path):
global moduleList global module_list
matches = [] matches = []
debug.debug('MODULE: Start find sub File : "%s"' %path) debug.debug('MODULE: Start find sub File : "%s"' %path)
for root, dirnames, filenames in os.walk(path): for root, dirnames, filenames in os.walk(path):
@ -896,54 +942,148 @@ def import_path(path):
debug.debug('Module: Find a file : "%s"' %os.path.join(root, filename)) debug.debug('Module: Find a file : "%s"' %os.path.join(root, filename))
#matches.append(os.path.join(root, filename)) #matches.append(os.path.join(root, filename))
sys.path.append(os.path.dirname(os.path.join(root, filename)) ) sys.path.append(os.path.dirname(os.path.join(root, filename)) )
moduleName = filename.replace('.py', '') module_name = filename.replace('.py', '')
moduleName = moduleName.replace(__start_module_name, '') module_name = module_name.replace(__start_module_name, '')
debug.debug("MODULE: Integrate module: '" + moduleName + "' from '" + os.path.join(root, filename) + "'") debug.debug("MODULE: Integrate module: '" + module_name + "' from '" + os.path.join(root, filename) + "'")
moduleList.append([moduleName,os.path.join(root, filename)]) module_list.append([module_name,os.path.join(root, filename)])
debug.verbose("New list module: ")
for mod in module_list:
debug.verbose(" " + str(mod[0]))
def exist(target, name): def exist(target, name):
global moduleList global module_list
for mod in moduleList: for mod in module_list:
if mod[0] == name: if mod[0] == name:
return True return True
return False return False
def load_module(target, name): def load_module(target, name):
global moduleList global module_list
for mod in moduleList: for mod in module_list:
if mod[0] == name: if mod[0] == name:
sys.path.append(os.path.dirname(mod[1])) sys.path.append(os.path.dirname(mod[1]))
debug.verbose("import module : '" + __start_module_name + name + "'") debug.verbose("import module : '" + __start_module_name + name + "'")
theModule = __import__(__start_module_name + name) the_module_file = mod[1]
#try: the_module = __import__(__start_module_name + name)
tmpElement = theModule.create(target) # get basic module properties:
#except: property = get_module_option(the_module, name)
#tmpElement = None # configure the module:
#debug.warning(" no function 'create' in the module : " + mod[0] + " from:'" + mod[1] + "'") if "create" in dir(the_module):
if (tmpElement == None) : tmp_element = the_module.create(target, name)
if tmp_element != None:
# overwrite some package default property (if not set by user)
if property["compagny-type"] != None:
tmp_element.pkg_set_if_default("COMPAGNY_TYPE", property["compagny-type"])
if property["compagny-name"] != None:
tmp_element.pkg_set_if_default("COMPAGNY_NAME", property["compagny-name"])
if property["maintainer"] != None:
tmp_element.pkg_set_if_default("MAINTAINER", property["maintainer"])
if property["name"] != None:
tmp_element.pkg_set_if_default("NAME", property["name"])
if property["description"] != None:
tmp_element.pkg_set_if_default("DESCRIPTION", property["description"])
if property["license"] != None:
tmp_element.pkg_set_if_default("LICENSE", property["license"])
if property["version"] != None:
tmp_element.pkg_set_if_default("VERSION", property["version"])
else:
debug.warning(" no function 'create' in the module : " + mod[0] + " from:'" + mod[1] + "'")
continue
"""
if property["type"] == "":
continue
# configure the module:
if "configure" in dir(the_module):
tmp_element = module.Module(the_module_file, name, property["type"], property)
ret = the_module.configure(target, tmp_element)
if ret == True:
debug.warning("configure done corectly : " + mod[0] + " from:'" + mod[1] + "'")
else:
debug.warning("configure NOT done corectly : " + mod[0] + " from:'" + mod[1] + "'")
else:
debug.warning(" no function 'configure' in the module : " + mod[0] + " from:'" + mod[1] + "'")
continue
"""
# check if create has been done corectly
if tmp_element == None:
debug.debug("Request load module '" + name + "' not define for this platform") debug.debug("Request load module '" + name + "' not define for this platform")
else: else:
target.add_module(tmpElement) target.add_module(tmp_element)
def list_all_module(): def list_all_module():
global moduleList global module_list
tmpListName = [] tmpListName = []
for mod in moduleList: for mod in module_list:
tmpListName.append(mod[0]) tmpListName.append(mod[0])
return tmpListName return tmpListName
def list_all_module_with_desc(): def list_all_module_with_desc():
global moduleList global module_list
tmpList = [] tmpList = []
for mod in moduleList: for mod in module_list:
sys.path.append(os.path.dirname(mod[1])) sys.path.append(os.path.dirname(mod[1]))
theModule = __import__("lutin_" + mod[0]) the_module = __import__("lutin_" + mod[0])
try: tmpList.append(get_module_option(the_module, mod[0]))
tmpdesc = theModule.get_desc()
tmpList.append([mod[0], tmpdesc])
except:
debug.warning("has no naeme : " + mod[0])
tmpList.append([mod[0], ""])
return tmpList return tmpList
def get_module_option(the_module, name):
type = None
sub_type = None
description = None
license = None
compagny_type = None
compagny_name = None
maintainer = None
version = None
if "get_type" in dir(the_module):
type = the_module.get_type()
else:
debug.debug(" fundtion get_type() must be provided in the module: " + name)
if "get_sub_type" in dir(the_module):
sub_type = the_module.get_sub_type()
if "get_desc" in dir(the_module):
description = the_module.get_desc()
if "get_licence" in dir(the_module):
license = the_module.get_licence()
if "get_compagny_type" in dir(the_module):
compagny_type = the_module.get_compagny_type()
# com : Commercial
# net : Network??
# org : Organisation
# gov : Governement
# mil : Military
# edu : Education
# pri : Private
# museum : ...
compagny_type_list = ["", "com", "net", "org", "gov", "mil", "edu", "pri", "museum"]
if compagny_type not in compagny_type_list:
debug.warning("[" + name + "] type of the company not normal: " + compagny_type + " not in " + str(compagny_type_list))
if "get_compagny_name" in dir(the_module):
compagny_name = the_module.get_compagny_name()
if "get_maintainer" in dir(the_module):
maintainer = the_module.get_maintainer()
if "get_version" in dir(the_module):
version = the_module.get_version()
return {
"name":name,
"description":description,
"type":type,
"sub-type":sub_type,
"license":license,
"compagny-type":compagny_type,
"compagny-name":compagny_name,
"maintainer":maintainer,
"version":version
}

View File

@ -637,7 +637,7 @@ class Target:
def make_package_generic_files(self, path_package, pkg_properties, pkg_name, base_pkg_path, heritage_list, static): def make_package_generic_files(self, path_package, pkg_properties, pkg_name, base_pkg_path, heritage_list, static):
## Create version file: ## Create version file:
tools.file_write_data(os.path.join(path_package, self.pkg_path_version_file), tools.file_write_data(os.path.join(path_package, self.pkg_path_version_file),
pkg_properties["VERSION"], tools.version_to_string(pkg_properties["VERSION"]),
only_if_new=True) only_if_new=True)
## Create maintainer file: ## Create maintainer file:
@ -664,7 +664,7 @@ class Target:
elif os.path.exists(os.path.join(base_pkg_path, "README.md"))==True: elif os.path.exists(os.path.join(base_pkg_path, "README.md"))==True:
tools.copy_file(os.path.join(base_pkg_path, "README.md"), readme_file_dest) tools.copy_file(os.path.join(base_pkg_path, "README.md"), readme_file_dest)
else: else:
debug.info("no file 'README', 'README.md' or 'os-Linux/README' ==> generate an empty one") debug.debug("no file 'README', 'README.md' or 'os-Linux/README' ==> generate an empty one")
tools.file_write_data(readme_file_dest, tools.file_write_data(readme_file_dest,
"No documentation for " + pkg_name + "\n", "No documentation for " + pkg_name + "\n",
only_if_new=True) only_if_new=True)
@ -689,7 +689,7 @@ class Target:
if os.path.exists(os.path.join(base_pkg_path, "changelog")) == True: if os.path.exists(os.path.join(base_pkg_path, "changelog")) == True:
tools.copy_file(os.path.join(base_pkg_path, "changelog"), change_log_file_dest) tools.copy_file(os.path.join(base_pkg_path, "changelog"), change_log_file_dest)
else: else:
debug.info("no file 'changelog' ==> generate an empty one") debug.debug("no file 'changelog' ==> generate an empty one")
tools.file_write_data(change_log_file_dest, tools.file_write_data(change_log_file_dest,
"No changelog data " + pkg_name + "\n", "No changelog data " + pkg_name + "\n",
only_if_new=True) only_if_new=True)

View File

@ -68,6 +68,17 @@ def file_read_data(path, binary=False):
file.close() file.close()
return data_file return data_file
def version_to_string(version):
version_ID = ""
for id in version:
if len(version_ID) != 0:
if type(id) == str:
version_ID += "-"
else:
version_ID += "."
version_ID += str(id)
return version_ID
## ##
## @brief Write data in a specific path. ## @brief Write data in a specific path.
## @param[in] path Path of the data might be written. ## @param[in] path Path of the data might be written.

View File

@ -215,7 +215,7 @@ class Target(target.Target):
def make_package_generic_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static): def make_package_generic_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
debug.info("Generate package '" + pkg_name + "' v"+pkg_properties["VERSION"]) debug.info("Generate package '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
#output path #output path
target_outpath = self.get_staging_path(pkg_name) target_outpath = self.get_staging_path(pkg_name)
@ -260,7 +260,7 @@ class Target(target.Target):
tools.clean_directory(target_outpath_lib, copy_list) tools.clean_directory(target_outpath_lib, copy_list)
## Create generic files: ## Create generic files:
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static): self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
## create specific android project (local) ## create specific android project (local)
pkg_name_application_name = pkg_name pkg_name_application_name = pkg_name

View File

@ -85,7 +85,7 @@ class Target(target.Target):
def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static): def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
debug.info("Generate package '" + pkg_name + "' v"+pkg_properties["VERSION"]) debug.info("Generate package '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
#output path #output path
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app") target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
@ -101,7 +101,7 @@ class Target(target.Target):
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static) self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
## Create generic files: ## Create generic files:
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static): self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
## Create icon: ## Create icon:
if "ICON" in pkg_properties.keys() \ if "ICON" in pkg_properties.keys() \

View File

@ -75,7 +75,7 @@ class Target(target.Target):
""" """
def make_package_generic_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static): def make_package_generic_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
debug.info("Generate generic '" + pkg_name + "' v"+pkg_properties["VERSION"]) debug.info("Generate generic '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
#output path #output path
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app") target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
@ -91,7 +91,7 @@ class Target(target.Target):
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static) self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
## Create generic files: ## Create generic files:
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static): self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
## create the package: ## create the package:
debug.debug("package : " + self.get_staging_path(pkg_name) + "/" + pkg_name + ".app.pkg") debug.debug("package : " + self.get_staging_path(pkg_name) + "/" + pkg_name + ".app.pkg")

View File

@ -55,7 +55,7 @@ class Target(target.Target):
def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static): def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
debug.info("Generate package '" + pkg_name + "' v"+pkg_properties["VERSION"]) debug.info("Generate package '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
#output path #output path
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app/Contents") target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app/Contents")
@ -71,7 +71,7 @@ class Target(target.Target):
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static) self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
## Create generic files: ## Create generic files:
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static): self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
## Create icon (no convertion ==> TODO: must test if png is now supported): ## Create icon (no convertion ==> TODO: must test if png is now supported):
if "ICON" in pkg_properties.keys() \ if "ICON" in pkg_properties.keys() \

View File

@ -72,7 +72,7 @@ class Target(target.Target):
def make_package_generic_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static): def make_package_generic_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
debug.info("Generate package '" + pkg_name + "' v"+pkg_properties["VERSION"]) debug.info("Generate package '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
debug.debug("------------------------------------------------------------------------") debug.debug("------------------------------------------------------------------------")
#output path #output path
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app") target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
@ -88,7 +88,7 @@ class Target(target.Target):
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static) self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
## Create generic files: ## Create generic files:
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static): self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
def make_package_single_file(self, pkg_name, pkg_properties, base_pkg_path, heritage_list): def make_package_single_file(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):

View File

@ -7,7 +7,7 @@ def readme():
# https://pypi.python.org/pypi?%3Aaction=list_classifiers # https://pypi.python.org/pypi?%3Aaction=list_classifiers
setup(name='lutin', setup(name='lutin',
version='0.6.4', version='0.7.0',
description='Lutin generic builder', description='Lutin generic builder',
long_description=readme(), long_description=readme(),
url='http://github.com/HeeroYui/lutin', url='http://github.com/HeeroYui/lutin',