[DEV] correct the target flag methodology

This commit is contained in:
2016-01-08 22:28:31 +01:00
parent 1200434b97
commit 6c3f96c2a9
14 changed files with 174 additions and 183 deletions

View File

@@ -698,49 +698,21 @@ class Module:
else:
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
def append_and_check(self, listout, newElement, order):
for element in listout:
if element==newElement:
return
listout.append(newElement)
if order == True:
if type(newElement) is not dict:
listout.sort()
def append_to_internal_list2(self, listout, module, list, order=False):
# add list in the Map
if module not in listout:
listout[module] = []
# add elements...
self.append_to_internal_list(listout[module], list, order)
def append_to_internal_list(self, out_list, in_list, order=False):
if type(in_list) == str:
self.append_and_check(out_list, in_list, order)
elif type(in_list) == list:
# mulyiple imput in the list ...
for elem in in_list:
self.append_and_check(out_list, elem, order)
elif type(in_list) == dict:
self.append_and_check(out_list, in_list, order)
else:
debug.warning("can not add in list other than {list/dict/str} : " + str(type(in_list)))
def add_module_depend(self, list):
self.append_to_internal_list(self.depends, list, True)
tools.list_append_to(self.depends, list, True)
def add_optionnal_module_depend(self, module_name, compilation_flags=["", ""], export=False):
self.append_and_check(self.depends_optionnal, [module_name, compilation_flags, export], True)
tools.list_append_and_check(self.depends_optionnal, [module_name, compilation_flags, export], True)
def add_path(self, list, type='c'):
self.append_to_internal_list2(self.path["local"], type, list)
tools.list_append_to_2(self.path["local"], type, list)
def add_export_flag(self, type, list):
self.append_to_internal_list2(self.flags["export"], type, list)
tools.list_append_to_2(self.flags["export"], type, list)
# add the link flag at the module
def compile_flags(self, type, list):
self.append_to_internal_list2(self.flags["local"], type, list)
tools.list_append_to_2(self.flags["local"], type, list)
def compile_version(self, compilator_type, version, same_as_api=True, gnu=False):
if compilator_type == "c++" \
@@ -777,7 +749,7 @@ class Module:
debug.warning("Can not set version of compilator:" + str(compilator_type));
def add_src_file(self, list):
self.append_to_internal_list(self.src, list, True)
tools.list_append_to(self.src, list, True)
def add_header_file(self, list, destination_path=None):
if destination_path != None:
@@ -795,10 +767,10 @@ class Module:
else:
new_list.append({"src":elem,
"dst":elem})
self.append_to_internal_list(self.header, new_list, True)
tools.list_append_to(self.header, new_list, True)
def add_export_path(self, list, type='c'):
self.append_to_internal_list2(self.path["export"], type, list)
tools.list_append_to_2(self.path["export"], type, list)
def copy_image(self, source, destination='', sizeX=-1, sizeY=-1):
self.image_to_copy.append([source, destination, sizeX, sizeY])

View File

