From 2ebe27a5a4f7d8f04102184180c811c6eec14fae Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 6 Sep 2016 21:04:01 +0200 Subject: [PATCH] [DOC/DEV] continue documentation and update API ==> end of normalisation --- bin/lutin | 46 +-- doxy_lutin.py | 35 ++ lutin/arg.py | 164 ++++++-- lutin/builder.py | 27 +- lutin/debug.py | 95 ++++- lutin/depend.py | 28 +- lutin/heritage.py | 30 +- lutin/image.py | 13 + lutin/module.py | 982 ++++++++++++++++++++++++++++------------------ lutin/system.py | 26 +- lutin/target.py | 32 +- 11 files changed, 1015 insertions(+), 463 deletions(-) create mode 100644 doxy_lutin.py diff --git a/bin/lutin b/bin/lutin index aa0ea41..e8393d8 100755 --- a/bin/lutin +++ b/bin/lutin @@ -25,32 +25,32 @@ import lutin.host as lutinHost import lutin.tools as lutinTools myArgs = arguments.LutinArg() -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("h", "help", desc="Display this help") +myArgs.add("H", "HELP", desc="Display this help (with all compleate information)") 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("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("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("d", "depth", haveParam=True, desc="Depth of the search of sub element lutin_*.py (default=" + str(env.get_parse_depth()) + ")")) -myArgs.add(arguments.ArgDefine("s", "force-strip", desc="Force the stripping of the compile elements")) -myArgs.add(arguments.ArgDefine("o", "force-optimisation", desc="Force optimisation of the build")) -myArgs.add(arguments.ArgDefine("w", "warning", desc="Store warning in a file build file")) -myArgs.add(arguments.ArgDefine("i", "isolate-system", desc="Isolate system build (copy header of c and c++ system lib to not include unneeded external libs) EXPERIMENTAL (archlinux)")) +myArgs.add("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("C", "color", desc="Display makefile output in color") +myArgs.add("B", "force-build", desc="Force the rebuild without checking the dependency") +myArgs.add("P", "pretty", desc="Print the debug has pretty display") +myArgs.add("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously") +myArgs.add("d", "depth", haveParam=True, desc="Depth of the search of sub element lutin_*.py (default=" + str(env.get_parse_depth()) + ")") +myArgs.add("s", "force-strip", desc="Force the stripping of the compile elements") +myArgs.add("o", "force-optimisation", desc="Force optimisation of the build") +myArgs.add("w", "warning", desc="Store warning in a file build file") +myArgs.add("i", "isolate-system", desc="Isolate system build (copy header of c and c++ system lib to not include unneeded external libs) EXPERIMENTAL (archlinux)") 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("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("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("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("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("", "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("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("c", "compilator", list=[["clang",""],["gcc",""]], desc="Compile with clang or Gcc mode (by default gcc will be used)") +myArgs.add("", "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("m", "mode", list=[["debug",""],["release",""]], desc="Compile in release or debug mode (default release)") +myArgs.add("a", "arch", list=[["auto","Automatic choice"],["arm","Arm processer"],["x86","Generic PC : AMD/Intel"],["ppc","Power PC"]], desc="Architecture to compile") +myArgs.add("b", "bus", list=[["auto","Automatic choice"],["32","32 bits"],["64","64 bits"]], desc="Adressing size (Bus size)") +myArgs.add("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)") +myArgs.add("g", "gcov", desc="Enable code coverage intrusion in code") +myArgs.add("", "simulation", desc="Simulater mode (availlable only for IOS)") +myArgs.add("", "list-target", desc="List all availlables targets ==> for auto completion") +myArgs.add("", "list-module", desc="List all availlables module ==> for auto completion") myArgs.add_section("cible", "generate in order set") localArgument = myArgs.parse() diff --git a/doxy_lutin.py b/doxy_lutin.py new file mode 100644 index 0000000..bf4e11b --- /dev/null +++ b/doxy_lutin.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +import os +import doxy.module as module +import doxy.debug as debug +import doxy.tools as tools + +def create(target, module_name): + my_module = module.Module(__file__, module_name) + my_module.set_version([1,2,6]) + my_module.set_title("lutin: build system and packager") + my_module.set_website("http://HeeroYui.github.io/" + module_name) + my_module.set_website_sources("http://github.com/HeeroYui/" + module_name) + my_module.add_path([ + module_name, + "doc" + ]) + my_module.add_exclude_symbols([ + '_*', + 'lutinTarget_*', + 'lutinSystem_*', + 'lutinBuilder_*', + ]) + my_module.add_file_patterns([ + #'*.py', + 'builder.py', + 'debug.py', + 'env.py', + 'host.py', + 'module.py', + 'system.py', + 'target.py', + '*.md', + ]) + + return my_module \ No newline at end of file diff --git a/lutin/arg.py b/lutin/arg.py index 862d0c1..c535a0b 100644 --- a/lutin/arg.py +++ b/lutin/arg.py @@ -8,30 +8,63 @@ ## @license APACHE v2.0 (see license file) ## import sys -# Local import from . import debug +## +## @brief Single argument class. It permit to define the getted argument. +## class ArgElement: + ## + ## @brief Contructor. + ## @param[in] self Class handle + ## @param[in] option (string) Option name (write in fullmode ex: '--verbose' even if user write '-v') + ## @param[in] value (string) Writed value by the user (defult '') + ## def __init__(self, option, value=""): self.option = option; self.arg = value; + ## + ## @brief Get the name of the argument: (write in fullmode ex: '--verbose' even if user write '-v') + ## @param[in] self Class handle + ## @return (string) The argument name + ## def get_option_name(self): return self.option + ## + ## @brief Get argument data set by the user + ## @param[in] self Class handle + ## @return (string) The argument value + ## def get_arg(self): return self.arg + ## + ## @brief Display the Argument property + ## @param[in] self Class handle + ## def display(self): - if len(self.arg)==0: + if len(self.arg) == 0: debug.info("option : " + self.option) - elif len(self.option)==0: + elif len(self.option) == 0: debug.info("element : " + self.arg) else: debug.info("option : " + self.option + ":" + self.arg) - +## +## @brief Declare a possibility of an argument value +## class ArgDefine: + ## + ## @brief Contructor. + ## @param[in] self Class handle + ## @param[in] smallOption (char) Value for the small option ex: '-v' '-k' ... 1 single char element (no need of '-') + ## @param[in] bigOption (string) Value of the big option name ex: '--verbose' '--kill' ... stated with -- and with the full name (no need of '--') + ## @param[in] list ([[string,string],...]) Optionnal list of availlable option: '--mode=debug' ==> [['debug', 'debug mode'],['release', 'release the software']] + ## @param[in] desc (string) user friendly description with this parameter (default "") + ## @param[in] haveParam (bool) The option must have a parameter (default False) + ## def __init__(self, smallOption="", # like v for -v bigOption="", # like verbose for --verbose @@ -50,18 +83,46 @@ class ArgDefine: self.have_param = False self.description = desc; + ## + ## @brief Get the small name of the option ex: '-v' + ## @param[in] self Class handle + ## @return (string) Small name value + ## def get_option_small(self): return self.option_small - + + ## + ## @brief Get the big name of the option ex: '--verbose' + ## @param[in] self Class handle + ## @return (string) Big name value + ## def get_option_big(self): return self.option_big + ## + ## @brief Get the status of getting user parameter value + ## @param[in] self Class handle + ## @return True The user must write a value + ## @return False The user must NOT write a value + ## def need_parameters(self): return self.have_param + ## + ## @brief Compatibility with @ref ArgSection class + ## @param[in] self Class handle + ## @return (string) empty string + ## def get_porperties(self): return "" + ## + ## @brief Check if the user added value is correct or not with the list of availlable value + ## @param[in] self Class handle + ## @param[in] argument (string) User parameter value (string) + ## @return True The parameter is OK + ## @return False The parameter is NOT Availlable + ## def check_availlable(self, argument): if len(self.list)==0: return True @@ -70,6 +131,10 @@ class ArgDefine: return True return False + ## + ## @brief Display the argument property when user request help + ## @param[in] self Class handle + ## def display(self): color = debug.get_color_set() if self.option_small != "" and self.option_big != "": @@ -98,46 +163,94 @@ class ArgDefine: tmpElementPrint += " / " tmpElementPrint += val print(" { " + tmpElementPrint + " }") - - def parse(self, argList, currentID): - return currentID; +## +## @brief Section Class definition (permit to add a comment when requesting help +## class ArgSection: + ## + ## @brief Constructor + ## @param[in] self Class handle + ## @param[in] sectionName (string) Name of the cestion ex: "option" is displayed [option] + ## @param[in] desc (string) Comment assiciated with the group + ## def __init__(self, sectionName="", desc=""): self.section = sectionName; self.description = desc; + ## + ## @brief Compatibility with @ref ArgDefine class + ## @param[in] self Class handle + ## @return empty string + ## def get_option_small(self): return "" - + + ## + ## @brief Compatibility with @ref ArgDefine class + ## @param[in] self Class handle + ## @return empty string + ## def get_option_big(self): return "" - + + ## + ## @brief get property print value with the correct writing mode + ## @param[in] self Class handle + ## @return String to display in the short line help + ## def get_porperties(self): color = debug.get_color_set() return " [" + color['blue'] + self.section + color['default'] + "]" + ## + ## @brief Display the argument property when user request help + ## @param[in] self Class handle + ## def display(self): color = debug.get_color_set() print(" [" + color['blue'] + self.section + color['default'] + "] : " + self.description) - - def parse(self, argList, currentID): - return currentID; +## +## @brief Class to define the agmument list availlable for a program +## class LutinArg: + ## + ## @brief Constructor. + ## @param[in] self Class handle + ## def __init__(self): - self.listProperties = [] + self.list_properties = [] - def add(self, argument): - self.listProperties.append(argument) #ArgDefine(smallOption, bigOption, haveParameter, parameterList, description)); + ## + ## @brief Add a new argument possibilities... + ## @param[in] self Class handle + ## @param[in] smallOption (char) Value for the small option ex: '-v' '-k' ... 1 single char element (no need of '-') + ## @param[in] bigOption (string) Value of the big option name ex: '--verbose' '--kill' ... stated with -- and with the full name (no need of '--') + ## @param[in] list ([[string,string],...]) Optionnal list of availlable option: '--mode=debug' ==> [['debug', 'debug mode'],['release', 'release the software']] + ## @param[in] desc (string) user friendly description with this parameter (default "") + ## @param[in] haveParam (bool) The option must have a parameter (default False) + ## + def add(self, smallOption="", bigOption="", list=[], desc="", haveParam=False): + self.list_properties.append(ArgDefine(smallOption, bigOption, list, desc, haveParam)) + ## + ## @brief Add section on argument list + ## @param[in] self Class handle + ## @param[in] sectionName (string) Name of the cestion ex: "option" is displayed [option] + ## @param[in] sectionDesc (string) Comment assiciated with the group + ## def add_section(self, sectionName, sectionDesc): - self.listProperties.append(ArgSection(sectionName, sectionDesc)) + self.list_properties.append(ArgSection(sectionName, sectionDesc)) + ## + ## @brief Parse the argument set in the command line + ## @param[in] self Class handle + ## def parse(self): listArgument = [] # composed of list element NotparseNextElement=False @@ -159,7 +272,7 @@ class LutinArg: argumentFound=False; if option[:2]=="--": # big argument - for prop in self.listProperties: + for prop in self.list_properties: if prop.get_option_big()=="": continue if prop.get_option_big() == option[2:]: @@ -201,7 +314,7 @@ class LutinArg: debug.error("UNKNOW argument : '" + argument + "'") elif option[:1]=="-": # small argument - for prop in self.listProperties: + for prop in self.list_properties: if prop.get_option_small()=="": continue if prop.get_option_small() == option[1:1+len(prop.get_option_small())]: @@ -250,13 +363,16 @@ class LutinArg: #exit(0) return listArgument; - - + ## + ## @brief Display help on console output + ## @param[in] self Class handle + ## def display(self): print("usage:") listOfPropertiesArg = ""; - for element in self.listProperties : + for element in self.list_properties : listOfPropertiesArg += element.get_porperties() print(" " + sys.argv[0] + listOfPropertiesArg + " ...") - for element in self.listProperties : - element.display() \ No newline at end of file + for element in self.list_properties : + element.display() + diff --git a/lutin/builder.py b/lutin/builder.py index 2c301eb..b1e8220 100644 --- a/lutin/builder.py +++ b/lutin/builder.py @@ -27,7 +27,10 @@ from . import env builder_list=[] __start_builder_name="Builder_" - +## +## @brief Import all File that start with env.get_build_system_base_name() + __start_builder_name + XXX and register in the list of Builder +## @param[in] path_list ([string,...]) List of file that start with env.get_build_system_base_name() in the running worktree (Parse one time ==> faster) +## def import_path(path_list): global builder_list global_base = env.get_build_system_base_name() @@ -57,7 +60,10 @@ def import_path(path_list): for elem in builder_list: debug.verbose(" " + str(elem["name"])) -# we must have call all import before ... + +## +## @brief All builder are common (no target or comilator dependency). We need to load all of them when start lutin +## def init(): global builder_list debug.debug('BUILDER: Initialize all ...') @@ -65,6 +71,10 @@ def init(): if element["element"] != None: element["element"].init() +## +## @brief Get a builder tool with specifiying the input type (like cpp, S ...) +## @param[in] input_type (string) extention file that can be compile +## def get_builder(input_type): global builder_list for element in builder_list: @@ -75,13 +85,16 @@ def get_builder(input_type): debug.error("Can not find builder for type : '" + str(input_type) + "'") raise ValueError('type error :' + str(input_type)) - -def get_builder_with_output(input_type): +## +## @brief Get a builder tool with specifiying the output type (like .exe, .jar ...) +## @param[in] input_type (string) extention file that can be generated +## +def get_builder_with_output(output_type): global builder_list for element in builder_list: if element["element"] != None: - if input_type in element["element"].get_output_type(): + if output_type in element["element"].get_output_type(): return element["element"] # we can not find the builder ... - debug.error("Can not find builder for type : '" + str(input_type) + "'") - raise ValueError('type error :' + str(input_type)) \ No newline at end of file + debug.error("Can not find builder for type : '" + str(output_type) + "'") + raise ValueError('type error :' + str(output_type)) diff --git a/lutin/debug.py b/lutin/debug.py index abdb628..1472f74 100644 --- a/lutin/debug.py +++ b/lutin/debug.py @@ -26,15 +26,33 @@ color_cyan = "" debug_lock = threading.Lock() +## +## @brief Set log level of the console log system +## @param[in] id (int) Value of the log level: +## 0: None +## 1: error +## 2: warning +## 3: info +## 4: debug +## 5: verbose +## 6: extreme_verbose +## def set_level(id): global debug_level debug_level = id #print "SetDebug level at " + str(debug_level) +## +## @brief Get the current debug leval +## @return The value of the log level. Show: @ref set_level +## def get_level(): global debug_level return debug_level +## +## @brief Enable color of the console Log system +## def enable_color(): global debug_color debug_color = True @@ -53,6 +71,9 @@ def enable_color(): global color_cyan color_cyan = "\033[36m" +## +## @brief Disable color of the console Log system +## def disable_color(): global debug_color debug_color = True @@ -71,6 +92,11 @@ def disable_color(): global color_cyan color_cyan = "" +## +## @brief Print a extreme verbose log +## @param[in] input (string) Value to print if level is enough +## @param[in] force (bool) force display (no check of log level) +## def extreme_verbose(input, force=False): global debug_lock global debug_level @@ -80,6 +106,11 @@ def extreme_verbose(input, force=False): print(color_blue + input + color_default) debug_lock.release() +## +## @brief Print a verbose log +## @param[in] input (string) Value to print if level is enough +## @param[in] force (bool) force display (no check of log level) +## def verbose(input, force=False): global debug_lock global debug_level @@ -89,6 +120,11 @@ def verbose(input, force=False): print(color_blue + input + color_default) debug_lock.release() +## +## @brief Print a debug log +## @param[in] input (string) Value to print if level is enough +## @param[in] force (bool) force display (no check of log level) +## def debug(input, force=False): global debug_lock global debug_level @@ -98,6 +134,11 @@ def debug(input, force=False): print(color_green + input + color_default) debug_lock.release() +## +## @brief Print an info log +## @param[in] input (string) Value to print if level is enough +## @param[in] force (bool) force display (no check of log level) +## def info(input, force=False): global debug_lock global debug_level @@ -107,6 +148,11 @@ def info(input, force=False): print(input + color_default) debug_lock.release() +## +## @brief Print a warning log +## @param[in] input (string) Value to print if level is enough +## @param[in] force (bool) force display (no check of log level) +## def warning(input, force=False): global debug_lock global debug_level @@ -116,6 +162,11 @@ def warning(input, force=False): print(color_purple + "[WARNING] " + input + color_default) debug_lock.release() +## +## @brief Print a todo log +## @param[in] input (string) Value to print if level is enough +## @param[in] force (bool) force display (no check of log level) +## def todo(input, force=False): global debug_lock global debug_level @@ -125,6 +176,13 @@ def todo(input, force=False): print(color_purple + "[TODO] " + input + color_default) debug_lock.release() +## +## @brief Print an error log +## @param[in] input (string) Value to print if level is enough +## @param[in] thread_id (int) Current thead ID of the builder thread +## @param[in] force (bool) force display (no check of log level) +## @param[in] crash (bool) build error has appear ==> request stop of all builds +## def error(input, thread_id=-1, force=False, crash=True): global debug_lock global debug_level @@ -142,6 +200,15 @@ def error(input, thread_id=-1, force=False, crash=True): #os_exit(-1) #raise "error happend" + +## +## @brief Print a log for a specific element action like generateing .so or binary ... +## @param[in] type (string) type of action. Like: "copy file", "StaticLib", "Prebuild", "Library" ... +## @param[in] lib (string) Name of the library/binary/package that action is done +## @param[in] dir (string) build direction. ex: "<==", "==>" ... +## @param[in] name (string) Destination of the data +## @param[in] force (bool) force display (no check of log level) +## def print_element(type, lib, dir, name, force=False): global debug_lock global debug_level @@ -151,23 +218,31 @@ def print_element(type, lib, dir, name, force=False): print(color_cyan + type + color_default + " : " + color_yellow + lib + color_default + " " + dir + " " + color_blue + name + color_default) debug_lock.release() -def print_compilator(myString): +## +## @brief Print a compilation return (output) +## @param[in] my_string (string) Std-error/std-info that is generate by the build system +## +def print_compilator(my_string): global debug_color global debug_lock if debug_color == True: - myString = myString.replace('\\n', '\n') - myString = myString.replace('\\t', '\t') - myString = myString.replace('error:', color_red+'error:'+color_default) - myString = myString.replace('warning:', color_purple+'warning:'+color_default) - myString = myString.replace('note:', color_green+'note:'+color_default) - myString = re.sub(r'([/\w_-]+\.\w+):', r'-COLORIN-\1-COLOROUT-:', myString) - myString = myString.replace('-COLORIN-', color_yellow) - myString = myString.replace('-COLOROUT-', color_default) + my_string = my_string.replace('\\n', '\n') + my_string = my_string.replace('\\t', '\t') + my_string = my_string.replace('error:', color_red+'error:'+color_default) + my_string = my_string.replace('warning:', color_purple+'warning:'+color_default) + my_string = my_string.replace('note:', color_green+'note:'+color_default) + my_string = re.sub(r'([/\w_-]+\.\w+):', r'-COLORIN-\1-COLOROUT-:', my_string) + my_string = my_string.replace('-COLORIN-', color_yellow) + my_string = my_string.replace('-COLOROUT-', color_default) debug_lock.acquire() - print(myString) + print(my_string) debug_lock.release() +## +## @brief Get the list of default color +## @return A map with keys: "default","red","green","yellow","blue","purple","cyan" +## def get_color_set() : global color_default global color_red diff --git a/lutin/depend.py b/lutin/depend.py index 5035f90..1104396 100644 --- a/lutin/depend.py +++ b/lutin/depend.py @@ -41,6 +41,11 @@ def _file_read_data(path, binary=False): file.close() return data_file +## +## @brief Creata a dependency file with a list of files +## @param[in] depend_file (string) filename to store a dependency data +## @param[in] list_files ([string,...]) List of file that depend the current element +## def create_dependency_file(depend_file, list_files): data = "" for elem in list_files: @@ -48,6 +53,16 @@ def create_dependency_file(depend_file, list_files): _create_directory_of_file(depend_file) _file_write_data(depend_file, data) +## +## @brief Check if all dependency of a file and dependency file is correct or not +## @param[in] dst (string) File that will be generated +## @param[in] src (string) Source File needed to generate the 'dst' +## @param[in] depend_file (string) Dependency file that contain all file that the src depending +## @param[in] file_cmd (string) Filename of where is store the cmdline to generate the 'dst' +## @param[in] cmd_line (string) Command line that will be use to generate the 'dst' +## @param[in] force_identical (string) for copy file this check if the src and dst are identical +## @return (bool) True: something change ==> need to rebuild, False otherwise +## def need_re_build(dst, src, depend_file=None, file_cmd="", cmd_line="", force_identical=False): debug.extreme_verbose("Request check of dependency of :") debug.extreme_verbose(" dst='" + str(dst) + "'") @@ -142,7 +157,7 @@ def need_re_build(dst, src, depend_file=None, file_cmd="", cmd_line="", force_id file.close() # check the 2 files are identical: if force_identical == True: - # check if the 2 cmd_line are similar : + # check if the 2 cmd_line are similar: size_src = _file_size(src) size_dst = _file_size(dst) if size_src != size_dst: @@ -157,8 +172,15 @@ def need_re_build(dst, src, depend_file=None, file_cmd="", cmd_line="", force_id debug.extreme_verbose(" ==> Not rebuild (all dependency is OK)") return False - - +## +## @brief +## @param[in] dst (string) File that will be generated +## @param[in] src_list ([string,...]) Source file list needed to generate the 'dst' +## @param[in] must_have_src (bool) All sources must be present +## @param[in] file_cmd (string) Filename of where is store the cmdline to generate the 'dst' +## @param[in] cmd_line (string) Command line that will be use to generate the 'dst' +## @return (bool) True: Need to regenerate the package, False otherwise +## def need_re_package(dst, src_list, must_have_src, file_cmd="", cmd_line=""): debug.extreme_verbose("Request check of dependency of :") debug.extreme_verbose(" dst='" + str(dst) + "'") diff --git a/lutin/heritage.py b/lutin/heritage.py index ba619f5..32ee04f 100644 --- a/lutin/heritage.py +++ b/lutin/heritage.py @@ -151,6 +151,11 @@ class HeritageList: self.path[ppp].append(iii) debug.extreme_verbose("Path : " + str(self.path)) + ## + ## @brief Generate a string representing the class (for str(xxx)) + ## @param[in] self (handle) Class handle + ## @return (string) string of str() convertion + ## def __repr__(self): return "{HeritageList:" + str(self.list_heritage) + "}" @@ -169,19 +174,19 @@ class heritage: self.path = {} self.include = "" # update is set at true when data are newly created ==> force upper element to update - self.hasBeenUpdated=False + self.has_been_updated=False if type(module) != type(None): # all the parameter that the upper classe need when build - self.name = module.name - self.depends = copy.deepcopy(module.depends) + self.name = module.get_name() + self.depends = copy.deepcopy(module.get_depends()) # keep reference because the flags can change in time - self.flags = module.flags["export"] # have no deep copy here is a feature ... - self.path = copy.deepcopy(module.path["export"]) + self.flags = module._flags["export"] # have no deep copy here is a feature ... + self.path = copy.deepcopy(module._path["export"]) # if the user install some header ==> they will ba autoamaticaly exported ... if target != None: - if len(module.header) > 0: - self.include = target.get_build_path_include(module.name) + if len(module._header) > 0: + self.include = target.get_build_path_include(module.get_name()) def add_depends(self, elements): self.depends.append(elements) @@ -218,14 +223,14 @@ class heritage: self.path['c'].append(self.include) def need_update(self, list): - self.hasBeenUpdated=True + self.has_been_updated=True def add_sub(self, other): if type(other) == type(None): debug.verbose("input of the heriatege class is None !!!") return - if other.hasBeenUpdated == True: - self.hasBeenUpdated = True + if other.has_been_updated == True: + self.has_been_updated = True for flags in other.flags: value = other.flags[flags] if flags not in self.flags: @@ -247,6 +252,11 @@ class heritage: ver = self.flags["c++-version"] self.flags["c++-version"] = ver + ## + ## @brief Generate a string representing the class (for str(xxx)) + ## @param[in] self (handle) Class handle + ## @return (string) string of str() convertion + ## def __repr__(self): return "{Heritage:" + str(self.name) + " ... }" diff --git a/lutin/image.py b/lutin/image.py index bfdacd6..c3659b1 100644 --- a/lutin/image.py +++ b/lutin/image.py @@ -25,12 +25,25 @@ except: enable_resize_image = False debug.warning("Missing python tools : CoreGraphics (MacOs) or PIL") +## +## @brief Generate the upper pow 2 of the size in parameter +## @param[in] size (int) Size that might heve the upper pow(2) +## @return the new size in pow(2) +## def get_pow_2_multiple(size): base = 2 while size>base: base = base * 2 return base +## +## @brief Resize an image +## @param[in] src_file (string) Path of the source image file +## @param[in] dest_file (string) Path out the destination image file +## @param[in] x (int) Width of the image +## @param[in] y (int) Height of the image +## @param[in] cmd_file (string) Filename of where is store the cmdline to generate the 'dst' +## # TODO : 3 things to do : # check if force requested # check if time change diff --git a/lutin/module.py b/lutin/module.py index 921e2ef..23f6ab1 100644 --- a/lutin/module.py +++ b/lutin/module.py @@ -24,52 +24,59 @@ from . import image from . import license from . import env +## +## @brief Module class represent all system needed for a specific +## module like +## - type (bin/lib ...) +## - dependency +## - flags +## - files +## - ... +## class Module: - ## - ## @brief Module class represent all system needed for a specific - ## module like - ## - type (bin/lib ...) - ## - dependency - ## - flags - ## - files - ## - ... + ## @brief Contructor + ## @param[in] self (handle) Class handle + ## @param[in] file (string) Plugin file name (use __file__ to get it) + ## @param[in] module_name (string) Name of the module + ## @param[in] moduleType (string) Type of the module + ## @return None ## def __init__(self, file, module_name, moduleType): ## Remove all variable to prevent error of multiple deffinition of the module ... debug.verbose("Create a new module : '" + module_name + "' TYPE=" + moduleType) - self.origin_file='' - self.origin_path='' + self._origin_file='' + self._origin_path='' # type of the module: - self.type='LIBRARY' + self._type='LIBRARY' # Name of the module - self.name=module_name + self._name=module_name # Tools list: - self.tools = [] + self._tools = [] # Dependency list: - self.depends = [] + self._depends = [] # Dependency list (optionnal module): - self.depends_optionnal = [] - self.depends_find = [] + self._depends_optionnal = [] + self._depends_find = [] # Documentation list: - self.documentation = None + self._documentation = None # export PATH - self.path = {"export":{}, - "local":{} - } - self.flags = {"export":{}, + self._path = {"export":{}, "local":{} } - self.extention_order_build = ["java", "javah"] # all is not set here is done in the provided order ... + self._flags = {"export":{}, + "local":{} + } + self._extention_order_build = ["java", "javah"] # all is not set here is done in the provided order ... # sources list: - self.src = [] - self.header = [] + self._src = [] + self._header = [] # copy files and paths: - self.image_to_copy = [] - self.files = [] - self.paths = [] + self._image_to_copy = [] + self._files = [] + self._paths = [] # The module has been already build ... - self.isbuild = False + self._isbuild = False ## end of basic INIT ... if moduleType == 'BINARY' \ or moduleType == 'BINARY_SHARED' \ @@ -80,65 +87,102 @@ class Module: or moduleType == 'PACKAGE' \ or moduleType == 'PREBUILD' \ or moduleType == 'DATA': - self.type=moduleType + self._type=moduleType else : debug.error('for module "%s"' %module_name) debug.error(' ==> error : "%s" ' %moduleType) raise 'Input value error' - self.origin_file = file; - self.origin_path = tools.get_current_path(self.origin_file) - self.local_heritage = heritage.heritage(self, None) + self._origin_file = file; + self._origin_path = tools.get_current_path(self._origin_file) + self._local_heritage = None # TODO : Do a better dynamic property system => not really versatil - self.package_prop = { "COMPAGNY_TYPE" : "", - "COMPAGNY_NAME" : "", - "COMPAGNY_NAME2" : "", - "MAINTAINER" : [], - #"ICON" : set(""), - "SECTION" : [], - "PRIORITY" : "", - "DESCRIPTION" : "", - "VERSION" : [0,0,0], - "VERSION_CODE" : "", - "NAME" : "no-name", # name of the application - "ANDROID_MANIFEST" : "", # By default generate the manifest - "ANDROID_RESOURCES" : [], - "ANDROID_APPL_TYPE" : "APPL", # the other mode is "WALLPAPER" ... and later "WIDGET" - "ANDROID_WALLPAPER_PROPERTIES" : [], # To create properties of the wallpaper (no use of EWOL display) - "RIGHT" : [], - "LICENSE" : "", # by default: no license - "ADMOD_POSITION" : "top", - "ANDROID_SIGN" : "no_file.jks" - } - 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, - "ANDROID_SIGN" : True - } - self.sub_heritage_list = None - self.generate_file = [] + self._package_prop = { "COMPAGNY_TYPE" : "", + "COMPAGNY_NAME" : "", + "COMPAGNY_NAME2" : "", + "MAINTAINER" : [], + #"ICON" : set(""), + "SECTION" : [], + "PRIORITY" : "", + "DESCRIPTION" : "", + "VERSION" : [0,0,0], + "VERSION_CODE" : "", + "NAME" : "no-name", # name of the application + "ANDROID_MANIFEST" : "", # By default generate the manifest + "ANDROID_RESOURCES" : [], + "ANDROID_APPL_TYPE" : "APPL", # the other mode is "WALLPAPER" ... and later "WIDGET" + "ANDROID_WALLPAPER_PROPERTIES" : [], # To create properties of the wallpaper (no use of EWOL display) + "RIGHT" : [], + "LICENSE" : "", # by default: no license + "ADMOD_POSITION" : "top", + "ANDROID_SIGN" : "no_file.jks" + } + 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, + "ANDROID_SIGN" : True + } + self._sub_heritage_list = None + self._generate_file = [] + ## + ## @brief Generate a string representing the class (for str(xxx)) + ## @param[in] self (handle) Class handle + ## @return (string) string of str() convertion + ## def __repr__(self): - return "{lutin.Module:" + str(self.name) + "}" + return "{lutin.Module:" + str(self._name) + "}" + ## + ## @brief Get name of the module + ## @param[in] self (handle) Class handle + ## @return (string) Name of the current module + ## + def get_name(self): + return self._name + + ## + ## @brief Get type of the module ("BINARY", "LIBRARY", ...) + ## @param[in] self (handle) Class handle + ## @return (string) string with type of the @ref Module + ## def get_type(self): - return self.type + return self._type + + ## + ## @brief Get module dependency + ## @param[in] self (handle) Class handle + ## @return ([string,...]) List of module that depend on + ## + def get_depends(self): + return self._depends + + ## + ## @brief Get all header + ## @param[in] self (handle) Class handle + ## @return ([string,...]) List of module install header + ## + def get_header(self): + return self._header + ## ## @brief add Some copilation flags for this module (and only this one) + ## @param[in] self (handle) Class handle + ## @return None ## def add_extra_compile_flags(self): self.add_flag('c', [ @@ -155,6 +199,8 @@ class Module: ## ## @brief remove all unneeded warning on compilation ==> for extern libs ... + ## @param[in] self (handle) Class handle + ## @return None ## def remove_compile_warning(self): self.add_flag('c', [ @@ -167,18 +213,20 @@ class Module: ## ## @brief Send image in the build data directory - ## @param[in] target Target object - ## @param[in] copy_list When copy file, this API permit to remove unneeded files + ## @param[in] self (handle) Class handle + ## @param[in] target (handle) @ref lutin.target.Target class + ## @param[in] copy_list ([{},...]) When copy file, this API permit to remove unneeded files + ## @return None ## def image_to_build(self, target, copy_list): - for source, destination, sizeX, sizeY in self.image_to_copy: + for source, destination, sizeX, sizeY in self._image_to_copy: extension = source[source.rfind('.'):] if extension != ".png" \ and extension != ".jpg" \ and sizeX > 0: debug.error("Can not manage image other than .png and jpg to resize : " + source); display_source = source - source = self.origin_path + "/" + source + source = self._origin_path + "/" + source if destination == "": destination = source[source.rfind('/')+1:] debug.verbose("Regenerate Destination : '" + destination + "'") @@ -186,24 +234,26 @@ class Module: file_cmd = "" if sizeX > 0: debug.verbose("Image file : " + display_source + " ==> " + destination + " resize=(" + str(sizeX) + "," + str(sizeY) + ")") - fileName, fileExtension = os.path.splitext(os.path.join(self.origin_path,source)) - image.resize(source, os.path.join(target.get_build_path_data(self.name), destination), sizeX, sizeY, file_cmd) + fileName, fileExtension = os.path.splitext(os.path.join(self._origin_path,source)) + image.resize(source, os.path.join(target.get_build_path_data(self._name), destination), sizeX, sizeY, file_cmd) else: debug.verbose("Might copy file : " + display_source + " ==> " + destination) tools.copy_file(source, - os.path.join(target.get_build_path_data(self.name), destination), + os.path.join(target.get_build_path_data(self._name), destination), file_cmd, in_list=copy_list) ## ## @brief Send files in the build data directory - ## @param[in] target Target object - ## @param[in] copy_list When copy file, this API permit to remove unneeded files + ## @param[in] self (handle) Class handle + ## @param[in] target (handle) Target object + ## @param[in] copy_list ([{},...]) When copy file, this API permit to remove unneeded files + ## @return None ## def files_to_build(self, target, copy_list): - for source, destination in self.files: + for source, destination in self._files: display_source = source - source = os.path.join(self.origin_path, source) + source = os.path.join(self._origin_path, source) if destination == "": destination = source[source.rfind('/')+1:] debug.verbose("Regenerate Destination : '" + destination + "'") @@ -211,19 +261,21 @@ class Module: file_cmd = "" debug.verbose("Might copy file : " + display_source + " ==> " + destination) tools.copy_file(source, - os.path.join(target.get_build_path_data(self.name), destination), + os.path.join(target.get_build_path_data(self._name), destination), force_identical=True, in_list=copy_list) ## ## @brief Send compleate folder in the build data directory - ## @param[in] target Target object - ## @param[in] copy_list When copy file, this API permit to remove unneeded files + ## @param[in] self (handle) Class handle + ## @param[in] target (handle) Target object + ## @param[in] copy_list ([{},...]) When copy file, this API permit to remove unneeded files + ## @return None ## def paths_to_build(self, target, copy_list): - for source, destination in self.paths: + for source, destination in self._paths: debug.debug("Might copy path : " + source + "==>" + destination) - tmp_path = os.path.dirname(os.path.realpath(os.path.join(self.origin_path, source))) + tmp_path = os.path.dirname(os.path.realpath(os.path.join(self._origin_path, source))) tmp_rule = os.path.basename(source) for root, dirnames, filenames in os.walk(tmp_path): debug.extreme_verbose(" root='" + str(root) + "' tmp_path='" + str(tmp_path)) @@ -241,34 +293,39 @@ class Module: # TODO : maybe an error when changing subdirectory ... #if root[len(source)-1:] != "": # new_destination = os.path.join(new_destination, root[len(source)-1:]) - debug.verbose("Might copy : '" + os.path.join(root, cycle_file) + "' ==> '" + os.path.join(target.get_build_path_data(self.name), new_destination, cycle_file) + "'" ) + debug.verbose("Might copy : '" + os.path.join(root, cycle_file) + "' ==> '" + os.path.join(target.get_build_path_data(self._name), new_destination, cycle_file) + "'" ) file_cmd = "" # TODO : ... tools.copy_file(os.path.join(root, cycle_file), - os.path.join(target.get_build_path_data(self.name), new_destination, cycle_file), + os.path.join(target.get_build_path_data(self._name), new_destination, cycle_file), file_cmd, in_list=copy_list) - - + ## + ## @brief Process GCOV on the Current module + ## @param[in] self (handle) Class handle + ## @param[in] target (handle) Target object + ## @param[in] generate_output (bool) Generate the output gcov file of every library file (to debug wich branch is used) + ## @return None + ## def gcov(self, target, generate_output=False): - if self.type == 'PREBUILD': - debug.error("Can not generate gcov on prebuid system ... : '" + self.name + "'"); + if self._type == 'PREBUILD': + debug.error("Can not generate gcov on prebuid system ... : '" + self._name + "'"); return # list of path that can apear in the output data : gcov_path_file = [] - gcov_path_file.append(target.get_build_path_include(self.name)) # for include (that is installed) - gcov_path_file.append(" " + target.get_build_path_include(self.name)) - gcov_path_file.append(self.origin_path) # for sources. - gcov_path_file.append(" " + self.origin_path) + gcov_path_file.append(target.get_build_path_include(self._name)) # for include (that is installed) + gcov_path_file.append(" " + target.get_build_path_include(self._name)) + gcov_path_file.append(self._origin_path) # for sources. + gcov_path_file.append(" " + self._origin_path) # squash header and src... full_list_file = [] - for elem in self.header: + for elem in self._header: debug.extreme_verbose("plop H : " +str(elem['src'])) - full_list_file.append([self.name, elem['src']]) - for elem in self.src: + full_list_file.append([self._name, elem['src']]) + for elem in self._src: debug.extreme_verbose("plop S : " +str(elem)) - full_list_file.append([self.name, elem]) - for mod_name in self.tools: + full_list_file.append([self._name, elem]) + for mod_name in self._tools: tool_module = load_module(target, mod_name) if tool_module == None: continue @@ -278,14 +335,14 @@ class Module: for elem in tool_module.src: debug.extreme_verbose("plop SS: " + tool_module.name + ":" + str(elem)) full_list_file.append([tool_module.name, elem]) - debug.extreme_verbose("plop F : " +str(self.extention_order_build)) + debug.extreme_verbose("plop F : " +str(self._extention_order_build)) # remove uncompilable elements: # TODO: list_file = tools.filter_extention(full_list_file, self.extention_order_build, True) list_file = full_list_file; global_list_file = "" for file in list_file: - debug.verbose(" gcov : " + self.name + " <== " + str(file)); - file_dst = target.get_full_name_destination(file[0], self.origin_path, file[1], "o") + debug.verbose(" gcov : " + self._name + " <== " + str(file)); + file_dst = target.get_full_name_destination(file[0], self._origin_path, file[1], "o") global_list_file += file_dst + " " cmd = "gcov" # specify the version of gcov we need to use @@ -329,7 +386,7 @@ class Module: last_file = last_file[:-1] if path_finder == False: remove_next = True - debug.verbose(" REMOVE: '" + str(elem[6:len(self.origin_path)+1]) + "' not in " + str(gcov_path_file)) + debug.verbose(" REMOVE: '" + str(elem[6:len(self._origin_path)+1]) + "' not in " + str(gcov_path_file)) continue continue if elem[:7] == "Aucune " \ @@ -363,11 +420,11 @@ class Module: # check if in source or header: in_source_file = False debug.verbose(" ??> Check: " + str(last_file)) - for elem_header in self.header: + for elem_header in self._header: debug.verbose(" ==> Check: " + str(elem_header['src'])) if elem_header['src'] == last_file: in_source_file = True - for elem_src in self.src: + for elem_src in self._src: debug.verbose(" ==> Check: " + str(elem_src)) if elem_src == last_file: in_source_file = True @@ -396,11 +453,11 @@ class Module: except ZeroDivisionError: pourcent = 0.0 # generate json file: - json_file_name = target.get_build_path(self.name) + "/" + self.name + "_coverage.json" + json_file_name = target.get_build_path(self._name) + "/" + self._name + "_coverage.json" debug.debug("generate json file : " + json_file_name) tmp_file = open(json_file_name, 'w') tmp_file.write('{\n') - tmp_file.write(' "lib-name":"' + self.name + '",\n') + tmp_file.write(' "lib-name":"' + self._name + '",\n') #tmp_file.write(' "coverage":"' + str(pourcent) + '",\n') tmp_file.write(' "executed":"' + str(executed_lines) + '",\n') tmp_file.write(' "executable":"' + str(executable_lines) + '",\n') @@ -421,38 +478,45 @@ class Module: tmp_file.flush() tmp_file.close() # print debug: - debug.print_element("coverage", self.name, ":", str(pourcent) + "% " + str(executed_lines) + "/" + str(executable_lines)) + debug.print_element("coverage", self._name, ":", str(pourcent) + "% " + str(executed_lines) + "/" + str(executable_lines)) return True + ## + ## @brief Build the current the module and install in staging path. + ## @param[in] self (handle) Class handle. + ## @param[in] target (handle) @ref lutin.target.Target object. + ## @param[in] package_name (string) Package name (not the module name). Used to know where to install element in the staging. + ## @return (handle) @ref lutin.heritage.heritage. + ## # call here to build the module def build(self, target, package_name): # ckeck if not previously build - if target.is_module_build(self.name) == True: - if self.sub_heritage_list == None: - self.local_heritage = heritage.heritage(self, target) - debug.warning("plop " + str(self.local_heritage)); - return copy.deepcopy(self.sub_heritage_list) + if target.is_module_build(self._name) == True: + if self._sub_heritage_list == None: + self._local_heritage = heritage.heritage(self, target) + debug.warning("plop " + str(self._local_heritage)); + return copy.deepcopy(self._sub_heritage_list) # create the package heritage - self.local_heritage = heritage.heritage(self, target) + self._local_heritage = heritage.heritage(self, target) if package_name==None \ - and ( self.type == 'BINARY' - or self.type == 'BINARY_SHARED' \ - or self.type == 'BINARY_STAND_ALONE' \ - or self.type == 'PACKAGE' ) : + and ( self._type == 'BINARY' + or self._type == 'BINARY_SHARED' \ + or self._type == 'BINARY_STAND_ALONE' \ + or self._type == 'PACKAGE' ) : # this is the endpoint binary ... - package_name = self.name + package_name = self._name else: pass # build dependency before list_sub_file_needed_to_build = [] - self.sub_heritage_list = heritage.HeritageList() + self._sub_heritage_list = heritage.HeritageList() # optionnal dependency : - for dep, option, export in self.depends_optionnal: + for dep, option, export in self._depends_optionnal: debug.verbose("try find optionnal dependency: '" + str(dep) + "'") inherit_list, isBuilt = target.build(dep, package_name, True) if isBuilt == True: - self.local_heritage.add_depends(dep); + self._local_heritage.add_depends(dep); # TODO : Add optionnal Flags ... # ==> do it really better ... if export == False: @@ -460,21 +524,21 @@ class Module: else: self.add_flag(option[0], option[1], export=True); # add at the heritage list : - self.sub_heritage_list.add_heritage_list(inherit_list) - for dep in self.depends: - debug.debug("module: '" + str(self.name) + "' request: '" + dep + "'") + self._sub_heritage_list.add_heritage_list(inherit_list) + for dep in self._depends: + debug.debug("module: '" + str(self._name) + "' request: '" + dep + "'") inherit_list = target.build(dep, package_name, False) # add at the heritage list : - self.sub_heritage_list.add_heritage_list(inherit_list) + self._sub_heritage_list.add_heritage_list(inherit_list) # do sub library action for automatic generating ... - local_type = self.type - if self.type == 'LIBRARY_DYNAMIC': + local_type = self._type + if self._type == 'LIBRARY_DYNAMIC': local_type = 'LIBRARY' - if self.type == 'LIBRARY_STATIC': + if self._type == 'LIBRARY_STATIC': local_type = 'LIBRARY' - if self.type == 'BINARY_SHARED': + if self._type == 'BINARY_SHARED': local_type = 'BINARY' - if self.type == 'BINARY_STAND_ALONE': + if self._type == 'BINARY_STAND_ALONE': local_type = 'BINARY' if local_type in target.action_on_state: for lvl in range(0,100): @@ -485,40 +549,40 @@ class Module: # ---------------------------------------------------- # -- Generic library help -- # ---------------------------------------------------- - package_version_string = tools.version_to_string(self.package_prop["VERSION"]); - if self.type == 'DATA': - debug.print_element("Data", self.name, "-", package_version_string) - elif self.type == 'PREBUILD': - debug.print_element("Prebuild", self.name, "-", package_version_string) - elif self.type == 'LIBRARY': - debug.print_element("Library", self.name, "-", package_version_string) - elif self.type == 'LIBRARY_DYNAMIC': - debug.print_element("Library(dynamic)", self.name, "-", package_version_string) - elif self.type == 'LIBRARY_STATIC': - debug.print_element("Library(static)", self.name, "-", package_version_string) - elif self.type == 'BINARY': - debug.print_element("Binary(auto)", self.name, "-", package_version_string) - elif self.type == 'BINARY_SHARED': - debug.print_element("Binary (shared)", self.name, "-", package_version_string) - elif self.type == 'BINARY_STAND_ALONE': - debug.print_element("Binary (stand alone)", self.name, "-", package_version_string) - elif self.type == 'PACKAGE': - debug.print_element("Package", self.name, "-", package_version_string) + package_version_string = tools.version_to_string(self._package_prop["VERSION"]); + if self._type == 'DATA': + debug.print_element("Data", self._name, "-", package_version_string) + elif self._type == 'PREBUILD': + debug.print_element("Prebuild", self._name, "-", package_version_string) + elif self._type == 'LIBRARY': + debug.print_element("Library", self._name, "-", package_version_string) + elif self._type == 'LIBRARY_DYNAMIC': + debug.print_element("Library(dynamic)", self._name, "-", package_version_string) + elif self._type == 'LIBRARY_STATIC': + debug.print_element("Library(static)", self._name, "-", package_version_string) + elif self._type == 'BINARY': + debug.print_element("Binary(auto)", self._name, "-", package_version_string) + elif self._type == 'BINARY_SHARED': + debug.print_element("Binary (shared)", self._name, "-", package_version_string) + elif self._type == 'BINARY_STAND_ALONE': + debug.print_element("Binary (stand alone)", self._name, "-", package_version_string) + elif self._type == 'PACKAGE': + debug.print_element("Package", self._name, "-", package_version_string) # list of all file to copy: copy_list={} # --------------------------------------------------------------------------- # -- install header (generated header files) -- # --------------------------------------------------------------------------- - generate_path = target.get_build_path_temporary_generate(self.name) - include_path = target.get_build_path_include(self.name) + generate_path = target.get_build_path_temporary_generate(self._name) + include_path = target.get_build_path_include(self._name) have_only_generate_file = False - if len(self.generate_file) > 0: + if len(self._generate_file) > 0: debug.debug("install GENERATED headers ...") - for elem_generate in self.generate_file: + for elem_generate in self._generate_file: ret_write = tools.file_write_data(os.path.join(generate_path, elem_generate["filename"]), elem_generate["data"], only_if_new=True) if ret_write == True: - debug.print_element("generate", self.name, "##", elem_generate["filename"]) + debug.print_element("generate", self._name, "##", elem_generate["filename"]) dst = os.path.join(include_path, elem_generate["filename"]) copy_list[dst] = {"src":os.path.join(generate_path, elem_generate["filename"]), "cmd_file":None, @@ -532,8 +596,8 @@ class Module: # -- install header (do it first for extern lib and gcov better interface) -- # --------------------------------------------------------------------------- debug.debug("install headers ...") - for file in self.header: - src_path = os.path.join(self.origin_path, file["src"]) + for file in self._header: + src_path = os.path.join(self._origin_path, file["src"]) if "multi-dst" in file: dst_path = os.path.join(include_path, file["multi-dst"]) tools.copy_anything(src_path, @@ -557,10 +621,10 @@ class Module: # --------------------------------------------------------------------------- # -- Sources compilation -- # --------------------------------------------------------------------------- - if self.type != 'PREBUILD': + if self._type != 'PREBUILD': # build local sources in a specific order: - for extention_local in self.extention_order_build: - list_file = tools.filter_extention(self.src, [extention_local]) + for 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] @@ -572,12 +636,12 @@ class Module: res_file = tmp_builder.compile(file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - path = self.path, - name = self.name, - basic_path = self.origin_path, - module_src = self.src) + self._sub_heritage_list, + flags = self._flags, + path = self._path, + name = self._name, + basic_path = self._origin_path, + module_src = self._src) if multithreading == False: multiprocess.pool_synchrosize() if res_file["action"] == "add": @@ -587,9 +651,9 @@ class Module: else: debug.error("an not do action for : " + str(res_file)) except ValueError: - debug.warning(" UN-SUPPORTED file format: '" + self.origin_path + "/" + file + "'") + debug.warning(" UN-SUPPORTED file format: '" + self._origin_path + "/" + file + "'") # now build the other : - list_file = tools.filter_extention(self.src, self.extention_order_build, invert=True) + 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] @@ -601,12 +665,12 @@ class Module: res_file = tmp_builder.compile(file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - path = self.path, - name = self.name, - basic_path = self.origin_path, - module_src = self.src) + self._sub_heritage_list, + flags = self._flags, + path = self._path, + name = self._name, + basic_path = self._origin_path, + module_src = self._src) if multithreading == False: multiprocess.pool_synchrosize() if res_file["action"] == "add": @@ -616,21 +680,21 @@ class Module: else: debug.error("an not do action for : " + str(res_file)) except ValueError: - debug.warning(" UN-SUPPORTED file format: '" + self.origin_path + "/" + file + "'") + debug.warning(" UN-SUPPORTED file format: '" + self._origin_path + "/" + file + "'") # when multiprocess availlable, we need to synchronize here ... multiprocess.pool_synchrosize() # ---------------------------------------------------- # -- Generation point -- # ---------------------------------------------------- - if self.type=='PREBUILD': - self.local_heritage.add_sources(self.src) - elif self.type == 'LIBRARY' \ - or self.type == 'LIBRARY_DYNAMIC' \ - or self.type == 'LIBRARY_STATIC': + if self._type=='PREBUILD': + self._local_heritage.add_sources(self._src) + elif self._type == 'LIBRARY' \ + or self._type == 'LIBRARY_DYNAMIC' \ + or self._type == 'LIBRARY_STATIC': res_file_out = [] - if self.type == 'LIBRARY' \ - or self.type == 'LIBRARY_STATIC': + if self._type == 'LIBRARY' \ + or self._type == 'LIBRARY_STATIC': try: tmp_builder = builder.get_builder_with_output("a"); list_file = tools.filter_extention(list_sub_file_needed_to_build, tmp_builder.get_input_type()) @@ -638,16 +702,16 @@ class Module: res_file = tmp_builder.link(list_file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = self.name, - basic_path = self.origin_path) - self.local_heritage.add_lib_static(res_file) + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path) + self._local_heritage.add_lib_static(res_file) except ValueError: debug.error(" UN-SUPPORTED link format: '.a'") if target.support_dynamic_link == True: - if self.type == 'LIBRARY' \ - or self.type == 'LIBRARY_DYNAMIC': + if self._type == 'LIBRARY' \ + or self._type == 'LIBRARY_DYNAMIC': 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()) @@ -655,11 +719,11 @@ class Module: res_file = tmp_builder.link(list_file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = self.name, - basic_path = self.origin_path) - self.local_heritage.add_lib_dynamic(res_file) + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path) + self._local_heritage.add_lib_dynamic(res_file) except ValueError: debug.error(" UN-SUPPORTED link format: '.so'/'.dynlib'/'.dll'") try: @@ -669,21 +733,21 @@ class Module: res_file = tmp_builder.link(list_file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = self.name, - basic_path = self.origin_path) - self.local_heritage.add_lib_interpreted('java', res_file) + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path) + self._local_heritage.add_lib_interpreted('java', res_file) except ValueError: debug.error(" UN-SUPPORTED link format: '.jar'") - elif self.type == 'BINARY' \ - or self.type == 'BINARY_SHARED' \ - or self.type == 'BINARY_STAND_ALONE': + elif self._type == 'BINARY' \ + or self._type == 'BINARY_SHARED' \ + or self._type == 'BINARY_STAND_ALONE': shared_mode = False if target.name == "Android": debug.warning("Android mode ...") # special case for android ... - for elem in self.sub_heritage_list.src['src']: + for elem in self._sub_heritage_list.src['src']: debug.warning(" " + elem[-4:]) if elem[-4:] == '.jar': # abstract GUI interface ... @@ -691,7 +755,7 @@ class Module: break; static_mode = True if target.support_dynamic_link == True: - if self.type == 'BINARY_SHARED': + if self._type == 'BINARY_SHARED': static_mode = False if shared_mode == True: try: @@ -700,12 +764,12 @@ class Module: res_file = tmp_builder.link(list_file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = self.name, - basic_path = self.origin_path, + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path, static = static_mode) - self.local_heritage.add_sources(res_file) + self._local_heritage.add_sources(res_file) except ValueError: debug.error(" UN-SUPPORTED link format: '.so'") try: @@ -715,11 +779,11 @@ class Module: res_file = tmp_builder.link(list_file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = self.name, - basic_path = self.origin_path) - self.local_heritage.add_sources(res_file) + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path) + self._local_heritage.add_sources(res_file) except ValueError: debug.error(" UN-SUPPORTED link format: '.jar'") else: @@ -728,14 +792,14 @@ class Module: res_file = tmp_builder.link(list_sub_file_needed_to_build, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = self.name, - basic_path = self.origin_path, + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path, static = static_mode) except ValueError: debug.error(" UN-SUPPORTED link format: '.bin'") - elif self.type == "PACKAGE": + elif self._type == "PACKAGE": if target.name == "Android": # special case for android wrapper: try: @@ -744,11 +808,11 @@ class Module: res_file = tmp_builder.link(list_file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = "lib" + self.name, - basic_path = self.origin_path) - self.local_heritage.add_sources(res_file) + self._sub_heritage_list, + flags = self._flags, + name = "lib" + self._name, + basic_path = self._origin_path) + self._local_heritage.add_sources(res_file) except ValueError: debug.error(" UN-SUPPORTED link format: '.so'") try: @@ -758,11 +822,11 @@ class Module: res_file = tmp_builder.link(list_file, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = self.name, - basic_path = self.origin_path) - self.local_heritage.add_sources(res_file) + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path) + self._local_heritage.add_sources(res_file) except ValueError: debug.error(" UN-SUPPORTED link format: '.jar'") else: @@ -771,16 +835,16 @@ class Module: res_file = tmp_builder.link(list_sub_file_needed_to_build, package_name, target, - self.sub_heritage_list, - flags = self.flags, - name = self.name, - basic_path = self.origin_path) + self._sub_heritage_list, + flags = self._flags, + name = self._name, + basic_path = self._origin_path) except ValueError: debug.error(" UN-SUPPORTED link format: 'binary'") - elif self.type == "DATA": + elif self._type == "DATA": debug.debug("Data package have noting to build... just install") else: - debug.error("Did not known the element type ... (impossible case) type=" + self.type) + debug.error("Did not known the element type ... (impossible case) type=" + self._type) # ---------------------------------------------------- # -- install data -- @@ -793,84 +857,146 @@ class Module: #real copy files tools.copy_list(copy_list) # remove unneded files (NOT folder ...) - tools.clean_directory(target.get_build_path_data(self.name), copy_list) + tools.clean_directory(target.get_build_path_data(self._name), copy_list) # create local heritage specification - self.local_heritage.auto_add_build_header() - self.sub_heritage_list.add_heritage(self.local_heritage) + self._local_heritage.auto_add_build_header() + self._sub_heritage_list.add_heritage(self._local_heritage) # ---------------------------------------------------- # -- create package -- # ---------------------------------------------------- - if self.type[:6] == 'BINARY' \ - or self.type == 'PACKAGE': + if self._type[:6] == 'BINARY' \ + or self._type == 'PACKAGE': if target.end_generate_package == True: # generate the package with his properties ... if target.name=="Android": - self.sub_heritage_list.add_heritage(self.local_heritage) - target.make_package(self.name, self.package_prop, os.path.join(self.origin_path, ".."), self.sub_heritage_list) + self._sub_heritage_list.add_heritage(self._local_heritage) + target.make_package(self._name, self._package_prop, os.path.join(self._origin_path, ".."), self._sub_heritage_list) else: - target.make_package(self.name, self.package_prop, os.path.join(self.origin_path, ".."), self.sub_heritage_list) + target.make_package(self._name, self._package_prop, os.path.join(self._origin_path, ".."), self._sub_heritage_list) # return local dependency ... - return copy.deepcopy(self.sub_heritage_list) + return copy.deepcopy(self._sub_heritage_list) + ## + ## @brief Clean the build environement (in build, staging) + ## @param[in] self (handle) Class handle + ## @param[in] target (handle) Target object + ## @return (bool) True if clean is done + ## # call here to clean the module def clean(self, target): - if self.type=='PREBUILD': + if self._type=='PREBUILD': # nothing to add ==> just dependence None return True - elif self.type=='LIBRARY' \ - or self.type=='LIBRARY_DYNAMIC' \ - or self.type=='LIBRARY_STATIC': + elif self._type=='LIBRARY' \ + or self._type=='LIBRARY_DYNAMIC' \ + or self._type=='LIBRARY_STATIC': # remove path of the lib ... for this targer - pathbuild = target.get_build_path(self.name) + pathbuild = target.get_build_path(self._name) debug.info("remove path : '" + pathbuild + "'") tools.remove_path_and_sub_path(pathbuild) return True - elif self.type=='BINARY' \ - or self.type=='PACKAGE': + elif self._type=='BINARY' \ + or self._type=='PACKAGE': # remove path of the lib ... for this targer - pathbuild = target.get_build_path(self.name) + pathbuild = target.get_build_path(self._name) debug.info("remove path : '" + pathbuild + "'") tools.remove_path_and_sub_path(pathbuild) - pathStaging = target.get_staging_path(self.name) + pathStaging = target.get_staging_path(self._name) debug.info("remove path : '" + pathStaging + "'") tools.remove_path_and_sub_path(pathStaging) return True - else: - debug.error("Dit not know the element type ... (impossible case) type=" + self.type) + debug.error("Dit not know the element type ... (impossible case) type=" + self._type) + return False + ## + ## @brief Add a tools in dependency + ## @param[in] self (handle) Class handle + ## @param[in] list ([string,...] or string) Name(s) of the tools + ## @return None + ## def add_tools(self, list): - tools.list_append_to(self.tools, list, True) + tools.list_append_to(self._tools, list, True) + ## + ## @brief Add a dependency on this module + ## @param[in] self (handle) Class handle + ## @param[in] list ([string,...] or string) Name(s) of the modules dependency + ## @return None + ## def add_module_depend(self, list): - tools.list_append_to(self.depends, list, True) + tools.list_append_to(self._depends, list, True) + ## + ## @brief Add an optionnal dependency on this module + ## @param[in] self (handle) Class handle + ## @param[in] module_name (string) Name of the optionnal dependency + ## @param[in] compilation_flags ([string,string]) flag to add if dependency if find. + ## @param[in] export (bool) export the flat that has been requested to add if module is present. + ## @return None + ## def add_optionnal_module_depend(self, module_name, compilation_flags=["", ""], export=False): - tools.list_append_and_check(self.depends_optionnal, [module_name, compilation_flags, export], True) + tools.list_append_and_check(self._depends_optionnal, [module_name, compilation_flags, export], True) - def add_path(self, list, type='c'): - tools.list_append_to_2(self.path["local"], type, list) + ## + ## @brief Add a path to include when build + ## @param[in] self (handle) Class handle + ## @param[in] list ([string,...] or string) List of path to include + ## @param[in] type (string) inclusion group name 'c', 'c++', 'java' ... + ## @param[in] export (bool) export the include path. + ## @return None + ## + def add_path(self, list, type='c', export=False): + if export == True: + tools.list_append_to_2(self._path["export"], type, list) + else: + tools.list_append_to_2(self._path["local"], type, list) + + ## @brief deprecated ... + ## @return None + def add_export_path(self, list, type='c'): + debug.warning("[" + self._name + "] add_export_path is deprecated ==> use add_path(xxx, yyy, export=True)") + self.add_path(list, type, export=True) + ## + ## @brief Add compilation flags + ## @param[in] self (handle) Class handle + ## @param[in] type (string) inclusion group name 'c', 'c++', 'java' ... + ## @param[in] list ([string,...] or string) List of path to include + ## @param[in] export (bool) export the flat that has been requested to add if module is present. + ## @return None + ## def add_flag(self, type, list, export=False): if export == True: - tools.list_append_to_2(self.flags["export"], type, list) + tools.list_append_to_2(self._flags["export"], type, list) else: - tools.list_append_to_2(self.flags["local"], type, list) + tools.list_append_to_2(self._flags["local"], type, list) - ## deprecated ... + ## @brief deprecated ... + ## @return None def add_export_flag(self, type, list): - debug.warning("add_export_flag is deprecated ==> use add_flag(xxx, yyy, export=True)") + debug.warning("[" + self._name + "] Add_export_flag is deprecated ==> use add_flag(xxx, yyy, export=True)") self.add_flag(type, list, export=True) - ## deprecated ... + ## @brief deprecated ... + ## @return None def compile_flags(self, type, list): - debug.warning("compile_flags is deprecated ==> use add_flag(xxx, yyy)") + debug.warning("[" + self._name + "] Compile_flags is deprecated ==> use add_flag(xxx, yyy)") self.add_flag(type, list) + ## + ## @brief Set the compilation version of the + ## @param[in] self (handle) Class handle + ## @param[in] compilator_type (string) type of compilator: ["c++", "c"] + ## @param[in] version (int) year of the C/C++ version [1989, 1990, 1999, 2003, 2011, 2014, 2017, ...] + ## @param[in] same_as_api (bool) export the vertion on the API (otherwise the API version is the lowest) + ## @param[in] gnu (bool) Force gnu interface + ## @return None + ## def compile_version(self, compilator_type, version, same_as_api=True, gnu=False): if compilator_type == "c++" \ or compilator_type == "C++": @@ -881,10 +1007,10 @@ class Module: api_version = 1999 if same_as_api == True: api_version = version - self.flags["local"]["c++-version"] = { "version":version, - "gnu":gnu - } - self.flags["export"]["c++-version"] = api_version + self._flags["local"]["c++-version"] = { "version":version, + "gnu":gnu + } + 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 CPP vesion for API"); elif compilator_type == "c" \ @@ -896,23 +1022,30 @@ class Module: api_version = 1999 if same_as_api == True: api_version = version - self.flags["local"]["c-version"] = { "version":version, - "gnu":gnu - } - self.flags["export"]["c-version"] = api_version + self._flags["local"]["c-version"] = { "version":version, + "gnu":gnu + } + 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)); + ## + ## @brief Add source file to compile + ## @param[in] self (handle) Class handle + ## @param[in] list ([string,...] or string) File(s) to compile + ## @return None + ## def add_src_file(self, list): - tools.list_append_to(self.src, list, True) + tools.list_append_to(self._src, list, True) ## ## @brief An an header file in the install directory - ## @param[in] list List of element that is needed to install (can be a list or a simple string) - ## @param[in,optional] destination_path Path to install the files (remove all the path of the file) - ## @param[in,optional] clip_path Remove a part of the path set in the list and install data in generic include path - ## @param[in,optional] recursive when use regexp in file list ==> we can add recursive property + ## @param[in] self (handle) Class handle + ## @param[in] list ([string,...] or string) List of element that is needed to install + ## @param[in] destination_path (string) Path to install the files (remove all the path of the file) + ## @param[in] clip_path (string) Remove a part of the path set in the list and install data in generic include path + ## @param[in] recursive (bool) when use regexp in file list ==> we can add recursive property ## ## @code ## my_module.add_header_file([ @@ -920,7 +1053,7 @@ class Module: ## 'include/ewol/context/context.h', ## ]) ## @endcode - ## Here the user need to acces to the file wrote: #include + ## Here the user need to acces to the file wrote: @code #include @endcode ## ## We can simplify it: ## @code @@ -930,7 +1063,7 @@ class Module: ## ], ## destination_path='ewol') ## @endcode - ## Here the user need to acces to the file wrote: #include ==> the internal path has been removed + ## Here the user need to acces to the file wrote: @code #include @endcode ==> the internal path has been removed ## ## An other way is: ## @code @@ -940,7 +1073,7 @@ class Module: ## ], ## clip_path='include') ## @endcode - ## Here the user need to acces to the file wrote: #include ==> it just remove the include data + ## Here the user need to acces to the file wrote: @code #include @endcode ==> it just remove the include data ## ## With a copy all methode: ## @code @@ -948,7 +1081,9 @@ class Module: ## 'include/*.h', ## recursive=True) ## @endcode - ## Here the user need to acces to the file wrote: #include ==> it just remove the include data + ## Here the user need to acces to the file wrote: @code #include @endcode ==> it just remove the include data + ## + ## @return None ## def add_header_file(self, list, destination_path=None, clip_path=None, recursive=False): if destination_path != None: @@ -1002,35 +1137,64 @@ class Module: new_list.append({"src":elem, "dst":out_elem, "recursive":recursive}) - tools.list_append_to(self.header, new_list, True) + tools.list_append_to(self._header, new_list, True) ## ## @brief Many library need to generate dynamic file configuration, use this to generat your configuration and add it in the include path - ## @param[in] data_file Data of the file that is generated - ## @param[in] destination_path Path where to install data - ## @param[in] install_element add the file in the include path and not only in the generate path + ## @param[in] self (handle) Class handle + ## @param[in] data_file (string) Data of the file that is generated + ## @param[in] destination_path (string) Path where to install data + ## @param[in] install_element (bool) add the file in the include path and not only in the generate path ## @note this does not rewrite the file if it is not needed + ## @return None ## def add_generated_header_file(self, data_file, destination_path, install_element=False): - self.generate_file.append({ + self._generate_file.append({ "data":data_file, "filename":destination_path, "install":install_element }); - def add_export_path(self, list, type='c'): - tools.list_append_to_2(self.path["export"], type, list) - + ## + ## @brief copy image in the module datas + ## @param[in] self (handle) Class handle + ## @param[in] source (string) Source filename of the image + ## @param[in] destination (string) Destination filename in the image + ## @param[in] sizeX (int) new image width + ## @param[in] sizeY (int) new image height + ## @return None + ## 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]) + ## + ## @brief Copy the file in the module datas + ## @param[in] self (handle) Class handle + ## @param[in] source (string) filename of the souce to copy + ## @param[in] destination (string) Destination path to install data + ## @return None + ## def copy_file(self, source, destination=''): - self.files.append([source, destination]) + self._files.append([source, destination]) + ## + ## @brief Copy the path in the module datas + ## @param[in] self (handle) Class handle + ## @param[in] source (string) path of the souce to copy + ## @param[in] destination (string) Destination path to install data + ## @return None + ## def copy_path(self, source, destination=''): - self.paths.append([source, destination]) + self._paths.append([source, destination]) - def print_list(self, description, input_list): + ## + ## @brief Print the list to help + ## @param[in] self (handle) Class handle + ## @param[in] description (string) main help string + ## @param[in] description ([string,...]) List of possibilities to display + ## @return None + ## + def _print_list(self, description, input_list): if type(input_list) == list: if len(input_list) > 0: print(' ' + str(description)) @@ -1040,38 +1204,48 @@ class Module: print(' ' + str(description)) print(' ' + str(input_list)) + ## + ## @brief Display help of the module (dump) + ## @param[in] self (handle) Class handle + ## @return None + ## def display(self): print('-----------------------------------------------') - print(' package : "' + self.name + "'") + print(' module : "' + self._name + "'") print('-----------------------------------------------') - print(' type:"' + str(self.type) + "'") - print(' file:"' + str(self.origin_file) + "'") - print(' path:"' + str(self.origin_path) + "'") + print(' type:"' + str(self._type) + "'") + print(' file:"' + str(self._origin_file) + "'") + print(' path:"' + str(self._origin_path) + "'") - self.print_list('depends',self.depends) - self.print_list('depends_optionnal', self.depends_optionnal) + self._print_list('depends',self._depends) + self._print_list('depends_optionnal', self._depends_optionnal) - for element in self.flags["local"]: - value = self.flags["local"][element] - self.print_list('flags "' + str(element) + '"', value) + for element in self._flags["local"]: + value = self._flags["local"][element] + self._print_list('flags "' + str(element) + '"', value) - for element in self.flags["export"]: - value = self.flags["export"][element] - self.print_list('flags export "' + str(element) + '"', value) + for element in self._flags["export"]: + value = self._flags["export"][element] + self._print_list('flags export "' + str(element) + '"', value) - self.print_list('src',self.src) - self.print_list('files',self.files) - self.print_list('paths',self.paths) - for element in self.path["local"]: - value = self.path["local"][element] - self.print_list('local path "' + str(element) + '" ' + str(len(value)), value) + self._print_list('src', self._src) + self._print_list('files', self._files) + self._print_list('paths', self._paths) + for element in self._path["local"]: + value = self._path["local"][element] + self._print_list('local path "' + str(element) + '" ' + str(len(value)), value) - for element in self.path["export"]: - value = self.path["export"][element] - self.print_list('export path "' + str(element) + '" ' + str(len(value)), value) - - return True + for element in self._path["export"]: + value = self._path["export"][element] + self._print_list('export path "' + str(element) + '" ' + str(len(value)), value) + ## + ## @brief Set packaging variables + ## @param[in] self (handle) Class handle + ## @param[in] variable (string) Variable to set: "COMPAGNY_TYPE", "COMPAGNY_NAME", "ICON", "MAINTAINER", "SECTION", "PRIORITY", "DESCRIPTION", "VERSION", "VERSION_CODE", "NAME", "ANDROID_MANIFEST", "ANDROID_JAVA_FILES", "RIGHT", "ANDROID_RESOURCES", "ANDROID_APPL_TYPE", "ADMOD_ID", "APPLE_APPLICATION_IOS_ID", "LICENSE", "ANDROID_SIGN", "ADMOD_POSITION" + ## @param[in] value (string) Value assiciated at the package + ## @return None + ## def pkg_set(self, variable, value): if "COMPAGNY_TYPE" == variable: # com : Commercial @@ -1085,23 +1259,23 @@ class Module: if value not in ["", "com", "net", "org", "gov", "mil", "edu", "pri", "museum"]: debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'") else: - self.package_prop[variable] = value - self.package_prop_default[variable] = False + self._package_prop[variable] = value + self._package_prop_default[variable] = False elif "COMPAGNY_NAME" == variable: - self.package_prop[variable] = value - self.package_prop_default[variable] = False + self._package_prop[variable] = value + self._package_prop_default[variable] = False val2 = value.lower() val2 = val2.replace(' ', '') val2 = val2.replace('-', '') val2 = val2.replace('_', '') - self.package_prop["COMPAGNY_NAME2"] = val2 - self.package_prop_default["COMPAGNY_NAME2"] = False + self._package_prop["COMPAGNY_NAME2"] = val2 + self._package_prop_default["COMPAGNY_NAME2"] = False elif "ICON" == variable: - self.package_prop[variable] = value - self.package_prop_default[variable] = False + self._package_prop[variable] = value + self._package_prop_default[variable] = False elif "MAINTAINER" == variable: - self.package_prop[variable] = value - self.package_prop_default[variable] = False + self._package_prop[variable] = value + self._package_prop_default[variable] = False elif "SECTION" == variable: # project section : (must be separate by coma # refer to : http://packages.debian.org/sid/ @@ -1113,16 +1287,16 @@ class Module: # mail math misc net news ocaml oldlibs otherosfs # perl php python ruby science shells sound tex # text utils vcs video virtual web x11 xfce zope ... - self.package_prop[variable] = value - self.package_prop_default[variable] = False + self._package_prop[variable] = value + self._package_prop_default[variable] = False elif "PRIORITY" == variable: #list = ["required","important","standard","optional","extra"] #if isinstance(value, list): if value not in ["required", "important", "standard", "optional", "extra"]: debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'") else: - self.package_prop[variable] = value - self.package_prop_default[variable] = False + self._package_prop[variable] = value + self._package_prop_default[variable] = False elif variable in ["DESCRIPTION", "VERSION", "VERSION_CODE", @@ -1136,34 +1310,56 @@ class Module: "APPLE_APPLICATION_IOS_ID", "LICENSE", "ANDROID_SIGN"]: - self.package_prop[variable] = value - self.package_prop_default[variable] = False + self._package_prop[variable] = value + self._package_prop_default[variable] = False elif "ADMOD_POSITION" == variable: if value in ["top", "bottom"]: - self.package_prop[variable] = value - self.package_prop_default[variable] = False + self._package_prop[variable] = value + self._package_prop_default[variable] = False else: debug.error("not know pkg element : '" + variable + "' with value : '" + value + "' must be [top|bottom]") else: debug.error("not know pkg element : '" + variable + "'") - def pkg_set_if_default(self, variable, value): - if self.package_prop_default[variable] == True: + ## + ## @brief set a package config only if the config has not be change + ## @param[in] self (handle) Class handle + ## @param[in] variable (string) Variable to set: show @ref pkg_set + ## @param[in] value (string) Value assiciated at the package + ## @return None + ## + def _pkg_set_if_default(self, variable, value): + if self._package_prop_default[variable] == True: self.pkg_set(variable, value) + ## + ## @brief add an element in tha package property + ## @param[in] self (handle) Class handle + ## @param[in] variable (string) Variable to set: show @ref pkg_set + ## @param[in] value (string) Value assiciated at the package + ## @return None + ## def pkg_add(self, variable, value): - if variable in self.package_prop: - self.package_prop[variable].append(value) + if variable in self._package_prop: + self._package_prop[variable].append(value) else: - self.package_prop[variable] = [value] + self._package_prop[variable] = [value] + ## + ## @brief Add an external project module + ## @param[in] self (handle) Class handle + ## @param[in] target (handle) @ref lutin.target.Target handle + ## @param[in] projectMng (string) name of the project manager + ## @param[in] added_module ([string,...]) Modules to add + ## @return None + ## def ext_project_add_module(self, target, projectMng, added_module = []): - if self.name in added_module: + if self._name in added_module: return - added_module.append(self.name) - debug.verbose("add a module to the project generator :" + self.name) - debug.verbose("local path :" + self.origin_path) - projectMng.add_files(self.name, self.origin_path, self.src) + added_module.append(self._name) + debug.verbose("add a module to the project generator :" + self._name) + debug.verbose("local path :" + self._origin_path) + projectMng.add_files(self._name, self._origin_path, self._src) #projectMng.add_data_file(self.origin_path, self.files) #projectMng.add_data_path(self.origin_path, self.paths) """ @@ -1171,16 +1367,28 @@ class Module: target.project_add_module(depend, projectMng, added_module) """ + ## + ## @brief Create a project for external build environement + ## @param[in] self (handle) Class handle + ## @param[in] target (handle) @ref lutin.target.Target handle + ## @param[in] projectMng (string) name of the project manager + ## @return None + ## def create_project(self, target, projectMng): - projectMng.set_project_name(self.name) + projectMng.set_project_name(self._name) self.ext_project_add_module(target, projectMng) projectMng.generate_project_file() -module_list=[] +__module_list=[] __start_module_name="_" +## +## @brief Import all File that start with env.get_build_system_base_name() + __start_module_name + XXX and register in the list of modules +## @param[in] path_list List of file that start with env.get_build_system_base_name() in the running worktree (Parse one time ==> faster) +## @return None +## def import_path(path_list): - global module_list + global __module_list global_base = env.get_build_system_base_name() debug.debug("MODULE: Init with Files list:") for elem in path_list: @@ -1198,21 +1406,33 @@ def import_path(path_list): # Remove local patern module_name = filename[len(__start_module_name):] debug.verbose("MODULE: Integrate: '" + module_name + "' from '" + elem + "'") - module_list.append([module_name, elem]) + __module_list.append([module_name, elem]) debug.verbose("New list module: ") - for elem in module_list: + for elem in __module_list: debug.verbose(" " + str(elem[0])) +## +## @brief Check if a module exist +## @param[in] target (handle) @ref lutin.target.Target handle +## @param[in] name (string) Name of the module +## @return (bool) Existance of the module in worktree +## def exist(target, name): - global module_list - for mod in module_list: + global __module_list + for mod in __module_list: if mod[0] == name: return True return False +## +## @brief Load a module for a spefic @ref lutin.target.Target +## @param[in] target (handle) @ref lutin.target.Target handle +## @param[in] name (string) Name of the module +## @return (handle) @ref Module handle +## def load_module(target, name): - global module_list - for mod in module_list: + global __module_list + for mod in __module_list: if mod[0] == name: sys.path.append(os.path.dirname(mod[1])) debug.verbose("import module : '" + env.get_build_system_base_name() + __start_module_name + name + "'") @@ -1226,19 +1446,19 @@ def load_module(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"]) + 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"]) + tmp_element._pkg_set_if_default("COMPAGNY_NAME", property["compagny-name"]) if property["maintainer"] != None: - tmp_element.pkg_set_if_default("MAINTAINER", property["maintainer"]) + tmp_element._pkg_set_if_default("MAINTAINER", property["maintainer"]) if property["name"] != None: - tmp_element.pkg_set_if_default("NAME", property["name"]) + tmp_element._pkg_set_if_default("NAME", property["name"]) if property["description"] != None: - tmp_element.pkg_set_if_default("DESCRIPTION", property["description"]) + tmp_element._pkg_set_if_default("DESCRIPTION", property["description"]) if property["license"] != None: - tmp_element.pkg_set_if_default("LICENSE", property["license"]) + tmp_element._pkg_set_if_default("LICENSE", property["license"]) if property["version"] != None: - tmp_element.pkg_set_if_default("VERSION", property["version"]) + tmp_element._pkg_set_if_default("VERSION", property["version"]) else: debug.warning(" no function 'create' in the module : " + mod[0] + " from:'" + mod[1] + "'") continue @@ -1264,23 +1484,37 @@ def load_module(target, name): target.add_module(tmp_element) return tmp_element +## +## @brief List all module name +## @return ([string,...]) List of all module names +## def list_all_module(): - global module_list + global __module_list tmpListName = [] - for mod in module_list: + for mod in __module_list: tmpListName.append(mod[0]) return tmpListName +## +## @brief List all module name whith their desc +## @return ([...,...]) List of all module option @ref get_module_option() +## def list_all_module_with_desc(): - global module_list + global __module_list tmpList = [] - for mod in module_list: + for mod in __module_list: sys.path.append(os.path.dirname(mod[1])) the_module = __import__(env.get_build_system_base_name() + __start_module_name + mod[0]) tmpList.append(get_module_option(the_module, mod[0])) return tmpList +## +## @brief Get a specific module options +## @param[in] the_module (handle) @ref Module handle +## @param[in] name (string) Name of the module +## @return a Map with the keys: "name", "description", "type", "sub-type", "license", "compagny-type", "compagny-name", "maintainer", "version", "version-id" +## def get_module_option(the_module, name): type = None sub_type = None diff --git a/lutin/system.py b/lutin/system.py index ff0845b..e49b0bc 100644 --- a/lutin/system.py +++ b/lutin/system.py @@ -18,7 +18,9 @@ from . import debug from . import module from . import tools from . import env - +## +## @brief System class represent the pre-build Module that are already install and accessible in the system environment +## class System: def __init__(self): self.valid=False; @@ -59,6 +61,11 @@ class System: "clip":clip_path, "recursive":recursive }) + ## + ## @brief Generate a string representing the class (for str(xxx)) + ## @param[in] self (handle) Class handle + ## @return (string) string of str() convertion + ## def __repr__(self): return "{lutin.System}" @@ -75,7 +82,7 @@ def create_module_from_system(target, dict): # add exporting sources myModule.add_src_file(dict["system"].export_src) # add export path - myModule.add_export_path(dict["system"].export_path) + myModule.add_path(dict["system"].export_path, export=True) # Export all actions ... for elem in dict["system"].action_on_state: level, name, action = dict["system"].action_on_state[elem] @@ -98,6 +105,10 @@ def create_module_from_system(target, dict): system_list={} __start_system_name="System_" +## +## @brief Import all File that start with env.get_build_system_base_name() + __start_system_name + XXX and register in the list of System +## @param[in] path_list ([string,...]) List of file that start with env.get_build_system_base_name() in the running worktree (Parse one time ==> faster) +## def import_path(path_list): global system_list global_base = env.get_build_system_base_name() @@ -138,7 +149,9 @@ def import_path(path_list): for val in system_list[elem]: debug.verbose(" " + str(val["name"])) - +## +## @brief Display all the system binary that can be used +## def display(): global system_list for elementName in system_list: @@ -146,6 +159,13 @@ def display(): for data in system_list[elementName]: debug.info("SYSTEM: '" + data["name"] +"' in " + data["path"]) +## +## @brief Check if a library is availlable for a specific target +## @param[in] lib_name (string) Name of the Library +## @param[in] target_name (string) Name of the target +## @param[in] target (handle) Handle on the @ref Target build engine +## @return +## def exist(lib_name, target_name, target) : global system_list debug.verbose("exist= " + lib_name + " in " + target_name) diff --git a/lutin/target.py b/lutin/target.py index 19625a8..42935c8 100644 --- a/lutin/target.py +++ b/lutin/target.py @@ -21,7 +21,9 @@ from . import module from . import system from . import multiprocess from . import env - +## +## @brief Target class represent the buyild environement for a specific platform like Linux, or Android .... +## class Target: def __init__(self, name, config, arch): self.config = config @@ -170,6 +172,11 @@ class Target: # special case for IOS (example) no build dynamicly ... self.support_dynamic_link = True + ## + ## @brief Generate a string representing the class (for str(xxx)) + ## @param[in] self (handle) Class handle + ## @return (string) string of str() convertion + ## def __repr__(self): return "{lutin.Target}" @@ -434,12 +441,12 @@ class Target: return False def add_module(self, newModule): - debug.debug("Add nodule for Taget : " + newModule.name) + debug.debug("Add nodule for Taget : " + newModule.get_name()) self.module_list.append(newModule) def get_module(self, name): for mod in self.module_list: - if mod.name == name: + if mod.get_name() == name: return mod debug.error("the module '" + str(name) + "'does not exist/already build") return None @@ -455,21 +462,21 @@ class Target: def build_tree(self, name, packagesName): for mod in self.module_list: - if mod.name == name: + if mod.get_name() == name: mod.build_tree(self, packagesName) return debug.error("request to build tree on un-existant module name : '" + name + "'") def clean(self, name): for mod in self.module_list: - if mod.name == name: + if mod.get_name() == name: mod.clean(self) return debug.error("request to clean an un-existant module name : '" + name + "'") def load_if_needed(self, name, optionnal=False): for elem in self.module_list: - if elem.name == name: + if elem.get_name() == name: return True # try to find in the local Modules: exist = module.exist(self, name) @@ -491,7 +498,7 @@ class Target: def project_add_module(self, name, projectMng, addedModule): for mod in self.module_list: - if mod.name == name: + if mod.get_name() == name: mod.ext_project_add_module(self, projectMng, addedModule) return @@ -578,7 +585,8 @@ class Target: ret = [heritage.HeritageList(), False] else: for mod in self.module_list: - if mod.name == module_name: + debug.verbose("compare " + mod.get_name() + " == " + module_name) + if mod.get_name() == module_name: if action_name[:4] == "dump": debug.info("dump module '" + module_name + "'") if len(action_name) > 4: @@ -863,7 +871,10 @@ class Target: target_list=[] __start_target_name="Target_" - +## +## @brief Import all File that start with env.get_build_system_base_name() + __start_target_name + XXX and register in the list of Target +## @param[in] path_list ([string,...]) List of file that start with env.get_build_system_base_name() in the running worktree (Parse one time ==> faster) +## def import_path(path_list): global target_list global_base = env.get_build_system_base_name() @@ -888,6 +899,9 @@ def import_path(path_list): for elem in target_list: debug.verbose(" " + str(elem[0])) +## +## @brief +## def load_target(name, config): global target_list debug.debug("load target: " + name)