[DEV] update model

This commit is contained in:
Edouard DUPIN 2022-02-11 22:14:44 +01:00
parent 6a6961fb3d
commit 2c5642d5c8
4 changed files with 50 additions and 18 deletions

View File

@ -73,24 +73,28 @@ class HeritageList:
listHeritage = self.list_heritage
self.list_heritage = []
# first step : add all lib with no dependency:
debug.extreme_verbose(" add element with no dependency:")
debug.warning(" add element with no dependency:")
for herit in listHeritage:
if len(herit.depends) == 0:
debug.extreme_verbose(" add: " + str(herit.name))
self.list_heritage.append(copy.deepcopy(herit))
listHeritage.remove(herit)
debug.extreme_verbose(" add element with dependency:")
debug.warning(" add: " + str(herit.name) + " => " + str(herit));
self.list_heritage.append(copy.deepcopy(herit));
listHeritage.remove(herit);
debug.warning(" add element with dependency:")
while len(listHeritage) > 0:
currentHeritageSize = len(listHeritage)
debug.verbose(" list heritage = " + str([[x.name, x.depends] for x in listHeritage]))
debug.extreme_verbose(" list heritage (rest):")
debug.warning(" list heritage = " + str([[x.name, x.depends] for x in listHeritage]))
debug.warning(" list heritage (rest):")
for tmppp_herit in listHeritage:
debug.extreme_verbose(" elem= " + str(tmppp_herit.name) + " : " + str(tmppp_herit.depends))
debug.warning(" elem= " + str(tmppp_herit.name) + " : " + str(tmppp_herit.depends))
# Add element only when all dependence are resolved
for herit in listHeritage:
listDependsName = [y.name for y in self.list_heritage]
debug.warning(" self.list_heritage= " + str(self.list_heritage))
debug.warning(" inHeritance= " + str(herit.depends))
debug.warning(" listDependsName= " + str(listDependsName))
debug.warning(" check in = " + str([listDependsName for x in herit.depends]))
if all(x in listDependsName for x in herit.depends) == True:
debug.extreme_verbose(" add: " + str(herit.name))
debug.warning(" add: " + str(herit.name))
listHeritage.remove(herit)
self.list_heritage.append(copy.deepcopy(herit))
# check if nothing is include in heritage...

View File

@ -104,6 +104,8 @@ class Module:
self._isbuild = False
# add include install path after building package
self._include_header_after = False
# Export visibility of the package. when set, need to add "-Wl,--version-script=" flags (for .so only)
self._visibility_map = None
# configure default heritage
self._local_heritage = None
# TODO : Do a better dynamic property system => not really versatile
@ -153,10 +155,17 @@ class Module:
##
## @brief set the header not used for the compilation, thay are copied in the include folder, but they are only used for external library include.
## @param[in] self (handle) Class handle.
## @param[in] calue (boolean) Value of the variable.
## @param[in] value (boolean) Value of the variable.
##
def set_include_header_after(self, value):
self._include_header_after = value;
##
## @brief set the visibility map of the application to control what it is exposed ouside the program.
## @param[in] self (handle) Class handle.
## @param[in] file (string) path of the visibility file.
##
def set_visibility_map(self, file):
self._visibility_map = file;
##
## @brief Generate a string representing the class (for str(xxx))
@ -804,13 +813,17 @@ class Module:
tmp_builder = builder.get_builder_with_output("so");
list_file = tools.filter_extention(list_sub_file_needed_to_build, tmp_builder.get_input_type())
if len(list_file) > 0:
tmp_visibility = self._visibility_map;
if tmp_visibility != None:
tmp_visibility = os.path.join(self.get_origin_path(), tmp_visibility);
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)
basic_path = self._origin_path,
visibility_file = tmp_visibility)
self._local_heritage.add_lib_dynamic(res_file)
except ValueError:
debug.error(" UN-SUPPORTED link format: '.so'/'.dynlib'/'.dll'")
@ -957,7 +970,7 @@ class Module:
# ----------------------------------------------------
# -- install data --
# ----------------------------------------------------
debug.debug("install datas")
debug.debug("install data")
copy_list={}
self.image_to_build(target, copy_list)
self.files_to_build(target, copy_list)
@ -1078,13 +1091,13 @@ class Module:
and elem[0] == '/':
# unix case
debug.warning(" add_path(" + str(list) + ")")
debug.warning("[" + self._name + "] Not permited to add a path that start in / directory (only relative path) (compatibility until 2.x)")
debug.warning("[" + self._name + "] Not permitted to add a path that start in / directory (only relative path) (compatibility until 2.x)")
add_list.append(elem)
elif len(elem) > 2 \
and elem[1] == ':':
# windows case :
debug.warning(" add_path(" + str(list) + ")")
debug.warning("[" + self._name + "] Not permited to add a path that start in '" + elem[0] + ":' directory (only relative path) (compatibility until 2.x)")
debug.warning("[" + self._name + "] Not permitted to add a path that start in '" + elem[0] + ":' directory (only relative path) (compatibility until 2.x)")
add_list.append(elem)
if elem == ".":
add_list.append(tools.get_current_path(self._origin_file))
@ -1095,13 +1108,13 @@ class Module:
and list[0] == '/':
# unix case
debug.warning(" add_path(" + str(list) + ")")
debug.warning("[" + self._name + "] Not permited to add a path that start in / directory (only relative path) (compatibility until 2.x)")
debug.warning("[" + self._name + "] Not permitted to add a path that start in / directory (only relative path) (compatibility until 2.x)")
add_list = list
elif len(list) > 2 \
and list[1] == ':':
# windows case :
debug.warning(" add_path(" + str(list) + ")")
debug.warning("[" + self._name + "] Not permited to add a path that start in '" + list[0] + ":' directory (only relative path) (compatibility until 2.x)")
debug.warning("[" + self._name + "] Not permitted to add a path that start in '" + list[0] + ":' directory (only relative path) (compatibility until 2.x)")
add_list = list
elif list == ".":
add_list = tools.get_current_path(self._origin_file)

