Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
e1728a4d8d | |||
c6ea16d046 | |||
b645f087f3 | |||
6e69681480 | |||
14114158aa | |||
618825ac76 |
109
lutin/module.py
109
lutin/module.py
@@ -42,6 +42,8 @@ class Module:
|
||||
self.type='LIBRARY'
|
||||
# Name of the module
|
||||
self.name=module_name
|
||||
# Tools list:
|
||||
self.tools = []
|
||||
# Dependency list:
|
||||
self.depends = []
|
||||
# Dependency list (optionnal module):
|
||||
@@ -234,12 +236,38 @@ class Module:
|
||||
if self.type == 'PREBUILD':
|
||||
debug.error("Can not generate gcov on prebuid system ... : '" + self.name + "'");
|
||||
return
|
||||
# list of path that can apear in the output data :
|
||||
gcov_path_file = []
|
||||
gcov_path_file.append(target.get_build_path_include(self.name)) # for include (that is installed)
|
||||
gcov_path_file.append(" " + target.get_build_path_include(self.name))
|
||||
gcov_path_file.append(self.origin_path) # for sources.
|
||||
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']))
|
||||
full_list_file.append([self.name, elem['src']])
|
||||
for elem in self.src:
|
||||
debug.extreme_verbose("plop S : " +str(elem))
|
||||
full_list_file.append([self.name, elem])
|
||||
for mod_name in self.tools:
|
||||
tool_module = load_module(target, mod_name)
|
||||
if tool_module == None:
|
||||
continue
|
||||
for elem in tool_module.header:
|
||||
debug.extreme_verbose("plop HH: " + ":" + str(elem['src']))
|
||||
full_list_file.append([tool_module.name, elem['src']])
|
||||
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))
|
||||
# remove uncompilable elements:
|
||||
list_file = tools.filter_extention(self.src, self.extention_order_build, True)
|
||||
# TODO: list_file = tools.filter_extention(full_list_file, self.extention_order_build, True)
|
||||
list_file = full_list_file;
|
||||
global_list_file = ""
|
||||
for file in list_file:
|
||||
debug.verbose(" gcov : " + self.name + " <== " + file);
|
||||
file_dst = target.get_full_name_destination(self.name, self.origin_path, file, "o")
|
||||
debug.verbose(" gcov : " + self.name + " <== " + str(file));
|
||||
file_dst = target.get_full_name_destination(file[0], self.origin_path, file[1], "o")
|
||||
global_list_file += file_dst + " "
|
||||
cmd = "gcov"
|
||||
# specify the version of gcov we need to use
|
||||
@@ -261,39 +289,78 @@ class Module:
|
||||
executed_lines = 0
|
||||
executable_lines = 0
|
||||
for elem in ret:
|
||||
debug.debug("line: " + elem)
|
||||
if remove_next == True:
|
||||
remove_next = False
|
||||
debug.debug("--------------------------")
|
||||
continue;
|
||||
if elem[:10] == "Creating '" \
|
||||
or elem[:10] == "Removing '":
|
||||
or elem[:10] == "Removing '" \
|
||||
or elem[:14] == "Suppression de" \
|
||||
or elem[:11] == "Création de":
|
||||
remove_next = True
|
||||
continue
|
||||
if elem[:6] == "File '" \
|
||||
and self.origin_path != elem[6:len(self.origin_path)+6]:
|
||||
remove_next = True
|
||||
if elem[:6] in ["File '", "File «"] \
|
||||
or elem[:7] in ["File ' ", "File « "]:
|
||||
path_finder = False
|
||||
for path_base_finder in gcov_path_file:
|
||||
if path_base_finder == elem[6:len(path_base_finder)+6]:
|
||||
path_finder = True
|
||||
last_file = elem[6+len(path_base_finder)+1:-1]
|
||||
while last_file[-1] == " ":
|
||||
last_file = last_file[:-1]
|
||||
if path_finder == False:
|
||||
remove_next = True
|
||||
debug.verbose(" REMOVE: '" + str(elem[6:len(self.origin_path)+1]) + "' not in " + str(gcov_path_file))
|
||||
continue
|
||||
continue
|
||||
if elem[:6] == "File '":
|
||||
last_file = elem[6+len(self.origin_path)+1:-1]
|
||||
if elem[:7] == "Aucune ":
|
||||
debug.verbose(" Nothing to execute");
|
||||
continue
|
||||
start_with = "Lines executed:"
|
||||
if elem[:len(start_with)] != start_with:
|
||||
start_with = ["Lines executed:", "Lignes exécutées:"]
|
||||
find = False
|
||||
for line_base in start_with:
|
||||
if elem[:len(line_base)] == line_base:
|
||||
find = True
|
||||
elem = elem[len(line_base)+1:]
|
||||
break;
|
||||
if find == False:
|
||||
debug.warning(" gcov ret : " + str(elem));
|
||||
debug.warning(" ==> does not start with : " + start_with);
|
||||
debug.warning(" ==> does not start with : " + str(start_with));
|
||||
debug.warning(" Parsing error");
|
||||
continue
|
||||
out = elem[len(start_with):].split("% of ")
|
||||
out = elem.split("% of ")
|
||||
if len(out) != 2:
|
||||
debug.warning(" gcov ret : " + str(elem));
|
||||
debug.warning(" Parsing error of '% of '");
|
||||
continue
|
||||
out = elem.split("% de ")
|
||||
if len(out) != 2:
|
||||
debug.warning(" gcov ret : " + str(elem));
|
||||
debug.warning(" Parsing error of '% of '");
|
||||
continue
|
||||
debug.verbose("property : " + str(out))
|
||||
pourcent = float(out[0])
|
||||
total_line_count = int(out[1])
|
||||
total_executed_line = int(float(total_line_count)*pourcent/100.0)
|
||||
# check if in source or header:
|
||||
in_source_file = False
|
||||
debug.verbose(" ??> Check: " + str(last_file))
|
||||
for elem_header in self.header:
|
||||
debug.verbose(" ==> Check: " + str(elem_header['src']))
|
||||
if elem_header['src'] == last_file:
|
||||
in_source_file = True
|
||||
for elem_src in self.src:
|
||||
debug.verbose(" ==> Check: " + str(elem_src))
|
||||
if elem_src == last_file:
|
||||
in_source_file = True
|
||||
if in_source_file == False:
|
||||
debug.verbose(" ==> Remove not in source: " + str(out))
|
||||
continue
|
||||
useful_list.append([last_file, pourcent, total_executed_line, total_line_count])
|
||||
executed_lines += total_executed_line
|
||||
executable_lines += total_line_count
|
||||
last_file = ""
|
||||
debug.debug("--------------------------")
|
||||
ret = useful_list[:-1]
|
||||
debug.verbose("plopppp " + str(useful_list))
|
||||
#for elem in ret:
|
||||
# debug.info(" " + str(elem));
|
||||
for elem in ret:
|
||||
@@ -303,7 +370,10 @@ class Module:
|
||||
debug.info(" % " + str(elem[1]) + "\r\t\t" + str(elem[0]));
|
||||
else:
|
||||
debug.info(" % " + str(elem[1]) + "\r\t\t" + str(elem[0]));
|
||||
pourcent = 100.0*float(executed_lines)/float(executable_lines)
|
||||
try:
|
||||
pourcent = 100.0*float(executed_lines)/float(executable_lines)
|
||||
except ZeroDivisionError:
|
||||
pourcent = 0.0
|
||||
# generate json file:
|
||||
json_file_name = target.get_build_path(self.name) + "/" + self.name + "_coverage.json"
|
||||
debug.debug("generate json file : " + json_file_name)
|
||||
@@ -331,6 +401,7 @@ class Module:
|
||||
tmp_file.close()
|
||||
# print debug:
|
||||
debug.print_element("coverage", self.name, ":", str(pourcent) + "% " + str(executed_lines) + "/" + str(executable_lines))
|
||||
return True
|
||||
|
||||
# call here to build the module
|
||||
def build(self, target, package_name):
|
||||
@@ -712,6 +783,9 @@ class Module:
|
||||
else:
|
||||
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
||||
|
||||
def add_tools(self, list):
|
||||
tools.list_append_to(self.tools, list, True)
|
||||
|
||||
def add_module_depend(self, list):
|
||||
tools.list_append_to(self.depends, list, True)
|
||||
|
||||
@@ -1026,6 +1100,7 @@ def load_module(target, name):
|
||||
debug.debug("Request load module '" + name + "' not define for this platform")
|
||||
else:
|
||||
target.add_module(tmp_element)
|
||||
return tmp_element
|
||||
|
||||
def list_all_module():
|
||||
global module_list
|
||||
|
@@ -48,7 +48,7 @@ processor_availlable = 1 # number of CPU core availlable
|
||||
def run_command_no_lock_out(cmd_line):
|
||||
# prepare command line:
|
||||
args = shlex.split(cmd_line)
|
||||
debug.verbose("cmd = " + str(args))
|
||||
debug.info("cmd = " + str(args))
|
||||
try:
|
||||
# create the subprocess
|
||||
p = subprocess.Popen(args)
|
||||
|
@@ -121,8 +121,8 @@ class Target:
|
||||
"-ftest-coverage"
|
||||
])
|
||||
self.add_flag("link", [
|
||||
"-fprofile-arcs",
|
||||
"-ftest-coverage"
|
||||
"-lgcov",
|
||||
"--coverage"
|
||||
])
|
||||
|
||||
self.update_path_tree()
|
||||
@@ -508,11 +508,25 @@ class Target:
|
||||
self.un_install_package(module_name)
|
||||
except AttributeError:
|
||||
debug.error("target have no 'un_install_package' instruction")
|
||||
elif action_name == "run":
|
||||
try:
|
||||
self.run(module_name)
|
||||
except AttributeError:
|
||||
debug.error("target have no 'run' instruction")
|
||||
elif action_name[:3] == "run":
|
||||
if len(action_name) > 3:
|
||||
# we have option:
|
||||
action_name2 = action_name.replace("\:", "1234COLUMN4321")
|
||||
option_list = action_name2.split(":")
|
||||
if len(option_list) == 0:
|
||||
debug.warning("action 'run' wrong options options ... : '" + action_name + "' might be separate with ':'")
|
||||
option_list = []
|
||||
else:
|
||||
option_list_tmp = option_list[1:]
|
||||
option_list = []
|
||||
for elem in option_list_tmp:
|
||||
option_list.append(elem.replace("1234COLUMN4321", ":"))
|
||||
else:
|
||||
option_list = []
|
||||
#try:
|
||||
self.run(module_name, option_list)
|
||||
#except AttributeError:
|
||||
# debug.error("target have no 'run' instruction")
|
||||
elif action_name == "log":
|
||||
try:
|
||||
self.show_log(module_name)
|
||||
@@ -549,6 +563,8 @@ class Target:
|
||||
option_list = []
|
||||
else:
|
||||
option_list = option_list[1:]
|
||||
else:
|
||||
option_list = []
|
||||
if "output" in option_list:
|
||||
ret = mod.gcov(self, generate_output=True)
|
||||
else:
|
||||
|
@@ -126,7 +126,7 @@ def link(file, binary, target, depancy, flags, name, basic_path, static = False)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
cmd.append(target.global_flags_ld)
|
||||
cmd.append(target.global_flags["link"])
|
||||
except:
|
||||
pass
|
||||
for view in ["local", "export"]:
|
||||
|
@@ -137,12 +137,15 @@ class Target(target.Target):
|
||||
# remove executable link version:
|
||||
tools.remove_file(target_bin_link)
|
||||
|
||||
def run(self, pkg_name):
|
||||
def run(self, pkg_name, option_list):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("-- Run package '" + pkg_name + "'")
|
||||
debug.info("-- Run package '" + pkg_name + "' + option: " + str(option_list))
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
appl_path = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app", "bin", pkg_name)
|
||||
multiprocess.run_command_no_lock_out(appl_path)
|
||||
cmd = appl_path + " "
|
||||
for elem in option_list:
|
||||
cmd += elem + " "
|
||||
multiprocess.run_command_no_lock_out(cmd)
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("-- Run package '" + pkg_name + "' Finished")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
@@ -147,12 +147,15 @@ class Target(target.Target):
|
||||
if os.path.exists("/Applications/" + pkg_name + ".app") == True:
|
||||
shutil.rmtree("/Applications/" + pkg_name + ".app")
|
||||
|
||||
def run(self, pkg_name):
|
||||
def run(self, pkg_name, option_list):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("-- Run package '" + pkg_name + "'")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
appl_path = os.path.join(tools.get_run_path(),self.path_out,self.path_staging,pkg_name + ".app", "bin", pkg_name)
|
||||
multiprocess.run_command_no_lock_out(appl_path)
|
||||
cmd = appl_path + " "
|
||||
for elem in option_list:
|
||||
cmd += elem + " "
|
||||
multiprocess.run_command_no_lock_out(cmd)
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("-- Run package '" + pkg_name + "' Finished")
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
2
setup.py
2
setup.py
@@ -7,7 +7,7 @@ def readme():
|
||||
|
||||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
setup(name='lutin',
|
||||
version='1.1.0',
|
||||
version='1.2.0',
|
||||
description='Lutin generic builder (might replace makefile, CMake ...)',
|
||||
long_description=readme(),
|
||||
url='http://github.com/HeeroYui/lutin',
|
||||
|
Reference in New Issue
Block a user