[DEV] Rework API of the c++ lib to be more versatil and permit to have local c++ lib

This commit is contained in:
Edouard DUPIN 2016-01-07 21:46:43 +01:00
parent 6c431ad300
commit 1200434b97
26 changed files with 538 additions and 133 deletions

View File

@ -82,7 +82,7 @@ class Module:
self.origin_file = file; self.origin_file = file;
self.origin_path = tools.get_current_path(self.origin_file) self.origin_path = tools.get_current_path(self.origin_file)
self.local_heritage = heritage.heritage(self, None) self.local_heritage = heritage.heritage(self, None)
# TODO : Do a better dynamic property system => not really versatil
self.package_prop = { "COMPAGNY_TYPE" : "", self.package_prop = { "COMPAGNY_TYPE" : "",
"COMPAGNY_NAME" : "", "COMPAGNY_NAME" : "",
"COMPAGNY_NAME2" : "", "COMPAGNY_NAME2" : "",
@ -627,6 +627,14 @@ class Module:
include_path = target.get_build_path_include(self.name) include_path = target.get_build_path_include(self.name)
for file in self.header: for file in self.header:
src_path = os.path.join(self.origin_path, file["src"]) 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=False,
force_identical=True,
in_list=copy_list)
else:
dst_path = os.path.join(include_path, file["dst"]) dst_path = os.path.join(include_path, file["dst"])
tools.copy_file(src_path, tools.copy_file(src_path,
dst_path, dst_path,
@ -773,12 +781,17 @@ class Module:
def add_header_file(self, list, destination_path=None): def add_header_file(self, list, destination_path=None):
if destination_path != None: if destination_path != None:
debug.verbose("Change destination PATH: " + str(destination_path)) debug.verbose("Change destination PATH: '" + str(destination_path) + "'")
new_list = [] new_list = []
for elem in list: for elem in list:
if destination_path != None: if destination_path != None:
base = os.path.basename(elem)
if '*' in base or '[' in base or '(' in base:
new_list.append({"src":elem, new_list.append({"src":elem,
"dst":os.path.join(destination_path, os.path.basename(elem))}) "multi-dst":destination_path})
else:
new_list.append({"src":elem,
"dst":os.path.join(destination_path, base)})
else: else:
new_list.append({"src":elem, new_list.append({"src":elem,
"dst":elem}) "dst":elem})

View File

@ -23,6 +23,7 @@ class System:
self.include_cc=[] self.include_cc=[]
self.export_flags_cc=[] self.export_flags_cc=[]
self.export_flags_xx=[] self.export_flags_xx=[]
self.export_flags_xx_remove=[]
self.export_flags_mm=[] self.export_flags_mm=[]
self.export_flags_m=[] self.export_flags_m=[]
self.export_flags_ar=[] self.export_flags_ar=[]
@ -31,6 +32,7 @@ class System:
self.export_libs_ld=[] self.export_libs_ld=[]
self.export_libs_ld_shared=[] self.export_libs_ld_shared=[]
self.export_src=[] self.export_src=[]
self.export_path=[]
self.action_on_state={} self.action_on_state={}
def append_and_check(self, listout, newElement, order): def append_and_check(self, listout, newElement, order):
@ -38,7 +40,7 @@ class System:
if element==newElement: if element==newElement:
return return
listout.append(newElement) listout.append(newElement)
if True==order: if order == True:
listout.sort() listout.sort()
def append_to_internal_list(self, listout, list, order=False): def append_to_internal_list(self, listout, list, order=False):
@ -49,26 +51,39 @@ class System:
for elem in list: for elem in list:
self.append_and_check(listout, elem, order) self.append_and_check(listout, elem, order)
def add_export_flag_LD(self, list): def add_export_sources(self, list):
self.append_to_internal_list(self.export_flags_ld, list)
def add_export_flag_CC(self, list):
self.append_to_internal_list(self.export_flags_cc, list)
def add_export_flag_XX(self, list):
self.append_to_internal_list(self.export_flags_xx, list)
def add_export_flag_M(self, list):
self.append_to_internal_list(self.export_flags_m, list)
def add_export_flag_MM(self, list):
self.append_to_internal_list(self.export_flags_mm, list)
def add_export_SRC(self, list):
self.append_to_internal_list(self.export_src, list) self.append_to_internal_list(self.export_src, list)
# todo : add other than C ...
def add_export_path(self, list):
self.append_to_internal_list(self.export_path, list)
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) + "'")
def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None): def add_action(self, name_of_state="PACKAGE", level=5, name="no-name", action=None):
if name_of_state not in self.action_on_state: if name_of_state not in self.action_on_add_src_filestate:
self.action_on_state[name_of_state] = [[level, name, action]] self.action_on_state[name_of_state] = [[level, name, action]]
else: else:
self.action_on_state[name_of_state].append([level, name, action]) self.action_on_state[name_of_state].append([level, name, action])
@ -76,15 +91,17 @@ class System:
def createModuleFromSystem(target, dict): def create_module_from_system(target, dict):
myModule = module.Module(dict["path"], dict["name"], 'PREBUILD') myModule = module.Module(dict["path"], dict["name"], 'PREBUILD')
myModule.add_export_flag('c', dict["system"].export_flags_cc) myModule.add_export_flag('c', dict["system"].export_flags_cc)
myModule.add_export_flag('link', dict["system"].export_flags_ld) 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++', 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('m', dict["system"].export_flags_m)
myModule.add_export_flag('mm', dict["system"].export_flags_mm) myModule.add_export_flag('mm', dict["system"].export_flags_mm)
myModule.add_src_file(dict["system"].export_src) myModule.add_src_file(dict["system"].export_src)
myModule.add_export_path(dict["system"].export_path)
for elem in dict["system"].action_on_state: for elem in dict["system"].action_on_state:
level, name, action = dict["system"].action_on_state[elem] level, name, action = dict["system"].action_on_state[elem]
@ -172,7 +189,7 @@ def load(target, lib_name, target_name):
debug.error("you must call this function after checking of the system exist() !2!") debug.error("you must call this function after checking of the system exist() !2!")
if data["module"] == None: if data["module"] == None:
# create a module from the system interface... # create a module from the system interface...
data["module"] = createModuleFromSystem(target, data) data["module"] = create_module_from_system(target, data)
data["loaded"] = True data["loaded"] = True
target.add_module(data["module"]) target.add_module(data["module"])
return return