View File

@ -55,6 +55,7 @@ list_of_property_module=[
"version",
"version-id",
"code-quality",
"visibility-map",
"header-install-mode",
"package" # package is for specifie some right in LUTIN
];
@ -141,6 +142,7 @@ list_of_element_availlable=[
...
] ...
},
"visibility-map": "libbsd/src/libbsd.map", # for application that need to control the visibility of the exports: -Wl,--version-script=/src/libbsd.map"
"header-install-mode": "AFTER", # or "BEFORE"<< default is before ==> better to isolate the include folder...
"header": [
"xxx/Yyy.hpp",
@ -237,7 +239,8 @@ list_of_element_availlable=[
"c": [
"-DAPPL_VERSION={{{project.version}}}",
"-DAPPL_NAME={{{project.name}}}",
"-DAPPL_TYPE={{{project.type}}}"
"-DAPPL_TYPE={{{project.type}}}",
"-DAPPL_PATH={{{project.path}}}"
]
},
"arch": {
@ -390,6 +393,7 @@ def replace_dynamic_tags(my_module, data):
out = out.replace("{{{project.version}}}", tools.version_to_string(my_module.get_version()));
out = out.replace("{{{project.name}}}", my_module.get_name());
out = out.replace("{{{project.type}}}", my_module.get_type());
out = out.replace("{{{project.path}}}", my_module.get_origin_path());
out = out.replace("{{{quote}}}", "\\'");
out = out.replace("{{{quote2}}}", "\\\""); # "
return out;
@ -573,6 +577,12 @@ def load_module_from_GLD(target, name, path, json_path):
my_module._pkg_set_if_default("VERSION", property["version"])
if "visibility-map" in data.keys():
if type(data["visibility-map"]) == str:
my_module.set_visibility_map(data["visibility-map"]);
else:
debug.warning("can not support for element: 'visibility-map' must be a string (representing a file)");
if "header-install-mode" in data.keys():
if data["header-install-mode"] == "AFTER":
my_module.set_include_header_after(True);

View File

@ -63,7 +63,7 @@ def get_support_multithreading():
##
## @brief Commands for running gcc to link a shared library.
##
def link(file, binary, target, depancy, flags, name, basic_path, static=False):
def link(file, binary, target, depancy, flags, name, basic_path, static=False, visibility_file = None):
file_src = file
file_dst = target.get_build_file_dynamic(name)
file_depend = file_dst + target.suffix_dependence
@ -150,6 +150,9 @@ def link(file, binary, target, depancy, flags, name, basic_path, static=False):
cmd.append("-Wl,-R$ORIGIN/../lib/")
except:
pass
if visibility_file != None:
cmd.append("-Wl,--version-script=" + visibility_file);
for view in ["local", "export"]:
if view not in flags:
continue
@ -168,6 +171,8 @@ def link(file, binary, target, depancy, flags, name, basic_path, static=False):
and depend.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine) == False:
return file_dst
tools.create_directory_of_file(file_dst)
debug.print_element("SharedLib", name, "==>", os.path.relpath(file_dst))
multiprocess.run_command(cmdLine, store_output_file=file_warning)
# strip the output file: