Compare commits

...

4 Commits

13 changed files with 233 additions and 65 deletions

View File

@@ -31,6 +31,7 @@ myArgs.add(arguments.ArgDefine("s", "force-strip", desc="Force the stripping of
myArgs.add_section("properties", "keep in the sequency of the cible")
myArgs.add(arguments.ArgDefine("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'"))
myArgs.add(arguments.ArgDefine("c", "compilator", list=[["clang",""],["gcc",""]], desc="Compile with clang or Gcc mode (by default gcc will be used)"))
myArgs.add(arguments.ArgDefine("", "compilator-version", haveParam=True, desc="with travis we need to specify the name of the version if we want to compile with gcc 4.9 ==> --compilator-version=4.9"))
myArgs.add(arguments.ArgDefine("m", "mode", list=[["debug",""],["release",""]], desc="Compile in release or debug mode (default release)"))
myArgs.add(arguments.ArgDefine("a", "arch", list=[["auto","Automatic choice"],["arm","Arm processer"],["x86","Generic PC : AMD/Intel"],["ppc","Power PC"]], desc="Architecture to compile"))
myArgs.add(arguments.ArgDefine("b", "bus", list=[["auto","Automatic choice"],["32","32 bits"],["64","64 bits"]], desc="Adressing size (Bus size)"))
@@ -47,18 +48,21 @@ localArgument = myArgs.parse()
display the help of this makefile
"""
def usage():
color = debug.get_color_set()
# generic argument displayed :
myArgs.display()
print(" All target can finish with '?clean' '?dump' ... ?action")
print(" all")
print(" All target can finish with '?clean' '?dump' '?gcov' ... ?action")
print(" " + color['green'] + "all" + color['default'])
print(" build all (only for the current selected board) (bynary and packages)")
print(" clean")
print(" " + color['green'] + "clean" + color['default'])
print(" clean all (same as previous)")
print(" dump")
print(" " + color['green'] + "dump" + color['default'])
print(" Dump all the module dependency and properties")
print(" " + color['green'] + "gcov" + color['default'])
print(" Parse all the code of the library with the gcov resolution")
listOfAllModule = module.list_all_module_with_desc()
for mod in listOfAllModule:
print(" " + mod[0])
print(" " + color['green'] + mod[0] + color['default'])
if mod[1] != "":
print(" " + mod[1])
print(" ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all")
@@ -139,7 +143,8 @@ config = {
"arch":"auto",
"generate-package":True,
"simulation":False,
"gcov":False
"gcov":False,
"compilator-version":""
}
# load the default target :
my_target = None
@@ -148,6 +153,8 @@ actionDone=False
for argument in localArgument:
if parseGenericArg(argument, False) == True:
continue
elif argument.get_option_nName() == "compilator-version":
config["compilator-version"] = argument.get_arg()
elif argument.get_option_nName() == "package":
config["generate-package"]=False
elif argument.get_option_nName() == "simulation":
@@ -177,7 +184,8 @@ for argument in localArgument:
"arch":"auto",
"generate-package":True,
"simulation":False,
"gcov":False
"gcov":False,
"compilator-version":""
}
#remove previous target
my_target = None

View File

@@ -70,12 +70,13 @@ class ArgDefine:
return False
def display(self):
color = debug.get_color_set()
if self.m_optionSmall != "" and self.m_optionBig != "":
print(" -" + self.m_optionSmall + " / --" + self.m_optionBig)
print(" " + color['red'] + "-" + self.m_optionSmall + "" + color['default'] + " / " + color['red'] + "--" + self.m_optionBig + color['default'])
elif self.m_optionSmall != "":
print(" -" + self.m_optionSmall)
print(" " + color['red'] + "-" + self.m_optionSmall + color['default'])
elif self.m_optionBig != "":
print(" --" + self.m_optionBig)
print(" " + color['red'] + "--" + self.m_optionBig + color['default'])
else:
print(" ???? ==> internal error ...")
if self.m_description != "":
@@ -115,10 +116,12 @@ class ArgSection:
return ""
def get_porperties(self):
return " [" + self.m_section + "]"
color = debug.get_color_set()
return " [" + color['blue'] + self.m_section + color['default'] + "]"
def display(self):
print(" [" + self.m_section + "] : " + self.m_description)
color = debug.get_color_set()
print(" [" + color['blue'] + self.m_section + color['default'] + "] : " + self.m_description)
def parse(self, argList, currentID):
return currentID;

View File

@@ -138,4 +138,22 @@ def print_compilator(myString):
debugLock.acquire()
print(myString)
debugLock.release()
debugLock.release()
def get_color_set() :
global color_default
global color_red
global color_green
global color_yellow
global color_blue
global color_purple
global color_cyan
return {
"default": color_default,
"red": color_red,
"green": color_green,
"yellow": color_yellow,
"blue": color_blue,
"purple": color_purple,
"cyan": color_cyan,
}

View File

@@ -92,7 +92,9 @@ def print_pretty(myString, force=False):
"-arch",
"-keystore",
"-sigalg",
"-digestalg"]
"-digestalg",
"-target",
"-gcc-toolchain"]
for element in baseElementList:
tmpcmdLine = tmpcmdLine.replace(element+'\n\t', element+' ')
for element in ["<", "<<", ">", ">>"]:

View File

@@ -170,6 +170,104 @@ class Module:
debug.debug("Might copy folder : " + source + "==>" + destination)
tools.copy_anything_target(target, self.origin_folder + "/" + source, destination)
def gcov(self, target, generate_output=False):
if self.type == 'PREBUILD':
debug.error("Can not generate gcov on prebuid system ... : '" + self.name + "'");
return
# remove uncompilable elements:
list_file = tools.filter_extention(self.src, self.extention_order_build, True)
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_folder, file, "o")
global_list_file += file_dst + " "
cmd = "gcov --branch-counts --preserve-paths "
if generate_output == False:
cmd += "--no-output "
cmd += global_list_file
debug.extreme_verbose(" " + cmd);
ret = multiprocess.run_command_direct(cmd)
# parsing ret :
ret = ret.split('\n');
debug.verbose("*** Gcov result parsing ...");
useful_list = []
remove_next = False
last_file = ""
executed_lines = 0
executable_lines = 0
for elem in ret:
if remove_next == True:
remove_next = False
continue;
if elem[:10] == "Creating '" \
or elem[:10] == "Removing '":
remove_next = True
continue
if elem[:6] == "File '" \
and self.origin_folder != elem[6:len(self.origin_folder)+6]:
remove_next = True
continue
if elem[:6] == "File '":
last_file = elem[6+len(self.origin_folder)+1:-1]
continue
start_with = "Lines executed:"
if elem[:len(start_with)] != start_with:
debug.warning(" gcov ret : " + str(elem));
debug.warning(" ==> does not start with : " + start_with);
debug.warning(" Parsing error");
continue
out = elem[len(start_with):].split("% of ")
if len(out) != 2:
debug.warning(" gcov ret : " + str(elem));
debug.warning(" Parsing error of '% of '");
continue
pourcent = float(out[0])
total_line_count = int(out[1])
total_executed_line = int(float(total_line_count)*pourcent/100.0)
useful_list.append([last_file, pourcent, total_executed_line, total_line_count])
executed_lines += total_executed_line
executable_lines += total_line_count
last_file = ""
ret = useful_list[:-1]
#for elem in ret:
# debug.info(" " + str(elem));
for elem in ret:
if elem[1]<10.0:
debug.info(" % " + str(elem[1]) + "\r\t\t" + str(elem[0]));
elif elem[1]<100.0:
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)
# generate json file:
json_file_name = target.get_build_folder(self.name) + "/" + self.name + "_coverage.json"
debug.debug("generate json file : " + json_file_name)
tmp_file = open(json_file_name, 'w')
tmp_file.write('{\n')
tmp_file.write(' "lib-name":"' + self.name + '",\n')
#tmp_file.write(' "coverage":"' + str(pourcent) + '",\n')
tmp_file.write(' "executed":"' + str(executed_lines) + '",\n')
tmp_file.write(' "executable":"' + str(executable_lines) + '",\n')
tmp_file.write(' "list":[\n')
val = 0
for elem in ret:
if val == 0 :
tmp_file.write(' {\n')
else:
tmp_file.write(' }, {\n')
val += 1
tmp_file.write(' "file":"' + elem[0] + '",\n')
#tmp_file.write(' "coverage":' + str(elem[1]) + ',\n')
tmp_file.write(' "executed":' + str(elem[2]) + ',\n')
tmp_file.write(' "executable":' + str(elem[3]) + '\n')
tmp_file.write(' }\n')
tmp_file.write(' ]\n')
tmp_file.write('}\n')
tmp_file.flush()
tmp_file.close()
# print debug:
debug.print_element("coverage", self.name, ":", str(pourcent) + "% " + str(executed_lines) + "/" + str(executable_lines))
# call here to build the module
def build(self, target, package_name):
# ckeck if not previously build

View File

@@ -66,6 +66,8 @@ def run_command_direct(cmdLine):
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except subprocess.CalledProcessError as e:
debug.error("subprocess.CalledProcessError : " + str(args))
except:
debug.error("Exception on : " + str(args))
# launch the subprocess:
output, err = p.communicate()
if sys.version_info >= (3, 0):
@@ -92,6 +94,8 @@ def run_command(cmdLine, storeCmdLine="", buildId=-1, file=""):
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except subprocess.CalledProcessError as e:
debug.error("subprocess.CalledProcessError : TODO ...")
except:
debug.error("Exception on : " + str(args))
# launch the subprocess:
output, err = p.communicate()
if sys.version_info >= (3, 0):

View File

@@ -148,13 +148,16 @@ class Target:
if self.config["compilator"] == "clang":
self.cc = self.cross + "clang"
self.xx = self.cross + "clang++"
#self.ar=self.cross + "llvm-ar"
#self.ranlib="ls"
self.ar=self.cross + "llvm-ar"
self.ranlib=""
else:
self.cc = self.cross + "gcc"
self.xx = self.cross + "g++"
#self.ar=self.cross + "ar"
#self.ranlib=self.cross + "ranlib"
if self.config["compilator-version"] != "":
self.cc = self.cc + "-" + self.config["compilator-version"]
self.xx = self.xx + "-" + self.config["compilator-version"]
#get g++ compilation version :
ret = multiprocess.run_command_direct(self.xx + " -dumpversion");
@@ -371,6 +374,9 @@ class Target:
return
def build(self, name, packagesName=None, optionnal=False):
if name == "gcov":
debug.info("gcov all")
debug.error("must set the gcov parsig on a specific library or binary ==> not supported now for all")
if name == "dump":
debug.info("dump all")
self.load_all()
@@ -397,6 +403,10 @@ class Target:
# get the action an the module ....
gettedElement = name.split("?")
moduleName = gettedElement[0]
if len(gettedElement)>=3:
sub_action_name = gettedElement[2]
else:
sub_action_name = ""
if len(gettedElement)>=2:
actionName = gettedElement[1]
else :
@@ -423,6 +433,11 @@ class Target:
elif actionName == "clean":
debug.info("clean module '" + moduleName + "'")
return mod.clean(self)
elif actionName == "gcov":
debug.debug("gcov on module '" + moduleName + "'")
if sub_action_name == "output":
return mod.gcov(self, generate_output=True)
return mod.gcov(self, generate_output=False)
elif actionName == "build":
debug.debug("build module '" + moduleName + "'")
if optionnal == True:

View File

@@ -25,10 +25,14 @@ class Target(target.Target):
#bus size selection (auto/32/64)
if config["bus-size"] == "auto":
config["bus-size"] = "32"
arch = ""#"ARMv7"
arch = ""
target.Target.__init__(self, "Android", config, arch)
if config["bus-size"] == "32":
arch="armv7"
else:
arch="arm64"
self.folder_ndk = os.getenv('PROJECT_NDK', "AUTO")
self.folder_sdk = os.getenv('PROJECT_SDK', "AUTO")
# auto search NDK
@@ -59,7 +63,7 @@ class Target(target.Target):
if host.BUS_SIZE==64:
tmpOsVal = "_64"
if self.config["compilator"] == "clang":
self.set_cross_base(self.folder_ndk + "/toolchains/llvm-3.3/prebuilt/linux-x86_64/bin/")
self.set_cross_base(self.folder_ndk + "/toolchains/llvm-3.6/prebuilt/linux-x86" + tmpOsVal + "/bin/")
else:
baseFolderArm = self.folder_ndk + "/toolchains/arm-linux-androideabi-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
baseFolderMips = self.folder_ndk + "/toolchains/mipsel-linux-android-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
@@ -72,12 +76,6 @@ class Target(target.Target):
if not os.path.isdir(baseFolderX86):
debug.info("Gcc x86 path does not exist !!!")
arch = "ARMv7"
# for gcc :
# for clang :
self.folder_bin="/mustNotCreateBinary"
self.folder_lib="/data/lib/armeabi"
self.folder_data="/data/assets"
@@ -86,7 +84,8 @@ class Target(target.Target):
# board id at 14 is for android 4.0 and more ...
self.boardId = 14
if arch == "ARMv5" or arch == "ARMv7":
self.global_flags_cc.append("-D__ANDROID_BOARD_ID__=" + str(self.boardId))
if arch == "armv5" or arch == "armv7":
self.global_include_cc.append("-I" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-arm/usr/include/")
elif arch == "mips":
self.global_include_cc.append("-I" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-mips/usr/include/")
@@ -95,15 +94,29 @@ class Target(target.Target):
if True:
if self.config["compilator"] == "clang":
if self.boardId < 21:
debug.error("Clang work only with the board wersion >= 21 : android 5.x.x")
self.global_flags_cc.append("-D__STDCPP_LLVM__")
# llvm-libc++ : BSD | MIT
self.global_include_cc.append("-gcc-toolchain " + self.folder_ndk +"/sources/android/support/include")
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/android/support/include")
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/include/")
if arch == "ARMv5":
if arch == "armv5":
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/armeabi/"
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
elif arch == "ARMv7":
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/armeabi-v7a/"
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
elif arch == "armv7":
# The only one tested ... ==> but we have link error ...
self.global_flags_cc.append("-target armv7-none-linux-androideabi")
self.global_flags_cc.append("-march=armv7-a")
self.global_flags_cc.append("-mfpu=vfpv3-d16")
self.global_flags_cc.append("-mhard-float")
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/"
self.global_flags_ld.append( stdCppBasePath + "thumb/libc++_static.a")
self.global_flags_ld.append("-target armv7-none-linux-androideabi")
self.global_flags_ld.append("-Wl,--fix-cortex-a8")
self.global_flags_ld.append("-Wl,--no-warn-mismatch")
self.global_flags_ld.append("-lm_hard")
elif arch == "mips":
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/mips/"
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
@@ -113,13 +126,16 @@ class Target(target.Target):
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
self.global_flags_ld.append( stdCppBasePath + "libc++_static.a")
else:
self.global_flags_cc.append("-D__STDCPP_GNU__")
# GPL v3 (+ exception link for gcc compilator)
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/include/")
if arch == "ARMv5":
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/android/support/include/")
if arch == "armv5":
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/armeabi/"
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
self.global_flags_ld.append( stdCppBasePath + "thumb/libgnustl_static.a")
self.global_flags_ld.append( stdCppBasePath + "thumb/libsupc++.a")
elif arch == "ARMv7":
elif arch == "armv7":
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/gnu-libstdc++/" + gccVersion + "/libs/armeabi-v7a/"
self.global_include_cc.append("-I" + stdCppBasePath + "include/")
self.global_flags_ld.append( stdCppBasePath + "thumb/libgnustl_static.a")
@@ -145,22 +161,23 @@ class Target(target.Target):
self.global_flags_cc.append("-D__ARM_ARCH_5T__")
self.global_flags_cc.append("-D__ARM_ARCH_5E__")
self.global_flags_cc.append("-D__ARM_ARCH_5TE__")
if self.arch == "ARM":
# -----------------------
# -- arm V5 :
# -----------------------
self.global_flags_cc.append("-march=armv5te")
self.global_flags_cc.append("-msoft-float")
else:
# -----------------------
# -- arm V7 (Neon) :
# -----------------------
self.global_flags_cc.append("-mfpu=neon")
self.global_flags_cc.append("-mfloat-abi=softfp")
self.global_flags_ld.append("-mfpu=neon")
self.global_flags_ld.append("-mfloat-abi=softfp")
self.global_flags_cc.append("-D__ARM_ARCH_7__")
self.global_flags_cc.append("-D__ARM_NEON__")
if self.config["compilator"] != "clang":
if self.arch == "armv5":
# -----------------------
# -- arm V5 :
# -----------------------
self.global_flags_cc.append("-march=armv5te")
self.global_flags_cc.append("-msoft-float")
else:
# -----------------------
# -- arm V7 (Neon) :
# -----------------------
self.global_flags_cc.append("-mfpu=neon")
self.global_flags_cc.append("-mfloat-abi=softfp")
self.global_flags_ld.append("-mfpu=neon")
self.global_flags_ld.append("-mfloat-abi=softfp")
self.global_flags_cc.append("-D__ARM_ARCH_7__")
self.global_flags_cc.append("-D__ARM_NEON__")
# the -mthumb must be set for all the android produc, some ot the not work coretly without this one ... (all android code is generated with this flags)
self.global_flags_cc.append("-mthumb")
@@ -168,20 +185,17 @@ class Target(target.Target):
# -- Common flags :
# -----------------------
self.global_flags_cc.append("-fpic")
self.global_flags_cc.append("-ffunction-sections")
self.global_flags_cc.append("-funwind-tables")
self.global_flags_cc.append("-fstack-protector")
self.global_flags_cc.append("-Wno-psabi")
self.global_flags_cc.append("-mtune=xscale")
self.global_flags_cc.append("-fexceptions")
##self.global_flags_cc.append("-fno-exceptions")
self.global_flags_cc.append("-fomit-frame-pointer")
self.global_flags_cc.append("-fno-strict-aliasing")
if self.config["compilator"] != "clang":
self.global_flags_cc.append("-ffunction-sections")
self.global_flags_cc.append("-funwind-tables")
self.global_flags_cc.append("-fstack-protector")
self.global_flags_cc.append("-Wno-psabi")
self.global_flags_cc.append("-mtune=xscale")
self.global_flags_cc.append("-fomit-frame-pointer")
self.global_flags_cc.append("-fno-strict-aliasing")
self.global_flags_xx.append("-frtti")
self.global_flags_cc.append("-fexceptions")
self.global_flags_xx.append("-Wa,--noexecstack")
def check_right_package(self, pkgProperties, value):
for val in pkgProperties["RIGHT"]:

View File

@@ -61,7 +61,8 @@ class Target(target.Target):
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk"
self.global_flags_ld.append("-miphoneos-version-min=8.0")
self.global_flags_cc.append("-miphoneos-version-min=8.0")
self.global_flags_cc.append("-D__STDCPP_LLVM__")
self.global_flags_ld.append([
"-Xlinker",
"-objc_abi_version",
@@ -71,10 +72,10 @@ class Target(target.Target):
"-stdlib=libc++",
"-fobjc-arc",
"-fobjc-link-runtime"])
self.global_flags_m.append("-fobjc-arc")
#self.global_flags_m.append("-fmodules")
def get_staging_folder(self, binaryName):
return tools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName + ".app/"

View File

@@ -32,6 +32,8 @@ class Target(target.Target):
# 32 bits
if host.BUS_SIZE != 32:
self.global_flags_cc.append("-m32")
self.global_flags_cc.append("-D__STDCPP_GNU__")
def generate_list_separate_coma(self, list):
result = ""

View File

@@ -38,6 +38,8 @@ class Target(target.Target):
self.suffix_binary=''
self.suffix_package=''
self.global_flags_cc.append("-D__STDCPP_LLVM__")
def get_staging_folder(self, binaryName):
return tools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName + ".app/Contents/"

View File

@@ -59,6 +59,7 @@ class Target(target.Target):
self.suffix_lib_dynamic='.dll'
self.suffix_binary='.exe'
self.suffix_package=''
self.global_flags_cc.append("-D__STDCPP_GNU__")
def get_staging_folder_data(self, binaryName):

View File

@@ -7,7 +7,7 @@ def readme():
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
setup(name='lutin',
version='0.5.14',
version='0.6.1',
description='Lutin generic builder',
long_description=readme(),
url='http://github.com/HeeroYui/lutin',