View File

@ -86,6 +86,8 @@ class Target:
self.path_generate_code="/generate_header" self.path_generate_code="/generate_header"
self.path_arch="/" + self.name self.path_arch="/" + self.name
self.global_flags_xx.append("-nostdlib")
if "debug" == self.config["mode"]: if "debug" == self.config["mode"]:
self.global_flags_cc.append("-g") self.global_flags_cc.append("-g")
self.global_flags_cc.append("-DDEBUG") self.global_flags_cc.append("-DDEBUG")

View File

@ -36,6 +36,13 @@ def get_input_type():
def get_output_type(): def get_output_type():
return ["o"] return ["o"]
def remove_element(data, to_remove):
out = []
for elem in data:
if elem not in to_remove:
out.append(elem)
return out;
## ##
## @brief Commands for running gcc to compile a C++ file in object file. ## @brief Commands for running gcc to compile a C++ file in object file.
## ##
@ -68,25 +75,49 @@ def compile(file, binary, target, depancy, flags, path, name, basic_path, module
cmd.append(get_version_compilation_flags(flags, depancy.flags)) cmd.append(get_version_compilation_flags(flags, depancy.flags))
except: except:
pass pass
list_flags = [];
try: try:
cmd.append(target.global_flags_cc) list_flags.append(target.global_flags_cc)
except: except:
pass pass
try: try:
cmd.append(target.global_flags_xx) list_flags.append(target.global_flags_xx)
except: except:
pass pass
for type in ["c", "c++"]: for type in ["c", "c++"]:
try: try:
cmd.append(depancy.flags[type]) list_flags.append(depancy.flags[type])
except: except:
pass pass
for view in ["local", "export"]: for view in ["local", "export"]:
for type in ["c", "c++"]: for type in ["c", "c++"]:
try: try:
cmd.append(flags[view][type]) list_flags.append(flags[view][type])
except: except:
pass pass
# get blacklist of flags
list_flags_blacklist = [];
try:
list_flags_blacklist.append(target.global_flags_cc_remove)
except:
pass
try:
list_flags_blacklist.append(target.global_flags_xx_remove)
except:
pass
for type in ["c-remove", "c++-remove"]:
try:
list_flags_blacklist.append(depancy.flags[type])
except:
pass
for view in ["local", "export"]:
for type in ["c-remove", "c++-remove"]:
try:
list_flags_blacklist.append(flags[view][type])
except:
pass
# apply blacklisting of data and add it on the cmdLine
cmd.append(remove_element(list_flags, list_flags_blacklist));
cmd.append(["-c", "-MMD", "-MP"]) cmd.append(["-c", "-MMD", "-MP"])
cmd.append(file_src) cmd.append(file_src)
# Create cmd line # Create cmd line

View File

@ -20,7 +20,7 @@ class System(system.System):
# todo : Check if present ... # todo : Check if present ...
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_SRC(target.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar") self.add_export_sources(target.path_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar")
self.add_action("PACKAGE", 10, "admod-auto-wrapper", tool_generate_main_java_class) self.add_action("PACKAGE", 10, "admod-auto-wrapper", tool_generate_main_java_class)

View File

@ -22,9 +22,9 @@ class System(system.System):
# TODO : Check if the android sdk android.jar is present ... # TODO : Check if the android sdk android.jar is present ...
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_SRC(jar_file_path) self.add_export_sources(jar_file_path)
self.add_export_flag_LD("-ldl") self.add_export_flag("link", "-ldl")
self.add_export_flag_LD("-llog") self.add_export_flag("link", "-llog")
self.add_export_flag_LD("-landroid") self.add_export_flag("link", "-landroid")

View File

@ -0,0 +1,74 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
from lutin import debug
from lutin import system
from lutin import tools
import os
class System(system.System):
def __init__(self, target):
system.System.__init__(self)
# create some HELP:
self.help = "CXX: Generic C++ library"
self.valid = True
if target.config["compilator"] == "clang":
if target.board_id < 21:
debug.error("Clang work only with the board wersion >= 21 : android 5.x.x")
self.valid = False
return
self.add_export_flag("c++", "-D__STDCPP_LLVM__")
# llvm is BSD-like licence
self.add_export_path(os.path.join(target.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libcxx", "include"))
if target.type_arch == "armv5":
stdCppBasePath = os.path.join(target.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libcxx", "libs", "armeabi")
self.add_export_path( os.path.join(stdCppBasePath, "include"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "libc++_static.a"))
elif target.type_arch == "armv7":
stdCppBasePath = os.path.join(target.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libs", "armeabi-v7a")
self.add_export_path( os.path.join(stdCppBasePath + "include"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "thumb", "libc++_static.a"))
elif target.type_arch == "mips":
stdCppBasePath = os.path.join(target.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libcxx", "libs", "mips")
self.add_export_path( os.path.join(stdCppBasePath + "include"))
self.add_export_flag("link", os.path.join(stdCppBasePath + "libc++_static.a"))
elif target.type_arch == "x86":
stdCppBasePath = os.path.join(target.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libcxx", "libs", "x86")
self.add_export_path( os.path.join(stdCppBasePath, "include"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "libc++_static.a"))
else:
debug.warning("unknow architecture: '" + str(target.arch) + "'");
else:
self.add_export_flag("c++", "-D__STDCPP_GNU__")
self.add_export_flag("c++-remove","-nostdlib")
# GPL v3 (+ exception link for gcc compilator)
self.add_export_path(os.path.join(target.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", target.compilator_version, "include"))
if target.type_arch == "armv5":
stdCppBasePath = os.path.join(target.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", target.compilator_version, "libs", "armeabi")
self.add_export_path( os.path.join(stdCppBasePath, "include"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "thumb", "libgnustl_static.a"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "thumb", "libsupc++.a"))
elif target.type_arch == "armv7":
stdCppBasePath = os.path.join(target.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", target.compilator_version, "libs", "armeabi-v7a")
self.add_export_path( os.path.join(stdCppBasePath, "include"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "thumb", "libgnustl_static.a"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "thumb", "libsupc++.a"))
elif target.type_arch == "mips":
stdCppBasePath = os.path.join(target.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", target.compilator_version, "libs", "mips")
self.add_export_path( os.path.join(stdCppBasePath, "include/"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "libgnustl_static.a"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "libsupc++.a"))
elif target.type_arch == "x86":
stdCppBasePath = os.path.join(target.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", target.compilator_version, "libs", "x86")
self.add_export_path( os.path.join(stdCppBasePath, "include"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "libgnustl_static.a"))
self.add_export_flag("link", os.path.join(stdCppBasePath, "libsupc++.a"))
else:
debug.warning("unknow architecture: '" + str(target.arch) + "'");
debug.warning("plop")

View File

@ -19,7 +19,7 @@ class System(system.System):
self.help="CoreAudio : Ios interface for audio (all time present, just system interface)" self.help="CoreAudio : Ios interface for audio (all time present, just system interface)"
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_LD("-framework CoreAudio") self.add_export_flag("link", "-framework CoreAudio")
self.add_export_flag_LD("-framework AudioToolbox") self.add_export_flag("link", "-framework AudioToolbox")

View File

@ -0,0 +1,25 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
from lutin import debug
from lutin import system
from lutin import tools
import os
class System(system.System):
def __init__(self, target):
system.System.__init__(self)
# create some HELP:
self.help = "CXX: Generic C++ library"
self.valid = True
# no check needed ==> just add this:
self.add_export_flag("c++","-D__STDCPP_LLVM__")
self.add_export_flag("c++-remove","-nostdlib")

View File

@ -24,6 +24,6 @@ class System(system.System):
return; return;
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_LD("-lasound") self.add_export_flag("link", "-lasound")

View File

@ -23,7 +23,7 @@ class System(system.System):
return; return;
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_LD([ self.add_export_flag("link", [
"-lboost_system", "-lboost_system",
"-lboost_thread", "-lboost_thread",
"-lboost_chrono" "-lboost_chrono"

View File

@ -0,0 +1,25 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
from lutin import debug
from lutin import system
from lutin import tools
import os
class System(system.System):
def __init__(self, target):
system.System.__init__(self)
# create some HELP:
self.help = "CXX: Generic C++ library"
self.valid = True
# no check needed ==> just add this:
self.add_export_flag("c++","-D__STDCPP_GNU__")
self.add_export_flag("c++-remove","-nostdlib")

View File

@ -23,6 +23,6 @@ class System(system.System):
return; return;
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_LD("-ljack") self.add_export_flag("link", "-ljack")

View File

@ -24,7 +24,7 @@ class System(system.System):
return; return;
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_CC("-ljack") self.add_export_flag("link", "-ljack")
""" """

View File

@ -23,6 +23,6 @@ class System(system.System):
return; return;
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_LD(["-lpulse-simple", "-lpulse"]) self.add_export_flag("link", ["-lpulse-simple", "-lpulse"])

View File

@ -23,6 +23,6 @@ class System(system.System):
return; return;
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_LD(["-lz"]) self.add_export_flag("link", "-lz")

View File

@ -19,6 +19,6 @@ class System(system.System):
self.help="CoreAudio : MacOs interface for audio (all time present, just system interface)" self.help="CoreAudio : MacOs interface for audio (all time present, just system interface)"
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_LD("-framework CoreAudio") self.add_export_flag("link", "-framework CoreAudio")
self.add_export_flag_LD("-framework CoreFoundation") self.add_export_flag("link", "-framework CoreFoundation")

View File

@ -0,0 +1,25 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
from lutin import debug
from lutin import system
from lutin import tools
import os
class System(system.System):
def __init__(self, target):
system.System.__init__(self)
# create some HELP:
self.help = "CXX: Generic C++ library"
self.valid = True
# no check needed ==> just add this:
self.add_export_flag("c++","-D__STDCPP_LLVM__")
self.add_export_flag("c++-remove","-nostdlib")

View File

@ -0,0 +1,31 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
from lutin import debug
from lutin import system
from lutin import tools
import os
class System(system.System):
def __init__(self, target):
system.System.__init__(self)
# create some HELP:
self.help = "CXX: Generic C++ library"
self.valid = True
# no check needed ==> just add this:
self.add_export_flag("c++","-D__STDCPP_GNU__")
self.add_export_flag("c++-remove","-nostdlib")
# force static link to prenvent many errors ...
self.add_export_flag("link", [
"-static-libgcc",
"-static-libstdc++",
"-static"
])

View File

@ -23,7 +23,8 @@ class System(system.System):
return; return;
self.valid = True self.valid = True
# todo : create a searcher of the presence of the library: # todo : create a searcher of the presence of the library:
self.add_export_flag_LD(["-ldsound", self.add_export_flag("link",[
"-ldsound",
"-lwinmm", "-lwinmm",
"-lole32" "-lole32"
]) ])

View File

@ -25,13 +25,14 @@ class Target(target.Target):
#bus size selection (auto/32/64) #bus size selection (auto/32/64)
if config["bus-size"] == "auto": if config["bus-size"] == "auto":
config["bus-size"] = "32" config["bus-size"] = "32"
arch = "" self.type_arch = ""
target.Target.__init__(self, "Android", config, arch) target.Target.__init__(self, "Android", config, self.type_arch)
debug.warning("plop " + str(self.ar))
if config["bus-size"] == "32": if config["bus-size"] == "32":
arch="armv7" self.type_arch="armv7"
else: else:
arch="arm64" self.type_arch="arm64"
self.path_ndk = os.getenv('PROJECT_NDK', "AUTO") self.path_ndk = os.getenv('PROJECT_NDK', "AUTO")
self.path_sdk = os.getenv('PROJECT_SDK', "AUTO") self.path_sdk = os.getenv('PROJECT_SDK', "AUTO")
@ -60,10 +61,14 @@ class Target(target.Target):
tmpOsVal = "64" tmpOsVal = "64"
gccVersion = "4.9" gccVersion = "4.9"
# TODO : Remove this or set it better ...
self.compilator_version = gccVersion
if host.BUS_SIZE==64: if host.BUS_SIZE==64:
tmpOsVal = "_64" tmpOsVal = "_64"
if self.config["compilator"] == "clang": if self.config["compilator"] == "clang":
self.set_cross_base(self.path_ndk + "/toolchains/llvm-3.6/prebuilt/linux-x86" + tmpOsVal + "/bin/") self.set_cross_base(self.path_ndk + "/toolchains/llvm-3.6/prebuilt/linux-x86" + tmpOsVal + "/bin/")
# Patch for LLVM AR tool
self.ar = self.cross + "llvm-ar"
else: else:
basepathArm = self.path_ndk + "/toolchains/arm-linux-androideabi-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/" basepathArm = self.path_ndk + "/toolchains/arm-linux-androideabi-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
basepathMips = self.path_ndk + "/toolchains/mipsel-linux-android-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/" basepathMips = self.path_ndk + "/toolchains/mipsel-linux-android-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
@ -106,75 +111,42 @@ class Target(target.Target):
debug.error("Can not find BOARD-ID ==> update your android SDK") 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.global_flags_cc.append("-D__ANDROID_BOARD_ID__=" + str(self.board_id))
if arch == "armv5" or arch == "armv7": 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")) self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-arm", "usr", "include"))
elif arch == "mips": elif self.type_arch == "mips":
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-mips", "usr", "include")) self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-mips", "usr", "include"))
elif arch == "x86": elif self.type_arch == "x86":
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-x86", "usr", "include")) self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-x86", "usr", "include"))
if True:
if self.config["compilator"] == "clang":
if self.board_id < 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 " + os.path.join(self.path_ndk, "sources", "android", "support", "include"))
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "sources", "android", "support", "include")) self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "sources", "android", "support", "include"))
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libcxx", "include"))
if arch == "armv5": if self.config["compilator"] == "clang":
stdCppBasePath = os.path.join(self.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libcxx", "libs", "armeabi") self.global_include_cc.append("-gcc-toolchain " + os.path.join(self.path_ndk, "sources", "android", "support", "include"))
self.global_include_cc.append("-I" + os.path.join(stdCppBasePath, "include")) if self.type_arch == "armv5":
self.global_flags_ld.append( os.path.join(stdCppBasePath, "libc++_static.a")) pass
elif arch == "armv7": elif self.type_arch == "armv7":
# The only one tested ... ==> but we have link error ... # The only one tested ... ==> but we have link error ...
self.global_flags_cc.append("-target armv7-none-linux-androideabi") self.global_flags_cc.append("-target armv7-none-linux-androideabi")
self.global_flags_cc.append("-march=armv7-a") self.global_flags_cc.append("-march=armv7-a")
self.global_flags_cc.append("-mfpu=vfpv3-d16") self.global_flags_cc.append("-mfpu=vfpv3-d16")
self.global_flags_cc.append("-mhard-float") self.global_flags_cc.append("-mhard-float")
stdCppBasePath = os.path.join(self.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libs", "armeabi-v7a")
self.global_flags_ld.append( os.path.join(stdCppBasePath, "thumb", "libc++_static.a"))
self.global_flags_ld.append("-target armv7-none-linux-androideabi") 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,--fix-cortex-a8")
self.global_flags_ld.append("-Wl,--no-warn-mismatch") self.global_flags_ld.append("-Wl,--no-warn-mismatch")
self.global_flags_ld.append("-lm_hard") self.global_flags_ld.append("-lm_hard")
elif arch == "mips": elif self.type_arch == "mips":
stdCppBasePath = os.path.join(self.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libcxx", "libs", "mips") pass
self.global_include_cc.append("-I" + os.path.join(stdCppBasePath + "include")) elif self.type_arch == "x86":
self.global_flags_ld.append( os.path.join(stdCppBasePath + "libc++_static.a")) pass
elif arch == "x86":
stdCppBasePath = os.path.join(self.path_ndk, "sources", "cxx-stl", "llvm-libc++", "libcxx", "libs", "x86")
self.global_include_cc.append("-I" + os.path.join(stdCppBasePath, "include"))
self.global_flags_ld.append( os.path.join(stdCppBasePath, "libc++_static.a"))
else: else:
self.global_flags_cc.append("-D__STDCPP_GNU__") if self.type_arch == "armv5":
# GPL v3 (+ exception link for gcc compilator) pass
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", gccVersion, "include")) elif self.type_arch == "armv7":
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "sources", "android", "support", "include")) pass
if arch == "armv5": elif self.type_arch == "mips":
stdCppBasePath = os.path.join(self.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", gccVersion, "libs", "armeabi") pass
self.global_include_cc.append("-I" + os.path.join(stdCppBasePath, "include")) elif self.type_arch == "x86":
self.global_flags_ld.append( os.path.join(stdCppBasePath, "thumb", "libgnustl_static.a")) pass
self.global_flags_ld.append( os.path.join(stdCppBasePath, "thumb", "libsupc++.a"))
elif arch == "armv7":
stdCppBasePath = os.path.join(self.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", gccVersion, "libs", "armeabi-v7a")
self.global_include_cc.append("-I" + os.path.join(stdCppBasePath, "include"))
self.global_flags_ld.append( os.path.join(stdCppBasePath, "thumb", "libgnustl_static.a"))
self.global_flags_ld.append( os.path.join(stdCppBasePath, "thumb", "libsupc++.a"))
elif arch == "mips":
stdCppBasePath = os.path.join(self.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", gccVersion, "libs", "mips")
self.global_include_cc.append("-I" + os.path.join(stdCppBasePath, "include/"))
self.global_flags_ld.append( os.path.join(stdCppBasePath, "libgnustl_static.a"))
self.global_flags_ld.append( os.path.join(stdCppBasePath, "libsupc++.a"))
elif arch == "x86":
stdCppBasePath = os.path.join(self.path_ndk, "sources", "cxx-stl", "gnu-libstdc++", gccVersion, "libs", "x86")
self.global_include_cc.append("-I" + os.path.join(stdCppBasePath, "include"))
self.global_flags_ld.append( os.path.join(stdCppBasePath, "libgnustl_static.a"))
self.global_flags_ld.append( os.path.join(stdCppBasePath, "libsupc++.a"))
else :
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "sources", "cxx-stl", "system", "include"))
self.global_include_cc.append("-I" + os.path.join(self.path_ndk, "sources", "cxx-stl", "stlport", "stlport"))
self.global_flags_ld.append(os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-arm", "usr", "lib", "libstdc++.a"))
self.global_sysroot = "--sysroot=" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-arm") self.global_sysroot = "--sysroot=" + os.path.join(self.path_ndk, "platforms", "android-" + str(self.board_id), "arch-arm")
@ -183,7 +155,7 @@ class Target(target.Target):
self.global_flags_cc.append("-D__ARM_ARCH_5E__") self.global_flags_cc.append("-D__ARM_ARCH_5E__")
self.global_flags_cc.append("-D__ARM_ARCH_5TE__") self.global_flags_cc.append("-D__ARM_ARCH_5TE__")
if self.config["compilator"] != "clang": if self.config["compilator"] != "clang":
if self.arch == "armv5": if self.type_arch == "armv5":
# ----------------------- # -----------------------
# -- arm V5 : # -- arm V5 :
# ----------------------- # -----------------------

View File

@ -0,0 +1,199 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
from lutin import debug
from lutin import target
from lutin import tools
import os
import stat
import re
from lutin import host
from lutin import multiprocess
class Target(target.Target):
def __init__(self, config):
#processor type selection (auto/arm/ppc/x86)
if config["arch"] == "auto":
config["arch"] = "x86"
#bus size selection (auto/32/64)
if config["bus-size"] == "auto":
config["bus-size"] = str(host.BUS_SIZE)
target.Target.__init__(self, "Linux", config, "")
if self.config["bus-size"] == "64":
# 64 bits
if host.BUS_SIZE != 64:
self.global_flags_cc.append("-m64")
else:
# 32 bits
if host.BUS_SIZE != 32:
self.global_flags_cc.append("-m32")
self.global_flags_cc.append("-fpic")
self.pkg_path_data = "share"
self.pkg_path_bin = "bin"
self.pkg_path_lib = "lib"
self.pkg_path_license = "license"
"""
.local/application
*--> applName -> applName.app/bin/applName
*--> applName.app
*--> appl_description.txt
*--> appl_name.txt
*--> changelog.txt
*--> copyright.txt
*--> readme.txt
*--> version.txt
*--> website.txt
*--> icon.png
*--> bin
* *--> applName
*--> doc
* *--> applName
*--> lib
* *--> XX.so
* *--> YY.so
*--> license
* *--> applName.txt
* *--> libXX.txt
* *--> libYY.txt
*--> man
*--> share
* *--> applName
* *--> XX
* *--> YY
*--> sources
"""
def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
debug.debug("------------------------------------------------------------------------")
debug.info("Generate generic '" + pkg_name + "' v" + tools.version_to_string(pkg_properties["VERSION"]))
debug.debug("------------------------------------------------------------------------")
#output path
target_outpath = os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
tools.create_directory_of_file(target_outpath)
## Create share datas:
self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
## copy binary files:
self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
## Create libraries:
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
## Create generic files:
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
## create the package:
debug.debug("package : " + self.get_staging_path(pkg_name) + "/" + pkg_name + ".app.pkg")
os.system("cd " + self.get_staging_path(pkg_name) + " ; tar -czf " + pkg_name + ".app.tar.gz " + pkg_name + ".app")
#multiprocess.run_command("cd " + self.get_staging_path(pkg_name) + " ; tar -czf " + pkg_name + ".app.tar.gz " + pkg_name + ".app")
tools.create_directory_of_file(self.get_final_path())
tools.copy_file(self.get_staging_path(pkg_name) + "/" + pkg_name + ".app.tar.gz", self.get_final_path() + "/" + pkg_name + ".app.gpkg")
def make_package_debian(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):
# http://alp.developpez.com/tutoriels/debian/creer-paquet/
debianpkg_name = re.sub("_", "-", pkg_name)
debug.debug("------------------------------------------------------------------------")
debug.info("Generate package '" + debianpkg_name + "' v"+pkg_properties["VERSION"])
debug.debug("------------------------------------------------------------------------")
self.get_staging_path(pkg_name)
target_outpathDebian = self.get_staging_path(pkg_name) + "/DEBIAN/"
finalFileControl = target_outpathDebian + "control"
finalFilepostRm = target_outpathDebian + "postrm"
# create the paths :
tools.create_directory_of_file(finalFileControl)
tools.create_directory_of_file(finalFilepostRm)
## Create the control file
tools.create_directory_of_file(finalFileControl)
tmpFile = open(finalFileControl, 'w')
tmpFile.write("Package: " + debianpkg_name + "\n")
tmpFile.write("Version: " + pkg_properties["VERSION"] + "\n")
tmpFile.write("Section: " + self.generate_list_separate_coma(pkg_properties["SECTION"]) + "\n")
tmpFile.write("Priority: " + pkg_properties["PRIORITY"] + "\n")
tmpFile.write("Architecture: all\n")
tmpFile.write("Depends: bash\n")
tmpFile.write("Maintainer: " + self.generate_list_separate_coma(pkg_properties["MAINTAINER"]) + "\n")
tmpFile.write("Description: " + pkg_properties["DESCRIPTION"] + "\n")
tmpFile.write("\n")
tmpFile.flush()
tmpFile.close()
## Create the PostRm
tmpFile = open(finalFilepostRm, 'w')
tmpFile.write("#!/bin/bash\n")
tmpFile.write("touch ~/." + pkg_name + "\n")
if pkg_name != "":
tmpFile.write("touch ~/.local/share/" + pkg_name + "\n")
tmpFile.write("rm -r ~/.local/share/" + pkg_name + "\n")
tmpFile.write("\n")
tmpFile.flush()
tmpFile.close()
## Enable Execution in script
os.chmod(finalFilepostRm, stat.S_IRWXU + stat.S_IRGRP + stat.S_IXGRP + stat.S_IROTH + stat.S_IXOTH);
## Readme donumentation
readmeFileDest = self.get_staging_path(pkg_name) + "/usr/share/doc/"+ debianpkg_name + "/README"
tools.create_directory_of_file(readmeFileDest)
if os.path.exists(base_pkg_path + "/os-Linux/README")==True:
tools.copy_file(base_pkg_path + "/os-Linux/README", readmeFileDest)
elif os.path.exists(base_pkg_path + "/README")==True:
tools.copy_file(base_pkg_path + "/README", readmeFileDest)
elif os.path.exists(base_pkg_path + "/README.md")==True:
tools.copy_file(base_pkg_path + "/README.md", readmeFileDest)
else:
debug.info("no file 'README', 'README.md' or 'os-Linux/README' ==> generate an empty one")
tmpFile = open(readmeFileDest, 'w')
tmpFile.write("No documentation for " + pkg_name + "\n")
tmpFile.flush()
tmpFile.close()
## licence file
license_file_dest = self.get_staging_path(pkg_name) + "/usr/share/doc/"+ debianpkg_name + "/copyright"
tools.create_directory_of_file(license_file_dest)
if os.path.exists(base_pkg_path + "/license.txt")==True:
tools.copy_file(base_pkg_path + "/license.txt", license_file_dest)
else:
debug.info("no file 'license.txt' ==> generate an empty one")
tmpFile = open(license_file_dest, 'w')
tmpFile.write("No license define by the developper for " + pkg_name + "\n")
tmpFile.flush()
tmpFile.close()
##changeLog file
change_log_file_dest = self.get_staging_path(pkg_name) + "/usr/share/doc/"+ debianpkg_name + "/changelog"
tools.create_directory_of_file(change_log_file_dest)
if os.path.exists(base_pkg_path + "/changelog")==True:
tools.copy_file(base_pkg_path + "/changelog", change_log_file_dest)
else:
debug.info("no file 'changelog' ==> generate an empty one")
tmpFile = open(change_log_file_dest, 'w')
tmpFile.write("No changelog data " + pkg_name + "\n")
tmpFile.flush()
tmpFile.close()
## create the package :
debug.debug("package : " + self.get_staging_path(pkg_name) + "/" + debianpkg_name + ".deb")
os.system("cd " + self.get_staging_path("") + " ; dpkg-deb --build " + pkg_name)
tools.create_directory_of_file(self.get_final_path())
tools.copy_file(self.get_staging_path("") + "/" + pkg_name + self.suffix_package, self.get_final_path() + "/" + pkg_name + self.suffix_package)
def install_package(self, pkg_name):
debug.debug("------------------------------------------------------------------------")
debug.info("Install package '" + pkg_name + "'")
debug.debug("------------------------------------------------------------------------")
os.system("sudo dpkg -i " + self.get_final_path() + "/" + pkg_name + self.suffix_package)
def un_install_package(self, pkg_name):
debug.debug("------------------------------------------------------------------------")
debug.info("Un-Install package '" + pkg_name + "'")
debug.debug("------------------------------------------------------------------------")
os.system("sudo dpkg -r " + self.get_final_path() + "/" + pkg_name + self.suffix_package)

View File

@ -63,7 +63,6 @@ class Target(target.Target):
self.global_flags_ld.append("-miphoneos-version-min=8.0") 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("-miphoneos-version-min=8.0")
self.global_flags_cc.append("-D__STDCPP_LLVM__")
self.global_flags_ld.append([ self.global_flags_ld.append([
"-Xlinker", "-Xlinker",
"-objc_abi_version", "-objc_abi_version",

View File

@ -35,8 +35,6 @@ class Target(target.Target):
self.global_flags_cc.append("-m32") self.global_flags_cc.append("-m32")
self.global_flags_cc.append("-fpic") self.global_flags_cc.append("-fpic")
self.global_flags_cc.append("-D__STDCPP_GNU__")
self.pkg_path_data = "share" self.pkg_path_data = "share"
self.pkg_path_bin = "bin" self.pkg_path_bin = "bin"

View File

@ -38,8 +38,6 @@ class Target(target.Target):
#self.suffix_binary='' #self.suffix_binary=''
#self.suffix_package='' #self.suffix_package=''
self.global_flags_cc.append("-D__STDCPP_LLVM__")
self.pkg_path_data = "Resources" self.pkg_path_data = "Resources"
self.pkg_path_bin = "MacOS" self.pkg_path_bin = "MacOS"
self.pkg_path_lib = "lib" self.pkg_path_lib = "lib"

View File

@ -45,10 +45,6 @@ class Target(target.Target):
else: else:
# 32 bits # 32 bits
self.set_cross_base("i686-w64-mingw32-") self.set_cross_base("i686-w64-mingw32-")
# force static link to prenvent many errors ...
self.global_flags_ld.append(["-static-libgcc",
"-static-libstdc++",
"-static"])
self.pkg_path_data = "data" self.pkg_path_data = "data"
self.pkg_path_bin = "" self.pkg_path_bin = ""
@ -59,7 +55,6 @@ class Target(target.Target):
self.suffix_lib_dynamic='.dll' self.suffix_lib_dynamic='.dll'
self.suffix_binary='.exe' self.suffix_binary='.exe'
#self.suffix_package='' #self.suffix_package=''
self.global_flags_cc.append("-D__STDCPP_GNU__")
def get_staging_path_data(self, binary_name, heritage_list): def get_staging_path_data(self, binary_name, heritage_list):