[DEV] add a proto of nasm

This commit is contained in:
Edouard DUPIN 2022-01-12 22:53:32 +01:00
parent 64d016880e
commit 4db61cf9f2
4 changed files with 171 additions and 36 deletions

View File

@ -21,6 +21,7 @@ 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_nasm.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

View File

@ -698,21 +698,22 @@ 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"])
if "multi-dst" in file:
dst_path = os.path.join(include_path, file["multi-dst"])
tools.copy_anything(src_path,
for builder_name in self._header.keys():
for file in self._header[builder_name]:
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,
dst_path,
recursive=file["recursive"],
force_identical=True,
in_list=copy_list)
else:
dst_path = os.path.join(include_path, file["dst"])
tools.copy_file(src_path,
dst_path,
recursive=file["recursive"],
force_identical=True,
in_list=copy_list)
else:
dst_path = os.path.join(include_path, file["dst"])
tools.copy_file(src_path,
dst_path,
force_identical=True,
in_list=copy_list)
#real copy files
tools.copy_list(copy_list)
# remove unneded files (NOT folder ...)
@ -1174,33 +1175,30 @@ class Module:
}
self._flags["export"]["c-version"] = api_version
if gnu == True and same_as_api == True:
debug.debug("[" + self._name + "] Can not propagate the gnu extention of the C vesion for API");
debug.debug("[" + self._name + "] Can not propagate the gnu extension of the C version for API");
else:
debug.warning("[" + self._name + "] 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 (auto detect the compiler to use...)
## @return None
##
def add_src_file(self, list):
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] list_values ([string,...] or string) File(s) to compile (auto detect the compiler to use...)
## @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);
def add_src_file(self, list_values, builder_name=None):
if type(list_values) == str:
list_values = [list_values]
if builder_name == None:
for elem in list_values:
extention = elem.split(".")[-1]
builder_name = builder.find_builder_with_input_extention(extention);
self.add_src_file(elem, builder_name)
else:
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
@ -1271,7 +1269,7 @@ class Module:
##
## @return None
##
def add_header_file(self, list, destination_path=None, clip_path=None, recursive=False):
def add_header_file(self, list, destination_path=None, clip_path=None, recursive=False, builder_name="*"):
if destination_path != None:
debug.verbose("Change destination PATH: '" + str(destination_path) + "'")
new_list = []
@ -1323,7 +1321,9 @@ class Module:
new_list.append({"src":elem,
"dst":out_elem,
"recursive":recursive})
tools.list_append_to(self._header, new_list, True)
if builder_name not in self._header.keys():
self._header[builder_name] = [];
tools.list_append_to(self._header[builder_name], new_list, True)
##
## @brief An an header path in the install directory
@ -1473,11 +1473,11 @@ class Module:
for element in self._flags["local"]:
value = self._flags["local"][element];
self._print_list('flags "' + str(element) + '"', value);
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) + '"', str(value));
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];

View File

@ -445,7 +445,7 @@ def parse_node_generic(target, path, json_path, my_module, data, first = False )
my_module.add_src_file(data["source"]);
elif type(data["source"]) == dict:
for builder_key in data["source"].keys():
my_module.add_src_file_type(data["source"][builder_key], builder_key);
my_module.add_src_file(data["source"][builder_key], builder_name=builder_key);
else:
debug.error("'" + json_path + "'Wrong type for node 'source' [] or {} or string");
@ -478,7 +478,7 @@ def parse_node_generic(target, path, json_path, my_module, data, first = False )
debug.error("headers does not manage other than string, list and object");
elif type(data["header"]) == dict:
for builder_key in data["header"].keys():
my_module.add_header_file(data["header"][builder_key], builder_key);
my_module.add_header_file(data["header"][builder_key], builder_name=builder_key);
else:
debug.error("Wrong type for node 'headers' [] or {}");

View File

@ -0,0 +1,134 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license MPL v2.0 (see license file)
##
##
## C++ builder
##
from lutin import multiprocess
from lutin import tools
from realog import debug
from lutin import depend
from lutin import env
##
## Initialize the builder, if needed ... to get dependency between builder (for example)
##
def init():
pass
##
## Get the current builder type.
## Return the type of builder
##
def get_type():
return "compiler"
##
## @brief Get builder input file type
## @return List of extention supported
##
def get_input_type():
return [];#["s"]
##
## @brief get the order of the current builder
## @return the string that define the build order
##
def get_order():
return 200
##
## @brief Get builder output file type
## @return List of extention supported
##
def get_output_type():
return ["o"]
##
## @brief Get builder support multi-threading or not
## @return True Multithreading supported
## @return False Multithreading NOT supported
##
def get_support_multithreading():
return True
##
## @brief Commands for running gcc to compile a C++ file in object file.
##
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)
# set ccache interface:
compilator_ccache = ""
if env.get_ccache() == True:
compilator_ccache = "ccache"
# create the command line before requesting start:
cmd = [
compilator_ccache,
"nasm",
"-o", file_dst,
"-f", "elf64",
target.sysroot
]
for view in ["export", "local"]:
for type in ["nasm"]:
try:
cmd.append(tools.add_prefix("-I",path[view][type]))
except:
pass
for type in ["nasm"]:
try:
cmd.append(tools.add_prefix("-I",depancy.path[type]))
except:
pass
cmd.append(target.global_include_cc)
list_flags = [];
if "nasm" in target.global_flags:
list_flags.append(target.global_flags["nasm"])
for view in ["local", "export"]:
if view in flags:
for type in ["nasm"]:
if type in flags[view]:
list_flags.append(flags[view][type])
# get blacklist of flags
list_flags_blacklist = [];
if "nasm-remove" in target.global_flags:
list_flags_blacklist.append(target.global_flags["nasm-remove"])
for type in ["nasm-remove"]:
if type in depancy.flags:
list_flags_blacklist.append(depancy.flags[type])
for view in ["local", "export"]:
if view in flags:
for type in ["c-nasm"]:
if type in flags[view]:
list_flags_blacklist.append(flags[view][type])
# apply blacklisting of data and add it on the cmdLine
clean_flags = tools.remove_element(list_flags, list_flags_blacklist)
#debug.warning("plop " + str(list_flags_blacklist) + " " + str(list_flags) + " --> " + str(clean_flags) )
cmd.append(clean_flags);
cmd.append(["-DPIC"])
cmd.append(["-MP"])
cmd.append(file_src)
# Create cmd line
cmdLine = tools.list_to_str(cmd)
# check the dependency for this file :
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
return {"action":"add", "file":file_dst}
tools.create_directory_of_file(file_dst)
comment = ["nasm", name, "<==", file]
#process element
multiprocess.run_in_pool(cmdLine, comment, file_cmd, store_output_file=file_warning)
return {"action":"add", "file":file_dst}