[DEV] update lutiun to support corectly multiple build model

This commit is contained in:
Edouard DUPIN 2022-01-12 00:04:08 +01:00
parent 9dc5218775
commit 64d016880e
19 changed files with 2203 additions and 1936 deletions

View File

@ -10,6 +10,18 @@ encoding//lutin/multiprocess.py=utf-8
encoding//lutin/system.py=utf-8
encoding//lutin/target.py=utf-8
encoding//lutin/tools.py=utf-8
encoding//lutin/z_builder/__init__.py=utf-8
encoding//lutin/z_builder/lutinBuilder_binary.py=utf-8
encoding//lutin/z_builder/lutinBuilder_c++.py=utf-8
encoding//lutin/z_builder/lutinBuilder_c.py=utf-8
encoding//lutin/z_builder/lutinBuilder_jar.py=utf-8
encoding//lutin/z_builder/lutinBuilder_java.py=utf-8
encoding//lutin/z_builder/lutinBuilder_javah.py=utf-8
encoding//lutin/z_builder/lutinBuilder_libraryDynamic.py=utf-8
encoding//lutin/z_builder/lutinBuilder_libraryStatic.py=utf-8
encoding//lutin/z_builder/lutinBuilder_m.py=utf-8
encoding//lutin/z_builder/lutinBuilder_mm.py=utf-8
encoding//lutin/z_builder/lutinBuilder_s.py=utf-8
encoding//lutin/z_system/lutinSystem_Android_c.py=utf-8
encoding//lutin/z_system/lutinSystem_Android_cxx.py=utf-8
encoding//lutin/z_system/lutinSystem_Android_m.py=utf-8
@ -19,10 +31,12 @@ encoding//lutin/z_system/lutinSystem_Linux_alsa.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_c.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_cxx.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_egl.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_khr.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_m.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_mysql.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_opengl.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_pthread.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_rt.py=utf-8
encoding//lutin/z_system/lutinSystem_Linux_z.py=utf-8
encoding//lutin/z_system/lutinSystem_MacOs_Cocoa.py=utf-8
encoding//lutin/z_system/lutinSystem_Windows_ole.py=utf-8
@ -35,3 +49,4 @@ encoding//lutin/z_target/lutinTarget_Debian.py=utf-8
encoding//lutin/z_target/lutinTarget_IOs.py=utf-8
encoding//lutin/z_target/lutinTarget_MacOs.py=utf-8
encoding//lutin/z_target/lutinTarget_Windows.py=utf-8
encoding//lutin/zip.py=utf-8

View File

