diff --git a/lutin/depend.py b/lutin/depend.py index 7aecfb0..1b50f2d 100644 --- a/lutin/depend.py +++ b/lutin/depend.py @@ -11,6 +11,18 @@ import os from . import debug from . import env +def _create_directory_of_file(file): + path = os.path.dirname(file) + try: + os.stat(path) + except: + os.makedirs(path) + +def _file_write_data(path, data): + file = open(path, "w") + file.write(data) + file.close() + def _file_size(path): if not os.path.isfile(path): return 0 @@ -28,6 +40,12 @@ def _file_read_data(path, binary=False): file.close() return data_file +def create_dependency_file(depend_file, list_files): + data = "" + for elem in list_files: + data += elem + "\n" + _create_directory_of_file(depend_file) + _file_write_data(depend_file, data) def need_re_build(dst, src, depend_file=None, file_cmd="", cmd_line="", force_identical=False): debug.extreme_verbose("Request check of dependency of :") @@ -47,14 +65,16 @@ def need_re_build(dst, src, depend_file=None, file_cmd="", cmd_line="", force_id and os.path.exists(dst) == False: debug.extreme_verbose(" ==> must rebuild (dst does not exist)") return True - if dst != "" \ - and dst != None \ + if src != "" \ + and src != None \ and os.path.exists(src) == False: debug.warning(" ==> unexistant file :'" + src + "'") return True # Check the basic date if the 2 files if dst != "" \ and dst != None \ + and src != "" \ + and src != None \ and os.path.getmtime(src) > os.path.getmtime(dst): debug.extreme_verbose(" ==> must rebuild (source time greater)") return True diff --git a/lutin/module.py b/lutin/module.py index df92c95..ea3e519 100644 --- a/lutin/module.py +++ b/lutin/module.py @@ -296,7 +296,6 @@ class Module: tmp_file.write(' }, {\n') val += 1 tmp_file.write(' "file":"' + elem[0] + '",\n') - #tmp_file.write(' "coverage":' + str(elem[1]) + ',\n') tmp_file.write(' "executed":' + str(elem[2]) + ',\n') tmp_file.write(' "executable":' + str(elem[3]) + '\n') tmp_file.write(' }\n') @@ -392,7 +391,8 @@ class Module: flags = self.flags, path = self.path, name = self.name, - basic_path = self.origin_path) + basic_path = self.origin_path, + module_src = self.src) if res_file["action"] == "add": list_sub_file_needed_to_build.append(res_file["file"]) elif res_file["action"] == "path": @@ -415,7 +415,8 @@ class Module: flags = self.flags, path = self.path, name = self.name, - basic_path = self.origin_path) + basic_path = self.origin_path, + module_src = self.src) if res_file["action"] == "add": list_sub_file_needed_to_build.append(res_file["file"]) elif res_file["action"] == "path": diff --git a/lutin/multiprocess.py b/lutin/multiprocess.py index 7254141..a945991 100644 --- a/lutin/multiprocess.py +++ b/lutin/multiprocess.py @@ -22,6 +22,7 @@ import shlex from . import debug from . import tools from . import env +from . import depend queueLock = threading.Lock() workQueue = queue.Queue() @@ -70,7 +71,7 @@ def run_command_direct(cmd_line): return False -def run_command(cmd_line, store_cmd_line="", build_id=-1, file="", store_output_file=""): +def run_command(cmd_line, store_cmd_line="", build_id=-1, file="", store_output_file="", depend_data=None): global errorOccured global exitFlag global currentIdExecution @@ -95,6 +96,8 @@ def run_command(cmd_line, store_cmd_line="", build_id=-1, file="", store_output_ if p.returncode == 0: debug.debug(env.print_pretty(cmd_line)) queueLock.acquire() + if depend_data != None: + depend.create_dependency_file(depend_data['file'], depend_data['data']) # TODO : Print the output all the time .... ==> to show warnings ... if build_id >= 0 and (output != "" or err != ""): debug.warning("output in subprocess compiling: '" + file + "'") @@ -163,7 +166,7 @@ class myThread(threading.Thread): cmdLine = data[1] cmdStoreFile = data[3] debug.print_element( "[" + str(data[4]) + "][" + str(self.thread_id) + "] " + comment[0], comment[1], comment[2], comment[3]) - run_command(cmdLine, cmdStoreFile, build_id=data[4], file=comment[3], store_output_file=data[5]) + run_command(cmdLine, cmdStoreFile, build_id=data[4], file=comment[3], store_output_file=data[5], depend_data=data[6]) else: debug.warning("unknow request command : " + data[0]) else: @@ -218,18 +221,18 @@ def un_init(): -def run_in_pool(cmd_line, comment, store_cmd_line="", store_output_file=""): +def run_in_pool(cmd_line, comment, store_cmd_line="", store_output_file="", depend_data=None): global currentIdExecution if processorAvaillable <= 1: debug.print_element(comment[0], comment[1], comment[2], comment[3]) - run_command(cmd_line, store_cmd_line, file=comment[3], store_output_file=store_output_file) + run_command(cmd_line, store_cmd_line, file=comment[3], store_output_file=store_output_file, depend_data=depend_data) return # multithreaded mode init() # Fill the queue queueLock.acquire() debug.verbose("add : in pool cmdLine") - workQueue.put(["cmdLine", cmd_line, comment, store_cmd_line, currentIdExecution, store_output_file]) + workQueue.put(["cmdLine", cmd_line, comment, store_cmd_line, currentIdExecution, store_output_file, depend_data]) currentIdExecution +=1; queueLock.release() diff --git a/lutin/z_builder/lutinBuilder_c.py b/lutin/z_builder/lutinBuilder_c.py index a86bdf0..07f17f4 100644 --- a/lutin/z_builder/lutinBuilder_c.py +++ b/lutin/z_builder/lutinBuilder_c.py @@ -40,7 +40,7 @@ def get_output_type(): ## ## @brief Commands for running gcc to compile a C file in object file. ## -def compile(file, binary, target, depancy, flags, path, name, basic_path): +def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src): file_src = target.get_full_name_source(basic_path, file) file_cmd = target.get_full_name_cmd(name, basic_path, file) file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type()) diff --git a/lutin/z_builder/lutinBuilder_cpp.py b/lutin/z_builder/lutinBuilder_cpp.py index d66c975..b670776 100644 --- a/lutin/z_builder/lutinBuilder_cpp.py +++ b/lutin/z_builder/lutinBuilder_cpp.py @@ -39,7 +39,7 @@ def get_output_type(): ## ## @brief Commands for running gcc to compile a C++ file in object file. ## -def compile(file, binary, target, depancy, flags, path, name, basic_path): +def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src): file_src = target.get_full_name_source(basic_path, file) file_cmd = target.get_full_name_cmd(name, basic_path, file) file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type()) diff --git a/lutin/z_builder/lutinBuilder_java.py b/lutin/z_builder/lutinBuilder_java.py index 364bed7..42254c7 100644 --- a/lutin/z_builder/lutinBuilder_java.py +++ b/lutin/z_builder/lutinBuilder_java.py @@ -33,15 +33,40 @@ def get_input_type(): def get_output_type(): return ["class"] +def create_dependency_files(target, src, heritage_src, basic_path): + depend = [] + for elem in src: + extention = elem.split('.')[-1] + if extention == 'jar' \ + or extention == 'java': + debug.extreme_verbose("add java depedence ... " + elem) + depend.append(target.get_full_name_source(basic_path, elem)) + + for elem in heritage_src: + extention = elem.split('.')[-1] + if extention == 'jar' \ + or extention == 'java': + debug.extreme_verbose("add java depedence ... " + elem) + depend.append(elem) + return depend + ## ## @brief Commands for running gcc to compile a C++ file in object file. ## -def compile(file, binary, target, depancy, flags, path, name, basic_path): +def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src): file_src = target.get_full_name_source(basic_path, file) file_cmd = target.get_full_name_cmd(name, basic_path, file) file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type(), remove_suffix=True) file_depend = target.get_full_dependency(name, basic_path, file) file_warning = target.get_full_name_warning(name, basic_path, file) + depend_files = create_dependency_files(target, module_src, depancy.src['src'], basic_path) + """ + debug.warning("file_src = " + file_src) + debug.warning("file_cmd = " + file_cmd) + debug.warning("file_dst = " + file_dst) + debug.warning("file_depend = " + file_depend) + debug.warning("file_warning = " + file_warning) + """ # create the command line befor requesting start: cmd = [ target.java, @@ -88,6 +113,11 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path): tools.create_directory_of_file(file_dst) comment = ["java", name, "<==", file] #process element - multiprocess.run_in_pool(cmdLine, comment, file_cmd, store_output_file=file_warning) + multiprocess.run_in_pool(cmdLine, + comment, + file_cmd, + store_output_file = file_warning, + depend_data = {"file":file_depend, + "data":depend_files}) return {"action":"add", "file":file_dst} diff --git a/lutin/z_builder/lutinBuilder_javah.py b/lutin/z_builder/lutinBuilder_javah.py index 207bbe5..ee73cc0 100644 --- a/lutin/z_builder/lutinBuilder_javah.py +++ b/lutin/z_builder/lutinBuilder_javah.py @@ -33,15 +33,33 @@ def get_input_type(): def get_output_type(): return ["h"] +def create_dependency_files(target, src, heritage_src, basic_path): + depend = [] + for elem in src: + extention = elem.split('.')[-1] + if extention == 'jar' \ + or extention == 'java': + debug.extreme_verbose("add java depedence ... " + elem) + depend.append(target.get_full_name_source(basic_path, elem)) + + for elem in heritage_src: + extention = elem.split('.')[-1] + if extention == 'jar' \ + or extention == 'java': + debug.extreme_verbose("add java depedence ... " + elem) + depend.append(elem) + return depend + ## ## @brief Commands for running gcc to compile a C++ file in object file. ## -def compile(file, binary, target, depancy, flags, path, name, basic_path): +def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src): # file_src = target.get_full_name_source(basic_path, file) file_cmd = target.get_full_name_cmd(name, basic_path, file) # file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type()) file_depend = target.get_full_dependency(name, basic_path, file) file_warning = target.get_full_name_warning(name, basic_path, file) + depend_files = create_dependency_files(target, module_src, depancy.src['src'], basic_path) # create the command line befor requesting start: cmd = [ target.javah, @@ -52,20 +70,25 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path): cmd.append("-verbose") cmd.append("-classpath") - cmd.append(target.get_build_path(name)) + cmd.append(target.get_build_path_object(name)) class_to_build = file[:-6] cmd.append(class_to_build) # Create cmd line - cmdLine=tools.list_to_str(cmd) + cmd_line = tools.list_to_str(cmd) - file_dst = target.get_build_path(name) + "/tmp_header/" + class_to_build.replace(".", "_") + ".h" + file_dst = target.get_build_path(name) + "/generate_header/" + class_to_build.replace(".", "_") + ".h" # check the dependency for this file : - #if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False: - # return file_dst + if depend.need_re_build(file_dst, None, file_depend, file_cmd, cmd_line) == False: + return {"action":"path", "path":target.get_build_path(name) + target.path_generate_code} #tools.create_directory_of_file(file_dst) comment = ["javah", class_to_build.replace(".", "_") + ".h", "<==", class_to_build] #process element - multiprocess.run_in_pool(cmdLine, comment, file_cmd, store_output_file=file_warning) + multiprocess.run_in_pool(cmd_line, + comment, + file_cmd, + store_output_file = file_warning, + depend_data = {"file":file_depend, + "data":depend_files}) debug.verbose("file= " + file_dst) #return file_dst return {"action":"path", "path":target.get_build_path(name) + target.path_generate_code} diff --git a/lutin/z_builder/lutinBuilder_m.py b/lutin/z_builder/lutinBuilder_m.py index d6199a1..d16a732 100644 --- a/lutin/z_builder/lutinBuilder_m.py +++ b/lutin/z_builder/lutinBuilder_m.py @@ -41,7 +41,7 @@ def get_output_type(): ## ## @brief Commands for running gcc to compile a m file in object file. ## -def compile(file, binary, target, depancy, flags, path, name, basic_path): +def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src): file_src = target.get_full_name_source(basic_path, file) file_cmd = target.get_full_name_cmd(name, basic_path, file) file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type()) diff --git a/lutin/z_builder/lutinBuilder_mm.py b/lutin/z_builder/lutinBuilder_mm.py index 5511a9e..98cdde7 100644 --- a/lutin/z_builder/lutinBuilder_mm.py +++ b/lutin/z_builder/lutinBuilder_mm.py @@ -41,7 +41,7 @@ def get_output_type(): ## ## @brief Commands for running gcc to compile a m++ file in object file. ## -def compile(file, binary, target, depancy, flags, path, name, basic_path): +def compile(file, binary, target, depancy, flags, path, name, basic_path, module_src): file_src = target.get_full_name_source(basic_path, file) file_cmd = target.get_full_name_cmd(name, basic_path, file) file_dst = target.get_full_name_destination(name, basic_path, file, get_output_type()) diff --git a/lutin/z_target/lutinTarget_Android.py b/lutin/z_target/lutinTarget_Android.py index a5d7d02..0166207 100644 --- a/lutin/z_target/lutinTarget_Android.py +++ b/lutin/z_target/lutinTarget_Android.py @@ -83,8 +83,8 @@ class Target(target.Target): #self.path_doc="/doc" #self.suffix_package='.pkg' - # board id at 14 is for android 4.0 and more ... - self.boardId = 14 + # board id at 15 is for android 4.0.3 and more ... (note: API 14 has been removed ...) + self.boardId = 15 self.global_flags_cc.append("-D__ANDROID_BOARD_ID__=" + str(self.boardId)) if arch == "armv5" or arch == "armv7": self.global_include_cc.append("-I" + self.path_ndk +"/platforms/android-" + str(self.boardId) + "/arch-arm/usr/include/")