@@ -15,72 +15,30 @@ import datetime
# Local import
from . import debug
from . import module
from . import tools
class System:
def __init__(self):
self.valid=False;
self.help="";
self.include_cc=[]
self.export_flags_cc=[]
self.export_flags_xx=[]
self.export_flags_xx_remove=[]
self.export_flags_mm=[]
self.export_flags_m=[]
self.export_flags_ar=[]
self.export_flags_ld=[]
self.export_flags_ld_shared=[]
self.export_libs_ld=[]
self.export_libs_ld_shared=[]
self.export_depends=[]
self.export_flags={}
self.export_src=[]
self.export_path=[]
self.action_on_state={}
def append_and_check(self, listout, newElement, order):
for element in listout:
if element==newElement:
return
listout.append(newElement)
if order == True:
listout.sort()
def append_to_internal_list(self, listout, list, order=False):
if type(list) == type(str()):
self.append_and_check(listout, list, order)
else:
# mulyiple imput in the list ...
for elem in list:
self.append_and_check(listout, elem, order)
def add_export_sources(self, list):
self.append_to_internal_list(self.export_src, list)
tools.list_append_to(self.export_src, list)
# todo : add other than C ...
def add_export_path(self, list):
self.append_to_internal_list(self.export_path, list)
tools.list_append_to(self.export_path, list)
def add_module_depend(self, list):
tools.list_append_to(self.export_depends, list, True)
def add_export_flag(self, type, list):
if type == "link":
self.append_to_internal_list(self.export_flags_ld, list)
if type == "link-remove":
# TODO
pass
elif type == "c":
self.append_to_internal_list(self.export_flags_cc, list)
elif type == "c-remove":
# TODO
pass
elif type == "c++":
self.append_to_internal_list(self.export_flags_xx, list)
elif type == "c++-remove":
self.append_to_internal_list(self.export_flags_xx_remove, list)
pass
elif type == "m":
self.append_to_internal_list(self.export_flags_m, list)
elif type == "mm":
self.append_to_internal_list(self.export_flags_mm, list)
else:
debug.warning("no option : '" + str(type) + "'")
tools.list_append_to_2(self.export_flags, type, list)
def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None):
if name_of_state not in self.action_on_add_src_filestate:
@@ -93,16 +51,17 @@ class System:
def create_module_from_system(target, dict):
myModule = module.Module(dict["path"], dict["name"], 'PREBUILD')
myModule.add_export_flag('c', dict["system"].export_flags_cc)
myModule.add_export_flag('link', dict["system"].export_flags_ld)
myModule.add_export_flag('c++', dict["system"].export_flags_xx)
myModule.add_export_flag('c++-remove', dict["system"].export_flags_xx_remove)
myModule.add_export_flag('m', dict["system"].export_flags_m)
myModule.add_export_flag('mm', dict["system"].export_flags_mm)
# add element flags to export
for elem in dict["system"].export_flags:
debug.verbose("add element :" + str(elem) + " elems=" + str(dict["system"].export_flags[elem]))
myModule.add_export_flag(elem, dict["system"].export_flags[elem])
# add module dependency
myModule.add_module_depend(dict["system"].export_depends)
# add exporting sources
myModule.add_src_file(dict["system"].export_src)
# add export path
myModule.add_export_path(dict["system"].export_path)
# Export all actions ...
for elem in dict["system"].action_on_state:
level, name, action = dict["system"].action_on_state[elem]
target.add_action(elem, level, name, action)

View File

@@ -54,11 +54,11 @@ class Target:
# Target global variables.
###############################################################################
self.global_include_cc=[]
"""
self.global_flags_cc=['-D__TARGET_OS__'+self.name,
'-D__TARGET_ARCH__'+self.select_arch,
'-D__TARGET_ADDR__'+self.select_bus + 'BITS',
'-D_REENTRANT']
self.global_flags_xx=[]
self.global_flags_mm=[]
if self.name == "Windows":
@@ -68,6 +68,9 @@ class Target:
self.global_flags_ar=['rcs']
self.global_flags_ld=[]
self.global_flags_ld_shared=[]
"""
self.global_flags={}
self.global_libs_ld=[]
self.global_libs_ld_shared=[]
@@ -86,30 +89,42 @@ class Target:
self.path_generate_code="/generate_header"
self.path_arch="/" + self.name
self.global_flags_xx.append("-nostdlib")
self.add_flag("c", [
'-D__TARGET_OS__' + self.name,
'-D__TARGET_ARCH__' + self.select_arch,
'-D__TARGET_ADDR__' + self.select_bus + 'BITS',
'-D_REENTRANT'
])
self.add_flag("c++", "-nostdlib")
self.add_flag("ar", 'rcs')
if self.name == "Windows":
self.add_flag("c++", ['-static-libgcc', '-static-libstdc++'])
if "debug" == self.config["mode"]:
self.global_flags_cc.append("-g")
self.global_flags_cc.append("-DDEBUG")
self.global_flags_cc.append("-O0")
self.add_flag("c", [
"-g",
"-DDEBUG",
"-O0"
])
else:
self.global_flags_cc.append("-DNDEBUG")
self.global_flags_cc.append("-O3")
self.add_flag("c", [
"-DNDEBUG",
"-O3"
])
## To add code coverate on build result system
if self.config["gcov"] == True:
self.global_flags_cc.append("-fprofile-arcs")
self.global_flags_cc.append("-ftest-coverage")
self.global_flags_ld.append("-fprofile-arcs")
self.global_flags_ld.append("-ftest-coverage")
self.add_flag("c", [
"-fprofile-arcs",
"-ftest-coverage"
])
self.add_flag("link", [
"-fprofile-arcs",
"-ftest-coverage"
])
self.update_path_tree()
"""
self.path_bin="usr/bin"
self.path_lib="usr/lib"
self.path_data="usr/share"
self.path_doc="usr/share/doc"
"""
self.path_bin="bin"
self.path_lib="lib"
self.path_data="share"
@@ -139,6 +154,9 @@ class Target:
# special case for IOS (example) no build dynamicly ...
self.support_dynamic_link = True
def add_flag(self, type, list):
tools.list_append_to_2(self.global_flags, type, list)
def update_path_tree(self):
self.path_out = os.path.join("out", self.name + "_" + self.config["arch"] + "_" + self.config["bus-size"], self.config["mode"])
self.path_final = os.path.join("final", self.config["compilator"])

