diff --git a/bin/lutin b/bin/lutin index 35fbce8..46dca07 100755 --- a/bin/lutin +++ b/bin/lutin @@ -38,6 +38,7 @@ 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("K", "ccache", desc="Enable the ccache interface") myArgs.add_section("properties", "keep in the sequency of the cible") 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'") @@ -216,6 +217,13 @@ def parseGenericArg(argument, active): if active == True: env.set_parse_depth(int(argument.get_arg())) return True + elif argument.get_option_name()=="ccache": + if active == True: + if check_boolean(argument.get_arg()) == True: + env.set_ccache(True) + else: + env.set_ccache(False) + return True elif argument.get_option_name() == "verbose": if active == True: debug.set_level(int(argument.get_arg())) @@ -291,6 +299,11 @@ if os.path.isfile(config_file) == True: debug.debug(" get default config 'get_parsing_depth' val='" + str(data) + "'") parseGenericArg(arguments.ArgElement("depth", str(data)), True) + if "get_ccache" in dir(configuration_file): + data = configuration_file.get_ccache() + debug.debug(" get default config 'get_ccache' val='" + str(data) + "'") + parseGenericArg(arguments.ArgElement("ccache", str(data)), True) + if "get_default_jobs" in dir(configuration_file): data = configuration_file.get_default_jobs() debug.debug(" get default config 'get_default_jobs' val='" + str(data) + "'") diff --git a/lutin/env.py b/lutin/env.py index c29a3d2..0f444cf 100644 --- a/lutin/env.py +++ b/lutin/env.py @@ -112,6 +112,17 @@ def get_warning_mode(): global store_warning return store_warning +ccache=False +def set_ccache(val): + global ccache + if val == True: + ccache = True + else: + ccache = False + +def get_ccache(): + global ccache + return ccache def end_with(name, list): for appl in list: diff --git a/lutin/z_builder/lutinBuilder_binary.py b/lutin/z_builder/lutinBuilder_binary.py index 2c8dfb7..88ad6de 100644 --- a/lutin/z_builder/lutinBuilder_binary.py +++ b/lutin/z_builder/lutinBuilder_binary.py @@ -83,8 +83,12 @@ def link(file, binary, target, depancy, flags, name, basic_path, static = False) lib_name = elem[:-len(target.suffix_lib_static)] + target.suffix_lib_dynamic if lib_name not in depancy.src['dynamic']: list_static.append(elem) + # set ccache interface: + compilator_ccache = "" + if env.get_ccache() == True: + compilator_ccache = "ccache" #create comand line: - cmd = [] + cmd = [compilator_ccache] # a specific case to not depend on the libstdc++ automaticly added by the G++ or clang++ compilator ==> then need to compile with GCC or CLANG if use libcxx from llvm or other ... if "need-libstdc++" in depancy.flags \ and depancy.flags["need-libstdc++"] == True: diff --git a/lutin/z_builder/lutinBuilder_c.py b/lutin/z_builder/lutinBuilder_c.py index acc829b..4261193 100644 --- a/lutin/z_builder/lutinBuilder_c.py +++ b/lutin/z_builder/lutinBuilder_c.py @@ -15,6 +15,7 @@ from lutin import multiprocess from lutin import tools from lutin import debug from lutin import depend +from lutin import env # C version: default_version = 1989 @@ -65,8 +66,13 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module file_depend = target.get_full_dependency(name, basic_path, file) file_warning = target.get_full_name_warning(name, basic_path, file) + # set ccache interface: + compilator_ccache = "" + if env.get_ccache() == True: + compilator_ccache = "ccache" # create the command line befor requesting start: cmd = [ + compilator_ccache, target.cc, "-o", file_dst, target.arch, diff --git a/lutin/z_builder/lutinBuilder_cpp.py b/lutin/z_builder/lutinBuilder_cpp.py index 59e0916..091dbdf 100644 --- a/lutin/z_builder/lutinBuilder_cpp.py +++ b/lutin/z_builder/lutinBuilder_cpp.py @@ -15,6 +15,7 @@ from lutin import multiprocess from lutin import tools from lutin import debug from lutin import depend +from lutin import env # C++ default version: default_version = 1999 default_version_gnu = False @@ -64,8 +65,13 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module 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) + # set ccache interface: + compilator_ccache = "" + if env.get_ccache() == True: + compilator_ccache = "ccache" # create the command line befor requesting start: cmd = [ + compilator_ccache, target.xx, "-o", file_dst, target.arch, diff --git a/lutin/z_builder/lutinBuilder_libraryDynamic.py b/lutin/z_builder/lutinBuilder_libraryDynamic.py index 272470a..99fb9c1 100644 --- a/lutin/z_builder/lutinBuilder_libraryDynamic.py +++ b/lutin/z_builder/lutinBuilder_libraryDynamic.py @@ -86,8 +86,12 @@ def link(file, binary, target, depancy, flags, name, basic_path, static=False): lib_name = elem[:-len(target.suffix_lib_static)] + target.suffix_lib_dynamic if lib_name not in depancy.src['dynamic']: list_static.append(elem) + # set ccache interface: + compilator_ccache = "" + if env.get_ccache() == True: + compilator_ccache = "ccache" #create command Line - cmd = [] + cmd = [compilator_ccache] # a specific case to not depend on the libstdc++ automaticly added by the G++ or clang++ compilator ==> then need to compile with GCC or CLANG if use libcxx from llvm or other ... if "need-libstdc++" in depancy.flags \ and depancy.flags["need-libstdc++"] == True: diff --git a/lutin/z_builder/lutinBuilder_libraryStatic.py b/lutin/z_builder/lutinBuilder_libraryStatic.py index b264687..010120f 100644 --- a/lutin/z_builder/lutinBuilder_libraryStatic.py +++ b/lutin/z_builder/lutinBuilder_libraryStatic.py @@ -68,7 +68,12 @@ def link(file, binary, target, depancy, flags, name, basic_path): debug.extreme_verbose("file_cmd = " + file_cmd) debug.extreme_verbose("file_warning = " + file_warning) + # set ccache interface: + compilator_ccache = "" + if env.get_ccache() == True: + compilator_ccache = "ccache" cmd = [ + compilator_ccache, target.ar ] try: diff --git a/lutin/z_builder/lutinBuilder_m.py b/lutin/z_builder/lutinBuilder_m.py index d2306e5..045a18b 100644 --- a/lutin/z_builder/lutinBuilder_m.py +++ b/lutin/z_builder/lutinBuilder_m.py @@ -16,6 +16,7 @@ from lutin import tools from lutin import builder from lutin import debug from lutin import depend +from lutin import env local_ref_on_builder_c = None @@ -65,8 +66,13 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module 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) + # set ccache interface: + compilator_ccache = "" + if env.get_ccache() == True: + compilator_ccache = "ccache" # create the command line befor requesting start: cmd = [ + compilator_ccache, target.cc, "-o", file_dst , target.arch, diff --git a/lutin/z_builder/lutinBuilder_mm.py b/lutin/z_builder/lutinBuilder_mm.py index a1ce26b..048bca7 100644 --- a/lutin/z_builder/lutinBuilder_mm.py +++ b/lutin/z_builder/lutinBuilder_mm.py @@ -16,6 +16,7 @@ from lutin import tools from lutin import builder from lutin import debug from lutin import depend +from lutin import env local_ref_on_builder_cpp = None @@ -65,8 +66,13 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module 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) + # set ccache interface: + compilator_ccache = "" + if env.get_ccache() == True: + compilator_ccache = "ccache" # create the command line befor requesting start: cmd = [ + compilator_ccache, target.xx, "-o", file_dst, target.arch, diff --git a/lutin/z_builder/lutinBuilder_s.py b/lutin/z_builder/lutinBuilder_s.py index 9cc2475..b3d79fc 100644 --- a/lutin/z_builder/lutinBuilder_s.py +++ b/lutin/z_builder/lutinBuilder_s.py @@ -14,6 +14,7 @@ from lutin import multiprocess from lutin import tools from lutin import depend +from lutin import env ## ## Initialize the builder, if needed ... to get dependency between builder (for example) @@ -60,8 +61,13 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module file_depend = target.get_full_dependency(name, basic_path, file) file_warning = target.get_full_name_warning(name, basic_path, file) + # set ccache interface: + compilator_ccache = "" + if env.get_ccache() == True: + compilator_ccache = "ccache" # create the command line befor requesting start: cmd = [ + compilator_ccache, target.cc, "-o", file_dst, target.arch,