2013-04-18 01:46:47 +02:00
|
|
|
#!/usr/bin/python
|
2013-04-21 22:17:47 +02:00
|
|
|
import lutinDebug as debug
|
2013-04-18 22:09:45 +02:00
|
|
|
import datetime
|
2013-04-21 22:17:47 +02:00
|
|
|
import lutinTools
|
|
|
|
import lutinModule
|
2013-04-18 01:46:47 +02:00
|
|
|
|
2013-04-18 22:09:45 +02:00
|
|
|
class Target:
|
2013-05-08 12:17:45 +02:00
|
|
|
def __init__(self, name, typeCompilator, debugMode, generatePackage, arch, cross):
|
2013-04-22 21:37:13 +02:00
|
|
|
self.arch = arch
|
|
|
|
self.cross = cross
|
2013-04-21 22:17:47 +02:00
|
|
|
self.name=name
|
2013-05-08 12:17:45 +02:00
|
|
|
self.endGeneratePackage = generatePackage
|
2013-07-11 11:21:25 +02:00
|
|
|
debug.info("=================================");
|
2013-11-20 21:26:31 +01:00
|
|
|
debug.info("== Target='" + self.name + "'");
|
2013-07-11 11:21:25 +02:00
|
|
|
debug.info("=================================");
|
2013-11-20 21:26:31 +01:00
|
|
|
self.ar=self.cross + "ar"
|
|
|
|
self.ranlib=self.cross + "ranlib"
|
2013-11-11 20:15:52 +01:00
|
|
|
if typeCompilator == "clang":
|
2013-04-22 21:37:13 +02:00
|
|
|
self.cc=self.cross + "clang"
|
|
|
|
self.xx=self.cross + "clang++"
|
2013-11-20 21:26:31 +01:00
|
|
|
#self.ar=self.cross + "llvm-ar"
|
|
|
|
#self.ranlib="ls"
|
2013-04-18 22:09:45 +02:00
|
|
|
else:
|
2013-04-22 21:37:13 +02:00
|
|
|
self.cc=self.cross + "gcc"
|
|
|
|
self.xx=self.cross + "g++"
|
2013-11-20 21:26:31 +01:00
|
|
|
#self.ar=self.cross + "ar"
|
|
|
|
#self.ranlib=self.cross + "ranlib"
|
2013-04-22 21:37:13 +02:00
|
|
|
self.ld=self.cross + "ld"
|
|
|
|
self.nm=self.cross + "nm"
|
|
|
|
self.strip=self.cross + "strip"
|
|
|
|
self.dlltool=self.cross + "dlltool"
|
2013-04-18 22:09:45 +02:00
|
|
|
###############################################################################
|
|
|
|
# Target global variables.
|
|
|
|
###############################################################################
|
2013-04-22 21:37:13 +02:00
|
|
|
self.global_include_cc=[]
|
2013-04-23 21:48:36 +02:00
|
|
|
self.global_flags_cc=['-D__TARGET_OS__'+self.name]
|
2013-11-20 21:26:31 +01:00
|
|
|
if self.name != "Windows":
|
|
|
|
self.global_flags_xx=['-std=c++11']
|
2013-11-28 00:54:40 +01:00
|
|
|
self.global_flags_mm=['-std=c++11']
|
2013-11-20 21:26:31 +01:00
|
|
|
else:
|
2013-12-19 01:07:30 +01:00
|
|
|
self.global_flags_xx=['-static-libgcc', '-static-libstdc++', '-L', '-std=c++11']
|
2013-11-28 00:54:40 +01:00
|
|
|
self.global_flags_mm=[]
|
2013-04-22 21:37:13 +02:00
|
|
|
self.global_flags_m=[]
|
|
|
|
self.global_flags_ar=['rcs']
|
|
|
|
self.global_flags_ld=[]
|
|
|
|
self.global_flags_ld_shared=[]
|
|
|
|
self.global_libs_ld=[]
|
|
|
|
self.global_libs_ld_shared=[]
|
|
|
|
|
|
|
|
self.global_sysroot=""
|
2013-04-18 22:09:45 +02:00
|
|
|
|
2013-04-24 12:50:14 +02:00
|
|
|
self.suffix_cmdLine='.cmd'
|
2013-04-19 22:06:05 +02:00
|
|
|
self.suffix_dependence='.d'
|
2013-04-18 22:09:45 +02:00
|
|
|
self.suffix_obj='.o'
|
|
|
|
self.suffix_lib_static='.a'
|
|
|
|
self.suffix_lib_dynamic='.so'
|
|
|
|
self.suffix_binary=''
|
|
|
|
self.suffix_package='.deb'
|
|
|
|
|
|
|
|
self.folder_arch="/" + self.name
|
|
|
|
|
2013-04-21 22:17:47 +02:00
|
|
|
if "debug"==debugMode:
|
2013-04-18 22:09:45 +02:00
|
|
|
self.buildMode = "debug"
|
|
|
|
else:
|
|
|
|
self.buildMode = "release"
|
|
|
|
self.folder_out="/out" + self.folder_arch + "/" + self.buildMode
|
2013-11-28 21:05:24 +01:00
|
|
|
self.folder_final="/final/" + typeCompilator
|
|
|
|
self.folder_staging="/staging/" + typeCompilator
|
|
|
|
self.folder_build="/build/" + typeCompilator
|
2013-04-18 22:09:45 +02:00
|
|
|
self.folder_bin="/usr/bin"
|
|
|
|
self.folder_lib="/usr/lib"
|
|
|
|
self.folder_data="/usr/share"
|
|
|
|
self.folder_doc="/usr/share/doc"
|
|
|
|
self.buildDone=[]
|
|
|
|
self.buildTreeDone=[]
|
2013-04-21 22:17:47 +02:00
|
|
|
self.moduleList=[]
|
2013-07-02 21:30:16 +02:00
|
|
|
# output staging files list :
|
|
|
|
self.listFinalFile=[]
|
|
|
|
|
|
|
|
|
2013-12-06 21:46:38 +01:00
|
|
|
def get_build_mode(self):
|
|
|
|
return self.buildMode
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def add_file_staging(self, inputFile, outputFile):
|
2013-07-02 21:30:16 +02:00
|
|
|
for source, dst in self.listFinalFile:
|
|
|
|
if dst == outputFile :
|
|
|
|
debug.verbose("already added : " + outputFile)
|
|
|
|
return
|
|
|
|
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'");
|
|
|
|
self.listFinalFile.append([inputFile,outputFile])
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def copy_to_staging(self, binaryName):
|
|
|
|
baseFolder = self.get_staging_folder_data(binaryName)
|
2013-07-02 21:30:16 +02:00
|
|
|
for source, dst in self.listFinalFile:
|
|
|
|
debug.verbose("must copy file : '" + source + "' ==> '" + dst + "'");
|
2013-12-23 22:22:24 +01:00
|
|
|
lutinTools.copy_file(source, baseFolder+"/"+dst)
|
2013-07-02 21:30:16 +02:00
|
|
|
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def clean_module_tree(self):
|
2013-07-02 21:30:16 +02:00
|
|
|
self.buildTreeDone = []
|
|
|
|
self.listFinalFile = []
|
|
|
|
|
2013-04-18 22:09:45 +02:00
|
|
|
|
2013-04-23 21:48:36 +02:00
|
|
|
# TODO : Remove this hack ... ==> really bad ... but usefull
|
2013-12-23 22:22:24 +01:00
|
|
|
def set_ewol_folder(self, folder):
|
2013-04-23 21:48:36 +02:00
|
|
|
self.folder_ewol = folder
|
|
|
|
|
2013-04-24 12:50:14 +02:00
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def file_generate_object(self,binaryName,moduleName,basePath,file):
|
2013-04-24 12:50:14 +02:00
|
|
|
list=[]
|
|
|
|
list.append(basePath + "/" + file)
|
2013-12-23 22:22:24 +01:00
|
|
|
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_obj)
|
|
|
|
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_dependence)
|
|
|
|
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_cmdLine)
|
2013-04-24 12:50:14 +02:00
|
|
|
return list
|
2013-04-18 22:09:45 +02:00
|
|
|
"""
|
|
|
|
return a list of 3 elements :
|
|
|
|
0 : sources files (can be a list)
|
|
|
|
1 : destination file
|
|
|
|
2 : dependence files module (*.d)
|
|
|
|
"""
|
2013-12-23 22:22:24 +01:00
|
|
|
def generate_file(self,binaryName,moduleName,basePath,file,type):
|
2013-04-18 22:09:45 +02:00
|
|
|
list=[]
|
|
|
|
if (type=="bin"):
|
|
|
|
list.append(file)
|
2013-12-23 22:22:24 +01:00
|
|
|
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_bin + "/" + moduleName + self.suffix_binary)
|
|
|
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
|
|
|
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_bin + "/" + moduleName + self.suffix_cmdLine)
|
2013-04-18 22:09:45 +02:00
|
|
|
elif (type=="lib-shared"):
|
|
|
|
list.append(file)
|
2013-12-23 22:22:24 +01:00
|
|
|
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_lib + "/" + moduleName + self.suffix_lib_dynamic)
|
|
|
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
|
|
|
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_lib + "/" + moduleName + self.suffix_cmdLine)
|
2013-04-18 22:09:45 +02:00
|
|
|
elif (type=="lib-static"):
|
|
|
|
list.append(file)
|
2013-12-23 22:22:24 +01:00
|
|
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_lib_static)
|
|
|
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
|
|
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_cmdLine)
|
2013-04-18 22:09:45 +02:00
|
|
|
else:
|
|
|
|
debug.error("unknow type : " + type)
|
|
|
|
return list
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def get_final_folder(self):
|
|
|
|
return lutinTools.get_run_folder() + self.folder_out + self.folder_final
|
2013-04-22 21:37:13 +02:00
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def get_staging_folder(self, binaryName):
|
|
|
|
return lutinTools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName
|
2013-04-19 22:06:05 +02:00
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def get_staging_folder_data(self, binaryName):
|
|
|
|
return self.get_staging_folder(binaryName) + self.folder_data + "/" + binaryName
|
2013-04-19 22:06:05 +02:00
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def get_build_folder(self, moduleName):
|
|
|
|
return lutinTools.get_run_folder() + self.folder_out + self.folder_build + "/" + moduleName
|
2013-04-18 22:09:45 +02:00
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def get_doc_folder(self, moduleName):
|
|
|
|
return lutinTools.get_run_folder() + self.folder_out + self.folder_doc + "/" + moduleName
|
2013-11-29 21:52:13 +01:00
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def is_module_build(self,module):
|
2013-04-18 22:09:45 +02:00
|
|
|
for mod in self.buildDone:
|
|
|
|
if mod == module:
|
|
|
|
return True
|
|
|
|
self.buildDone.append(module)
|
|
|
|
return False
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def is_module_buildTree(self,module):
|
2013-04-18 22:09:45 +02:00
|
|
|
for mod in self.buildTreeDone:
|
|
|
|
if mod == module:
|
|
|
|
return True
|
|
|
|
self.buildTreeDone.append(module)
|
|
|
|
return False
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def add_module(self, newModule):
|
2013-04-21 22:17:47 +02:00
|
|
|
debug.debug("Import nodule for Taget : " + newModule.name)
|
|
|
|
self.moduleList.append(newModule)
|
|
|
|
|
|
|
|
|
|
|
|
# return inherit packages ...
|
|
|
|
"""
|
2013-12-23 22:22:24 +01:00
|
|
|
def build(self, name, packagesName):
|
2013-04-21 22:17:47 +02:00
|
|
|
for module in self.moduleList:
|
|
|
|
if module.name == name:
|
2013-12-23 22:22:24 +01:00
|
|
|
return module.build(self, packagesName)
|
2013-04-21 22:17:47 +02:00
|
|
|
debug.error("request to build an un-existant module name : '" + name + "'")
|
|
|
|
"""
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def build_tree(self, name, packagesName):
|
2013-04-21 22:17:47 +02:00
|
|
|
for module in self.moduleList:
|
|
|
|
if module.name == name:
|
2013-12-23 22:22:24 +01:00
|
|
|
module.build_tree(self, packagesName)
|
2013-04-21 22:17:47 +02:00
|
|
|
return
|
|
|
|
debug.error("request to build tree on un-existant module name : '" + name + "'")
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def clean(self, name):
|
2013-04-21 22:17:47 +02:00
|
|
|
for module in self.moduleList:
|
|
|
|
if module.name == name:
|
2013-12-23 22:22:24 +01:00
|
|
|
module.clean(self)
|
2013-04-21 22:17:47 +02:00
|
|
|
return
|
|
|
|
debug.error("request to clean an un-existant module name : '" + name + "'")
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def load_if_needed(self, name):
|
2013-04-21 22:17:47 +02:00
|
|
|
for elem in self.moduleList:
|
|
|
|
if elem.name == name:
|
|
|
|
return
|
2013-12-23 22:22:24 +01:00
|
|
|
lutinModule.load_module(self, name)
|
2013-04-21 22:17:47 +02:00
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def load_all(self):
|
|
|
|
listOfAllTheModule = lutinModule.list_all_module()
|
2013-04-21 22:17:47 +02:00
|
|
|
for modName in listOfAllTheModule:
|
2013-12-23 22:22:24 +01:00
|
|
|
self.load_if_needed(modName)
|
2013-04-21 22:17:47 +02:00
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def build(self, name, packagesName=None):
|
2013-12-23 21:27:22 +01:00
|
|
|
if name == "dump":
|
2013-04-21 22:17:47 +02:00
|
|
|
debug.info("dump all")
|
2013-12-23 22:22:24 +01:00
|
|
|
self.load_all()
|
2013-12-04 23:41:51 +01:00
|
|
|
print 'Dump all modules properties'
|
2013-04-21 22:17:47 +02:00
|
|
|
for mod in self.moduleList:
|
2013-12-23 22:22:24 +01:00
|
|
|
mod.display(self)
|
2013-04-21 22:17:47 +02:00
|
|
|
elif name == "all":
|
2013-12-23 22:22:24 +01:00
|
|
|
debug.info("build all")
|
|
|
|
self.load_all()
|
2013-04-21 22:17:47 +02:00
|
|
|
for mod in self.moduleList:
|
2013-07-03 21:32:04 +02:00
|
|
|
if self.name=="Android":
|
|
|
|
if mod.type == "PACKAGE":
|
2013-12-23 22:22:24 +01:00
|
|
|
mod.build(self, None)
|
2013-07-03 21:32:04 +02:00
|
|
|
else:
|
|
|
|
if mod.type == "BINARY" \
|
|
|
|
or mod.type == "PACKAGE":
|
2013-12-23 22:22:24 +01:00
|
|
|
mod.build(self, None)
|
2013-04-21 22:17:47 +02:00
|
|
|
elif name == "clean":
|
2013-12-23 22:22:24 +01:00
|
|
|
debug.info("clean all")
|
|
|
|
self.load_all()
|
2013-04-21 22:17:47 +02:00
|
|
|
for mod in self.moduleList:
|
2013-12-23 22:22:24 +01:00
|
|
|
mod.clean(self)
|
2013-04-21 22:17:47 +02:00
|
|
|
else:
|
2013-04-26 22:17:09 +02:00
|
|
|
# get the action an the module ....
|
|
|
|
gettedElement = name.split("-")
|
|
|
|
moduleName = gettedElement[0]
|
|
|
|
if len(gettedElement)>=2:
|
|
|
|
actionName = gettedElement[1]
|
|
|
|
else :
|
|
|
|
actionName = "build"
|
|
|
|
debug.verbose("requested : " + moduleName + "-" + actionName)
|
|
|
|
if actionName == "install":
|
2013-12-23 22:22:24 +01:00
|
|
|
self.build(moduleName + "-build")
|
|
|
|
self.install_package(moduleName)
|
2013-04-26 22:17:09 +02:00
|
|
|
elif actionName == "uninstall":
|
2013-12-23 22:22:24 +01:00
|
|
|
self.un_install_package(moduleName)
|
2013-04-26 22:17:09 +02:00
|
|
|
elif actionName == "log":
|
|
|
|
self.Log(moduleName)
|
2013-04-21 22:17:47 +02:00
|
|
|
else:
|
2013-12-23 22:22:24 +01:00
|
|
|
self.load_if_needed(moduleName)
|
2013-04-26 22:17:09 +02:00
|
|
|
# clean requested
|
2013-04-21 22:17:47 +02:00
|
|
|
for mod in self.moduleList:
|
2013-04-26 22:17:09 +02:00
|
|
|
if mod.name == moduleName:
|
|
|
|
if actionName == "dump":
|
|
|
|
debug.info("dump module '" + moduleName + "'")
|
2013-12-23 22:22:24 +01:00
|
|
|
return mod.display(self)
|
2013-04-26 22:17:09 +02:00
|
|
|
elif actionName == "clean":
|
|
|
|
debug.info("clean module '" + moduleName + "'")
|
2013-12-23 22:22:24 +01:00
|
|
|
return mod.clean(self)
|
2013-04-26 22:17:09 +02:00
|
|
|
elif actionName == "build":
|
2013-07-04 21:33:39 +02:00
|
|
|
debug.debug("build module '" + moduleName + "'")
|
2013-12-23 22:22:24 +01:00
|
|
|
return mod.build(self, None)
|
2013-04-26 22:17:09 +02:00
|
|
|
debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it")
|
2013-04-18 22:09:45 +02:00
|
|
|
|
2013-04-18 01:46:47 +02:00
|
|
|
|
2013-04-22 21:37:13 +02:00
|
|
|
__startTargetName="lutinTarget"
|
|
|
|
|
2013-12-23 22:22:24 +01:00
|
|
|
def target_load(targetName, compilator, mode, generatePackage):
|
2013-04-22 21:37:13 +02:00
|
|
|
theTarget = __import__(__startTargetName + targetName)
|
|
|
|
#try:
|
2013-05-08 12:17:45 +02:00
|
|
|
tmpTarget = theTarget.Target(compilator, mode, generatePackage)
|
2013-04-22 21:37:13 +02:00
|
|
|
return tmpTarget
|
|
|
|
#except:
|
|
|
|
# debug.error("Can not create the Target : '" + targetName + "'")
|