View File

@@ -300,3 +300,31 @@ def store_warning(file, output, err):
file2.close()
## List tools:
def list_append_and_check(listout, newElement, order):
for element in listout:
if element==newElement:
return
listout.append(newElement)
if order == True:
if type(newElement) is not dict:
listout.sort()
def list_append_to(out_list, in_list, order=False):
if type(in_list) == str:
list_append_and_check(out_list, in_list, order)
elif type(in_list) == list:
# mulyiple imput in the list ...
for elem in in_list:
list_append_and_check(out_list, elem, order)
elif type(in_list) == dict:
list_append_and_check(out_list, in_list, order)
else:
debug.warning("can not add in list other than {list/dict/str} : " + str(type(in_list)))
def list_append_to_2(listout, module, list, order=False):
# add list in the Map
if module not in listout:
listout[module] = []
# add elements...
list_append_to(listout[module], list, order)

View File

@@ -68,7 +68,7 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module
except:
pass
try:
cmd.append(target.global_flags_cc)
cmd.append(target.global_flags["c"])
except:
pass
try:

View File

@@ -77,11 +77,11 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module
pass
list_flags = [];
try:
list_flags.append(target.global_flags_cc)
list_flags.append(target.global_flags["c"])
except:
pass
try:
list_flags.append(target.global_flags_xx)
list_flags.append(target.global_flags["c++"])
except:
pass
for type in ["c", "c++"]:
@@ -98,11 +98,11 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module
# get blacklist of flags
list_flags_blacklist = [];
try:
list_flags_blacklist.append(target.global_flags_cc_remove)
list_flags_blacklist.append(target.global_flags["c-remove"])
except:
pass
try:
list_flags_blacklist.append(target.global_flags_xx_remove)
list_flags_blacklist.append(target.global_flags["c++-remove"])
except:
pass
for type in ["c-remove", "c++-remove"]:

View File

@@ -110,7 +110,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
cmdLine=tools.list_to_str(cmd)

View File

@@ -45,7 +45,7 @@ def link(file, binary, target, depancy, flags, name, basic_path):
target.ar
]
try:
cmd.append(target.global_flags_ar)
cmd.append(target.global_flags["ar"])
except:
pass
try:

View File

@@ -70,11 +70,11 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module
except:
pass
try:
cmd.append(target.global_flags_cc)
cmd.append(target.global_flags["c"])
except:
pass
try:
cmd.append(target.global_flags_m)
cmd.append(target.global_flags["m"])
except:
pass
for type in ["c", "m"]:

View File

@@ -69,14 +69,11 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module
cmd.append(local_ref_on_builder_cpp.get_version_compilation_flags(flags, depancy.flags))
except:
pass
try:
cmd.append(target.global_flags_cc)
except:
pass
try:
cmd.append(target.global_flags_mm)
except:
pass
for type in ["c", "c++", "m", "mm"]:
try:
cmd.append(target.global_flags[type])
except:
pass
for type in ["c", "c++", "m", "mm"]:
try:
cmd.append(depancy.flags[type])

View File