@ -62,9 +62,10 @@ def import_path(path_list):
debug.verbose("BUILDER: Integrate: '" + builder_name + "' from '" + elem + "'")
the_builder = __import__(base_file_name)
builder_list.append({"name":builder_name,
"order":the_builder.get_order(),
"element":the_builder
})
debug.debug('BUILDER: type=' + the_builder.get_type() + " in=" + str(the_builder.get_input_type()) + " out=" + str(the_builder.get_output_type()))
debug.debug('BUILDER: type=' + the_builder.get_type() + " order=" + str(the_builder.get_order()) + " in=" + str(the_builder.get_input_type()) + " out=" + str(the_builder.get_output_type()))
debug.verbose("List of BUILDER: ")
for elem in builder_list:
debug.verbose(" " + str(elem["name"]))
@ -81,8 +82,8 @@ def init():
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
## @brief Get a builder tool with specifying the input type (like cpp, S ...)
## @param[in] input_type (string) extension file that can be compile
##
def get_builder(input_type):
global builder_list
@ -93,10 +94,59 @@ def get_builder(input_type):
# we can not find the builder ...
debug.error("Can not find builder for type : '" + str(input_type) + "'")
raise ValueError('type error :' + str(input_type))
##
## @brief Get a builder tool with his name
## @param[in] name (string) name of the builder
##
def get_builder_named(name):
global builder_list
for element in builder_list:
if element["name"] == name:
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))
##
## @brief Get a builder tool with specifiying the output type (like .exe, .jar ...)
## @param[in] input_type (string) extention file that can be generated
## @brief get all the builder with extension to detect automaticly mode to compile
## @return a map with the key name of the builder, and a table of extension files
##
def get_full_builder_extention():
global builder_list
out = {};
for element in builder_list:
if element["element"] != None:
out[element["name"]] = element["element"].get_input_type();
return out;
##
## @brief get all the builder in the common order build
## @return a list with the ordered builder names
##
def get_ordered_builder_list():
global builder_list
table = {};
for element in builder_list:
table[element["order"]] = element["name"];
out = []
for key in sorted(table.keys()):
out.append(table[key]);
debug.extreme_verbose("builder ordered=" + str(table));
debug.extreme_verbose(" ==> " + str(out));
return out;
def find_builder_with_input_extention(extension):
extention_map = get_full_builder_extention();
for builder_name in get_ordered_builder_list():
debug.extreme_verbose("builder_name: " + str(extension) + " in " + str(extention_map[builder_name]));
if extension in extention_map[builder_name]:
return builder_name;
debug.warning("does not find the builder: for extension: " + str(extension))
return "?";
##
## @brief Get a builder tool with specifying the output type (like .exe, .jar ...)
## @param[in] input_type (string) extension file that can be generated
##
def get_builder_with_output(output_type):
global builder_list

View File

@ -88,10 +88,10 @@ class Module:
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._ordered_builder = builder.get_ordered_builder_list();##### TODO: remove this :["java", "javah"] # all is not set here is done in the provided order ...
# sources list with the type of files (auto_detected if not specified (c/c++/java/javah/asm/...):
self._src = {}
self._header = {}
# copy files and paths:
self._image_to_copy = []
self._files = []
@ -401,11 +401,13 @@ class Module:
gcov_path_file.append(" " + self._origin_path)
# squash header and src...
full_list_file = []
for elem in self._header:
debug.extreme_verbose("plop H : " +str(elem['src']))
for key in self._header.keys():
for elem in self._header[key]:
debug.extreme_verbose("plop H : " + str(key) + "->" + str(elem['src']))
full_list_file.append([self._name, elem['src']])
for elem in self._src:
debug.extreme_verbose("plop S : " +str(elem))
for key in self._src.keys():
for elem in self._src[key]:
debug.extreme_verbose("plop S : " + str(key) + "->" + str(elem))
full_list_file.append([self._name, elem])
for mod_name in self._tools:
tool_module = load_module(target, mod_name)
@ -417,7 +419,7 @@ 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._ordered_builder))
# remove uncompilable elements:
# TODO: list_file = tools.filter_extention(full_list_file, self.extention_order_build, True)
list_file = full_list_file;
@ -502,11 +504,13 @@ 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 key_header in self._header.key():
for elem_header in self._header[key_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 key_src in self._src.keys():
for elem_src in self._src[key_src]:
debug.verbose(" ==> Check: " + str(elem_src))
if elem_src == last_file:
in_source_file = True
@ -723,13 +727,16 @@ class Module:
if self._type != 'PREBUILD' \
and self._type != 'PACKAGE':
# 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 file in list_file:
#debug.info(" " + self.name + " <== " + file);
for builder_name in self._ordered_builder:
debug.warning("Execute builder : " + builder_name);
if builder_name not in self._src.keys():
debug.warning(" ==> nothing to do...");
continue;
for file in self._src[builder_name]:
debug.info(" " + self._name + " <== " + file);
fileExt = file.split(".")[-1]
try:
tmp_builder = builder.get_builder(fileExt);
tmp_builder = builder.get_builder_named(builder_name);
multithreading = tmp_builder.get_support_multithreading()
if multithreading == False:
multiprocess.pool_synchrosize()
@ -753,35 +760,12 @@ class Module:
except ValueError:
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)
for file in list_file:
#debug.info(" " + self.name + " <== " + file);
fileExt = file.split(".")[-1]
try:
tmp_builder = builder.get_builder(fileExt)
multithreading = tmp_builder.get_support_multithreading()
if multithreading == False:
multiprocess.pool_synchrosize()
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)
if multithreading == False:
multiprocess.pool_synchrosize()
if res_file["action"] == "add":
list_sub_file_needed_to_build.append(res_file["file"])
elif res_file["action"] == "path":
self._add_path(res_file["path"], type='c')
else:
debug.error("an not do action for : " + str(res_file))
except ValueError:
debug.warning(" UN-SUPPORTED file format: '" + self._origin_path + "/" + file + "'")
# when multiprocess availlable, we need to synchronize here ...
list_other = tools.filter_map(self._src, self._ordered_builder, invert=True)
for builder_name in list_other.keys():
debug.warning(" " + builder_name + " is unknown !! element not build:");
for elem in self._src[builder_name]:
debug.warning(" ==> " + elem);
# when multiprocess available, we need to synchronize here ...
multiprocess.pool_synchrosize()
# ----------------------------------------------------
@ -1163,7 +1147,7 @@ class Module:
def compile_version(self, compilator_type, version, same_as_api=True, gnu=False):
if compilator_type == "c++" \
or compilator_type == "C++":
cpp_version_list = [1999, 2003, 2011, 2014, 2017, 2020]
cpp_version_list = [1999, 2003, 2011, 2014, 2017, 2020, 2023]
if version not in cpp_version_list:
debug.error("[" + self._name + "] Can not select CPP version : " + str(version) + " not in " + str(cpp_version_list))
# select API version:
@ -1178,7 +1162,7 @@ class Module:
debug.debug("[" + self._name + "] Can not propagate the gnu extention of the CPP vesion for API");
elif compilator_type == "c" \
or compilator_type == "C":
c_version_list = [1989, 1990, 1999, 2011, 2017, 1018]
c_version_list = [1989, 1990, 1999, 2011, 2017, 2018]
if version not in c_version_list:
debug.error("[" + self._name + "] Can not select C version : " + str(version) + " not in " + str(c_version_list))
# select API version:
@ -1197,11 +1181,26 @@ class Module:
##
## @brief Add source file to compile
## @param[in] self (handle) Class handle
## @param[in] list ([string,...] or string) File(s) to compile
## @param[in] list ([string,...] or string) File(s) to compile (auto detect the compiler to use...)
## @return None
##
def add_src_file(self, list):
tools.list_append_to(self._src, list, True)
for elem in list:
extention = elem.split(".")[-1]
builder_name = builder.find_builder_with_input_extention(extention);
self.add_src_file_type(elem, builder_name)
##
## @brief Add source file to compile with specific type
## @param[in] self (handle) Class handle
## @param[in] builder_name (string) builder name
## @param[in] list ([string,...] or string) File(s) to compile
## @return None
##
def add_src_file_type(self, list_values, builder_name):
debug.extreme_verbose(" add_src_file_type ==> " + str(self._src.keys()) + " with builder name " + str(builder_name));
if builder_name not in self._src.keys():
self._src[builder_name] = [];
tools.list_append_to(self._src[builder_name], list_values, True);
##
## @brief Add all files in a specific path as source file to compile
@ -1478,19 +1477,24 @@ class Module:
for element in self._flags["export"]:
value = self._flags["export"][element];
self._print_list('flags export "' + str(element) + '"', value);
self._print_list('sources', self._src);
self._print_list('flags export "' + str(element) + '"', str(value));
if len(self._src.keys()) != 0:
for key in self._src.keys():
value = self._src[key];
self._print_list('sources(' + key + ') ' + str(len(value)), value);
if len(self._header.keys()) != 0:
for key in self._header.keys():
value = self._header[key];
self._print_list('headers(' + key + ') ' + str(len(value)), [ iii['src'] for iii in value]);
self._print_list('files', self._files);
self._print_list('headers', [ iii['src'] for iii in self._header]);
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('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);
self._print_list('export path(' + str(element) + ') ' + str(len(value)), value);
print('-----------------------------------------------')
return True;

View File

@ -55,7 +55,8 @@ list_of_property_module=[
"version",
"version-id",
"code-quality",
"header-install-mode"
"header-install-mode",
"package" # package is for specifie some right in LUTIN
];
list_of_element_ignored=[
@ -76,7 +77,8 @@ list_of_element_availlable=[
"target",
"arch",
"bus-size", # todo
"sanity-compilation" # todo "isolate", "intricate", "*" permit to specify element to copy for the isolation mode. intricate is for current mode where everything is mixed together ...
"sanity-compilation", # todo "isolate", "intricate", "*" permit to specify element to copy for the isolation mode. intricate is for current mode where everything is mixed together ...
"compilator"
];
"""
@ -442,10 +444,8 @@ def parse_node_generic(target, path, json_path, my_module, data, first = False )
elif type(data["source"]) == list:
my_module.add_src_file(data["source"]);
elif type(data["source"]) == dict:
if "list" in data["source"].keys():
my_module.add_src_file(data["source"]["list"]);
else:
debug.error("missing 'list' in node 'source:{}'");
for builder_key in data["source"].keys():
my_module.add_src_file_type(data["source"][builder_key], builder_key);
else:
debug.error("'" + json_path + "'Wrong type for node 'source' [] or {} or string");
@ -477,10 +477,8 @@ def parse_node_generic(target, path, json_path, my_module, data, first = False )
else:
debug.error("headers does not manage other than string, list and object");
elif type(data["header"]) == dict:
if "list" in data["header"].keys():
my_module.add_header_file(data["header"]["list"]);
else:
debug.error("missing 'list' in node 'header:{}'");
for builder_key in data["header"].keys():
my_module.add_header_file(data["header"][builder_key], builder_key);
else:
debug.error("Wrong type for node 'headers' [] or {}");

View File

@ -310,6 +310,17 @@ def filter_extention(list_files, extentions, invert=False):
out.append(file)
return out
def filter_map(input_data, extentions, invert=False):
out = {}
for key in input_data.keys():
if invert:
if key not in extentions:
out[key] = input_data[key];
else:
if key in extentions:
out[key] = input_data[key];
return out
def move_if_needed(src, dst):
if not os.path.isfile(src):

View File

@ -31,6 +31,12 @@ def init():
def get_type():
return "linker"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 1100
##
## @brief Get builder input file type

View File

@ -40,6 +40,13 @@ def get_type():
def get_input_type():
return ["cpp", "CPP", "cxx", "CXX", "xx", "XX", "CC", "cc"]
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 600
##
## @brief Get builder output file type
## @return List of extention supported
@ -152,11 +159,16 @@ def get_version_compilation_flags(flags, dependency_flags):
is_gnu = default_version_gnu
version = max(version_local, dependency_version)
if version == 2020:
if version == 2023:
if is_gnu == True:
out = ["-std=gnu++2a", "-D__CPP_VERSION__=2020"]
out = ["-std=gnu++23", "-D__CPP_VERSION__=2023"]
else:
out = ["-std=c++2a", "-D__CPP_VERSION__=2020"]
out = ["-std=c++23", "-D__CPP_VERSION__=2023"]
elif version == 2020:
if is_gnu == True:
out = ["-std=gnu++20", "-D__CPP_VERSION__=2020"]
else:
out = ["-std=c++20", "-D__CPP_VERSION__=2020"]
elif version == 2017:
if is_gnu == True:
out = ["-std=gnu++17", "-D__CPP_VERSION__=2017"]

View File

@ -34,6 +34,13 @@ def init():
def get_type():
return "compiler"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 400
##
## @brief Get builder input file type
## @return List of extention supported

View File

@ -31,6 +31,13 @@ def init():
def get_type():
return "linker"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 1200
##
## @brief Get builder input file type
## @return List of extention supported

View File

@ -29,6 +29,13 @@ def init():
def get_type():
return "compiler"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 800
##
## @brief Get builder input file type
## @return List of extention supported

View File

@ -29,6 +29,13 @@ def init():
def get_type():
return "compiler"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 100
##
## @brief Get builder input file type
## @return List of extention supported

View File

@ -31,6 +31,13 @@ def init():
def get_type():
return "linker"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 900
##
## @brief Get builder input file type
## @return List of extention supported

View File

@ -31,6 +31,13 @@ def init():
def get_type():
return "linker"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 1000
##
## @brief Get builder input file type
## @return List of extention supported

View File

@ -35,6 +35,13 @@ def init():
def get_type():
return "compiler"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 500
##
## @brief Get builder input file type
## @return List of extention supported

View File

@ -35,6 +35,13 @@ def init():
def get_type():
return "compiler"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 700
##
## @brief Get builder input file type
## @return List of extention supported

View File

@ -29,24 +29,31 @@ def init():
def get_type():
return "compiler"
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 300
##
## @brief Get builder input file type
## @return List of extention supported
## @return List of extension supported
##
def get_input_type():
return ["s", "S"]
##
## @brief Get builder output file type
## @return List of extention supported
## @return List of extension supported
##
def get_output_type():
return ["o"]
##
## @brief Get builder support multi-threading or not
## @return True Multithreading supported
## @return False Multithreading NOT supported
## @return True Multi-threading supported
## @return False Multi-threading NOT supported
##
def get_support_multithreading():
return True

View File

@ -0,0 +1,35 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
from realog import debug
from lutin import system
from lutin import tools
from lutin import env
import os
class System(system.System):
def __init__(self, target):
system.System.__init__(self)
# create some HELP:
self.set_help("python numpy library")
# check if the library exist:
for version in ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]:
if os.path.isdir("/usr/lib/python" + version + "/site-packages/numpy/core/include"):
self.set_valid(True)
# todo : create a searcher of the presence of the library:
self.add_flag("link-lib", "python" + version);
if env.get_isolate_system() == True:
self.add_header_file(self, "/usr/lib/python" + version + "/site-packages/numpy/core/include/*", clip_path="/usr/lib/python" + version + "/site-packages/numpy/core/include/", recursive=True);
else:
self.add_path("/usr/lib/python" + version + "/site-packages/numpy/core/include/");
return;

View File

@ -0,0 +1,35 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
from realog import debug
from lutin import system
from lutin import tools
from lutin import env
import os
class System(system.System):
def __init__(self, target):
system.System.__init__(self)
# create some HELP:
self.set_help("Python3 library \n Can be install with the package:\n - zlib1g-dev")
# check if the library exist:
for version in ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]:
if os.path.isdir("/usr/include/python" + version):
self.set_valid(True)
# todo : create a searcher of the presence of the library:
self.add_flag("link-lib", "python" + version);
if env.get_isolate_system() == True:
self.add_header_file(self, "/usr/include/python" + version + "/*", clip_path="/usr/include/", recursive=True);
else:
self.add_path("/usr/include/python" + version + "/");
return;

View File

@ -0,0 +1,38 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
from realog import debug
from lutin import system
from lutin import tools
from lutin import env
import os
class System(system.System):
def __init__(self, target):
system.System.__init__(self)
# create some HELP:
self.set_help("RT : rt access to the shared momory interface")
# No check ==> on the basic std libs:
self.set_valid(True)
# todo : create a searcher of the presence of the library:
self.add_flag("link-lib", "rt")
self.add_depend([
'c'
])
if env.get_isolate_system() == True:
self.add_header_file([
"/usr/include/sys/mman.h",
"/usr/include/sys/stat.h"
],
clip_path="/usr/include",
recursive=False)