@@ -110,7 +110,7 @@ class Target(target.Target):
if self.board_id == 0:
debug.error("Can not find BOARD-ID ==> update your android SDK")
self.global_flags_cc.append("-D__ANDROID_BOARD_ID__=" + str(self.board_id))
self.add_flag("c", "-D__ANDROID_BOARD_ID__=" + str(self.board_id))
if self.type_arch == "armv5" or self.type_arch == "armv7":
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-arm", "usr", "include"))
elif self.type_arch == "mips":
@@ -126,14 +126,18 @@ class Target(target.Target):
pass
elif self.type_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")
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")
self.add_flag("c", [
"-target armv7-none-linux-androideabi",
"-march=armv7-a",
"-mfpu=vfpv3-d16",
"-mhard-float"
])
self.add_flag("link", [
"-target armv7-none-linux-androideabi",
"-Wl,--fix-cortex-a8",
"-Wl,--no-warn-mismatch",
"-lm_hard"
])
elif self.type_arch == "mips":
pass
elif self.type_arch == "x86":
@@ -150,45 +154,57 @@ class Target(target.Target):
self.global_sysroot = "--sysroot=" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-arm")
self.global_flags_cc.append("-D__ARM_ARCH_5__")
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__")
self.add_flag("c", [
"-D__ARM_ARCH_5__",
"-D__ARM_ARCH_5T__",
"-D__ARM_ARCH_5E__",
"-D__ARM_ARCH_5TE__"
])
if self.config["compilator"] != "clang":
if self.type_arch == "armv5":
# -----------------------
# -- arm V5 :
# -----------------------
self.global_flags_cc.append("-march=armv5te")
self.global_flags_cc.append("-msoft-float")
self.add_flag("c", [
"-march=armv5te",
"-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__")
self.add_flag("c", [
"-mfpu=neon",
"-mfloat-abi=softfp",
"-D__ARM_ARCH_7__",
"-D__ARM_NEON__"
])
self.add_flag("link", [
"-mfpu=neon",
"-mfloat-abi=softfp"
])
# 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")
self.add_flag("c", "-mthumb")
# -----------------------
# -- Common flags :
# -----------------------
self.global_flags_cc.append("-fpic")
self.add_flag("c", "-fpic")
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")
self.add_flag("c", [
"-ffunction-sections",
"-funwind-tables",
"-fstack-protector",
"-Wno-psabi",
"-mtune=xscale",
"-fomit-frame-pointer",
"-fno-strict-aliasing"
])
self.add_flag("c++", [
"-frtti",
"-fexceptions",
"-Wa,--noexecstack"
])
def check_right_package(self, pkg_properties, value):
for val in pkg_properties["RIGHT"]:

View File

@@ -28,13 +28,13 @@ class Target(target.Target):
if self.config["bus-size"] == "64":
# 64 bits
if host.BUS_SIZE != 64:
self.global_flags_cc.append("-m64")
self.add_flag("c", "-m64")
else:
# 32 bits
if host.BUS_SIZE != 32:
self.global_flags_cc.append("-m32")
self.add_flag("c", "-m32")
self.global_flags_cc.append("-fpic")
self.add_flag("c", "-fpic")
self.pkg_path_data = "share"
self.pkg_path_bin = "bin"

View File

@@ -56,25 +56,26 @@ class Target(target.Target):
if self.sumulator == True:
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
self.global_flags_ld.append("-mios-simulator-version-min=8.0")
self.global_flags_cc.append("-mios-simulator-version-min=8.0")
self.add_flag("link", "-mios-simulator-version-min=8.0")
self.add_flag("c", "-mios-simulator-version-min=8.0")
else:
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
self.global_flags_ld.append("-miphoneos-version-min=8.0")
self.global_flags_cc.append("-miphoneos-version-min=8.0")
self.add_flag("link", "-miphoneos-version-min=8.0")
self.add_flag("c", "-miphoneos-version-min=8.0")
self.global_flags_ld.append([
"-Xlinker",
"-objc_abi_version",
"-Xlinker 2",
"-Xlinker",
"-no_implicit_dylibs",
"-stdlib=libc++",
"-fobjc-arc",
"-fobjc-link-runtime"])
self.add_flag("link", [
"-Xlinker",
"-objc_abi_version",
"-Xlinker 2",
"-Xlinker",
"-no_implicit_dylibs",
"-stdlib=libc++",
"-fobjc-arc",
"-fobjc-link-runtime"
])
self.global_flags_m.append("-fobjc-arc")
#self.global_flags_m.append("-fmodules")
self.add_flag("m", ["-fobjc-arc")
#self.add_flag("m", ["-fmodules")
self.pkg_path_data = "share"
self.pkg_path_bin = ""

View File

@@ -28,13 +28,13 @@ class Target(target.Target):
if self.config["bus-size"] == "64":
# 64 bits
if host.BUS_SIZE != 64:
self.global_flags_cc.append("-m64")
self.add_flag("c", "-m64")
else:
# 32 bits
if host.BUS_SIZE != 32:
self.global_flags_cc.append("-m32")
self.add_flag("c", "-m32")
self.global_flags_cc.append("-fpic")
self.add_flag("c", "-fpic")
self.pkg_path_data = "share"
self.pkg_path_bin = "bin"