[DEV] add some system prebuild packages

This commit is contained in:
Edouard DUPIN 2015-02-06 23:32:12 +01:00
parent 134e0b523e
commit 1ec26df856
13 changed files with 402 additions and 90 deletions

View File

@ -126,6 +126,7 @@ if __name__ == "__main__":
# now import other standard module (must be done here and not before ... # now import other standard module (must be done here and not before ...
import lutinTarget import lutinTarget
import lutinSystem
import lutinHost import lutinHost
import lutinTools import lutinTools
@ -228,7 +229,9 @@ if __name__ == '__main__':
and folder.lower()!="out" : and folder.lower()!="out" :
debug.debug("Automatic load path: '" + folder + "'") debug.debug("Automatic load path: '" + folder + "'")
lutinModule.import_path(folder) lutinModule.import_path(folder)
lutinSystem.import_path(folder)
lutinTarget.import_path(folder) lutinTarget.import_path(folder)
#lutinSystem.display()
Start() Start()

View File

@ -33,6 +33,7 @@ class Module:
## ##
def __init__(self, file, moduleName, moduleType): def __init__(self, file, moduleName, moduleType):
## Remove all variable to prevent error of multiple deffinition of the module ... ## Remove all variable to prevent error of multiple deffinition of the module ...
debug.verbose("Create a new module : '" + moduleName + "' TYPE=" + moduleType)
self.originFile='' self.originFile=''
self.originFolder='' self.originFolder=''
# type of the module: # type of the module:
@ -41,6 +42,8 @@ class Module:
self.name=moduleName self.name=moduleName
# Dependency list: # Dependency list:
self.depends = [] self.depends = []
# Dependency list (optionnal module):
self.depends_optionnal = []
# Documentation list: # Documentation list:
self.documentation = None self.documentation = None
# export PATH # export PATH
@ -450,9 +453,18 @@ class Module:
# TODO : Set it better ... # TODO : Set it better ...
None None
# build dependency befor # build dependency before
listSubFileNeededTobuild = [] listSubFileNeededTobuild = []
self.subHeritageList = heritage.HeritageList() self.subHeritageList = heritage.HeritageList()
# optionnal dependency :
for dep, option in self.depends_optionnal:
inheritList, isBuilt = target.build_optionnal(dep, packageName)
if isBuilt == True:
# TODO : Add optionnal Flags ...
# ==> do it really better ...
self.add_export_flag_CC("-D"+option);
# add at the heritage list :
self.subHeritageList.add_heritage_list(inheritList)
for dep in self.depends: for dep in self.depends:
inheritList = target.build(dep, packageName) inheritList = target.build(dep, packageName)
# add at the heritage list : # add at the heritage list :
@ -462,26 +474,16 @@ class Module:
for file in self.src: for file in self.src:
#debug.info(" " + self.name + " <== " + file); #debug.info(" " + self.name + " <== " + file);
fileExt = file.split(".")[-1] fileExt = file.split(".")[-1]
if fileExt == "c" \ if fileExt in ["c", "C"]:
or fileExt == "C":
resFile = self.compile_cc_to_o(file, packageName, target, self.subHeritageList) resFile = self.compile_cc_to_o(file, packageName, target, self.subHeritageList)
listSubFileNeededTobuild.append(resFile) listSubFileNeededTobuild.append(resFile)
elif fileExt == "cpp" \ elif fileExt in ["cpp", "CPP", "cxx", "CXX", "xx", "XX", "CC", "cc"]:
or fileExt == "CPP" \
or fileExt == "cxx" \
or fileExt == "CXX" \
or fileExt == "xx" \
or fileExt == "XX" \
or fileExt == "CC" \
or fileExt == "cc":
resFile = self.compile_xx_to_o(file, packageName, target, self.subHeritageList) resFile = self.compile_xx_to_o(file, packageName, target, self.subHeritageList)
listSubFileNeededTobuild.append(resFile) listSubFileNeededTobuild.append(resFile)
elif fileExt == "mm" \ elif fileExt in ["mm", "MM"]:
or fileExt == "MM":
resFile = self.compile_mm_to_o(file, packageName, target, self.subHeritageList) resFile = self.compile_mm_to_o(file, packageName, target, self.subHeritageList)
listSubFileNeededTobuild.append(resFile) listSubFileNeededTobuild.append(resFile)
elif fileExt == "m" \ elif fileExt in ["m", "M"]:
or fileExt == "M":
resFile = self.compile_m_to_o(file, packageName, target, self.subHeritageList) resFile = self.compile_m_to_o(file, packageName, target, self.subHeritageList)
listSubFileNeededTobuild.append(resFile) listSubFileNeededTobuild.append(resFile)
else: else:
@ -491,8 +493,7 @@ class Module:
# generate end point: # generate end point:
if self.type=='PREBUILD': if self.type=='PREBUILD':
# nothing to add ==> just dependence debug.print_element("Prebuild", self.name, "==>", "find")
None
elif self.type=='LIBRARY': elif self.type=='LIBRARY':
resFile = self.link_to_a(listSubFileNeededTobuild, packageName, target, self.subHeritageList) resFile = self.link_to_a(listSubFileNeededTobuild, packageName, target, self.subHeritageList)
self.localHeritage.add_sources(resFile) self.localHeritage.add_sources(resFile)
@ -578,6 +579,9 @@ class Module:
def add_module_depend(self, list): def add_module_depend(self, list):
self.append_to_internalList(self.depends, list, True) self.append_to_internalList(self.depends, list, True)
def add_optionnal_module_depend(self, module_name, compilation_flags=""):
self.append_and_check(self.depends_optionnal, [module_name, compilation_flags], True)
def add_export_path(self, list): def add_export_path(self, list):
self.append_to_internalList(self.export_path, list) self.append_to_internalList(self.export_path, list)
@ -644,6 +648,7 @@ class Module:
print ' file:"%s"' %self.originFile print ' file:"%s"' %self.originFile
print ' folder:"%s"' %self.originFolder print ' folder:"%s"' %self.originFolder
self.print_list('depends',self.depends) self.print_list('depends',self.depends)
self.print_list('depends_optionnal', self.depends_optionnal)
self.print_list('flags_ld',self.flags_ld) self.print_list('flags_ld',self.flags_ld)
self.print_list('flags_cc',self.flags_cc) self.print_list('flags_cc',self.flags_cc)
self.print_list('flags_xx',self.flags_xx) self.print_list('flags_xx',self.flags_xx)

159
lutinSystem.py Normal file
View File

@ -0,0 +1,159 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import sys
import os
import inspect
import fnmatch
import lutinDebug as debug
import datetime
import lutinTools
import lutinModule as module
import lutinImage
import lutinHost
class System:
def __init__(self):
self.valid=False;
self.help="";
self.include_cc=[]
self.export_flags_cc=[]
self.export_flags_xx=[]
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=[]
def append_and_check(self, listout, newElement, order):
for element in listout:
if element==newElement:
return
listout.append(newElement)
if True==order:
listout.sort()
def append_to_internalList(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_flag_LD(self, list):
self.append_to_internalList(self.export_flags_ld, list)
def add_export_flag_CC(self, list):
self.append_to_internalList(self.export_flags_cc, list)
def add_export_flag_XX(self, list):
self.append_to_internalList(self.export_flags_xx, list)
def add_export_flag_M(self, list):
self.append_to_internalList(self.export_flags_m, list)
def add_export_flag_MM(self, list):
self.append_to_internalList(self.export_flags_mm, list)
def createModuleFromSystem(target, dict):
myModule = module.Module(dict["path"], dict["name"], 'PREBUILD')
myModule.add_export_flag_LD(dict["system"].export_flags_cc)
myModule.add_export_flag_XX(dict["system"].export_flags_xx)
myModule.add_export_flag_M(dict["system"].export_flags_m)
myModule.add_export_flag_MM(dict["system"].export_flags_mm)
# add the currrent module at the
return myModule
# Dictionnaire of Target name
# inside table of ["Name of the lib", "path of the lib", boolean loaded, module loaded]
systemList={}
__startSystemName="lutinSystem_"
def import_path(path):
global targetList
matches = []
debug.debug('Start find sub File : "%s"' %path)
for root, dirnames, filenames in os.walk(path):
tmpList = fnmatch.filter(filenames, __startSystemName + "*.py")
# Import the module :
for filename in tmpList:
debug.verbose(' Find a file : "%s"' %os.path.join(root, filename))
sys.path.append(os.path.dirname(os.path.join(root, filename)) )
systemName = filename.replace('.py', '')
systemName = systemName.replace(__startSystemName, '')
targetType, systemName = systemName.split('_')
debug.debug("integrate system: '" + targetType + "':'" + systemName + "' from '" + os.path.join(root, filename) + "'")
if targetType in systemList:
systemList[targetType].append({"name":systemName,
"path":os.path.join(root, filename),
"system":None,
"loaded":False,
"exist":False,
"module":None})
else:
systemList[targetType] = [{"name":systemName,
"path":os.path.join(root, filename),
"system":None,
"loaded":False,
"exist":False,
"module":None}]
def display():
global systemList
for elementName in systemList:
debug.info("integrate system: '" + elementName +"'")
for data in systemList[elementName]:
debug.info(" '" + data["name"] +"' in " + data["path"])
def exist(lib_name, target_name) :
global systemList
if target_name not in systemList:
return False
for data in systemList[target_name]:
if data["name"] == lib_name:
# we find it in the List ==> need to check if it is present in the system :
if data["loaded"] == False:
debug.verbose("add to path: '" + os.path.dirname(data["path"]) + "'")
sys.path.append(os.path.dirname(data["path"]))
debug.verbose("import system : '" + data["name"] + "'")
theSystem = __import__(__startSystemName + target_name + "_" + data["name"])
#create the system module
data["system"] = theSystem.System()
data["exist"] = data["system"].valid
return data["exist"]
return False
def load(target, lib_name, target_name):
global systemList
if target_name not in systemList:
debug.error("you must call this function after checking of the system exist() !1!")
for data in systemList[target_name]:
if data["name"] == lib_name:
if data["exist"] == False:
debug.error("you must call this function after checking of the system exist() !2!")
if data["module"] == None:
# create a module from the system interface...
data["module"] = createModuleFromSystem(target, data)
data["loaded"] = True
target.add_module(data["module"])
return

View File

@ -12,9 +12,11 @@ import os
import inspect import inspect
import fnmatch import fnmatch
import lutinDebug as debug import lutinDebug as debug
import lutinHeritage as heritage
import datetime import datetime
import lutinTools import lutinTools
import lutinModule import lutinModule
import lutinSystem
import lutinImage import lutinImage
import lutinHost import lutinHost
@ -110,8 +112,6 @@ class Target:
self.sysroot="" self.sysroot=""
self.externProjectManager = None
def update_folder_tree(self): def update_folder_tree(self):
self.folder_out="/out/" + self.name + "_" + self.config["arch"] + "_" + self.config["bus-size"] + "/" + self.config["mode"] self.folder_out="/out/" + self.name + "_" + self.config["arch"] + "_" + self.config["bus-size"] + "/" + self.config["mode"]
self.folder_final="/final/" + self.config["compilator"] self.folder_final="/final/" + self.config["compilator"]
@ -139,14 +139,6 @@ class Target:
self.dlltool = self.cross + "dlltool" self.dlltool = self.cross + "dlltool"
self.update_folder_tree() self.update_folder_tree()
def set_use_of_extern_build_tool(self, mode):
if mode == True:
if self.externProjectManager == None:
debug.error("This target does not support extern tool")
else:
# remove extern tool generator...
self.externProjectManager = None
def get_build_mode(self): def get_build_mode(self):
return self.config["mode"] return self.config["mode"]
@ -256,7 +248,7 @@ class Target:
return False return False
def add_module(self, newModule): def add_module(self, newModule):
debug.debug("Import nodule for Taget : " + newModule.name) debug.debug("Add nodule for Taget : " + newModule.name)
self.moduleList.append(newModule) self.moduleList.append(newModule)
@ -283,11 +275,22 @@ class Target:
return return
debug.error("request to clean an un-existant module name : '" + name + "'") debug.error("request to clean an un-existant module name : '" + name + "'")
def load_if_needed(self, name): def load_if_needed(self, name, optionnal=False):
for elem in self.moduleList: for elem in self.moduleList:
if elem.name == name: if elem.name == name:
return return True
if optionnal == False:
lutinModule.load_module(self, name) lutinModule.load_module(self, name)
return True
else:
# TODO : Check internal module and system module ...
# need to import the module (or the system module ...)
exist = lutinSystem.exist(name, self.name)
if exist == True:
lutinSystem.load(self, name, self.name)
return True;
else:
return False;
def load_all(self): def load_all(self):
listOfAllTheModule = lutinModule.list_all_module() listOfAllTheModule = lutinModule.list_all_module()
@ -300,25 +303,25 @@ class Target:
module.ext_project_add_module(self, projectMng, addedModule) module.ext_project_add_module(self, projectMng, addedModule)
return return
def build_optionnal(self, moduleName, packagesName=None):
present = self.load_if_needed(moduleName, optionnal=True)
if present == False:
return [heritage.HeritageList(), False]
# clean requested
for mod in self.moduleList:
if mod.name == moduleName:
debug.debug("build module '" + moduleName + "'")
return [mod.build(self, None), True]
debug.warning("not know module name : '" + moduleName + "' to '" + "build" + "' it")
return [heritage.HeritageList(), False]
def build(self, name, packagesName=None): def build(self, name, packagesName=None):
if name == "dump": if name == "dump":
debug.info("dump all") debug.info("dump all")
self.load_all() self.load_all()
for mod in self.moduleList: for mod in self.moduleList:
mod.display(self) mod.display(self)
elif self.externProjectManager != None: return
# TODO : Do it only if needed:
debug.debug("generate project")
# TODO : Set an option to force Regeneration of the project or the oposite....
self.load_all()
for mod in self.moduleList:
if mod.name != "edn":
continue
if mod.type == "PACKAGE":
mod.create_project(self, self.externProjectManager)
# TODO : Run project or do something else ...
debug.error("stop here ...")
else:
if name == "all": if name == "all":
debug.info("build all") debug.info("build all")
self.load_all() self.load_all()
@ -403,7 +406,6 @@ def load_target(name, config):
theTarget = __import__(__startTargetName + name) theTarget = __import__(__startTargetName + name)
#create the target #create the target
tmpTarget = theTarget.Target(config) tmpTarget = theTarget.Target(config)
#tmpTarget.set_use_of_extern_build_tool(externBuild)
return tmpTarget return tmpTarget
def list_all_target(): def list_all_target():

View File

View File

@ -0,0 +1,29 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import lutinDebug as debug
import lutinSystem
import lutinTools as tools
import os
class System(lutinSystem.System):
def __init__(self):
lutinSystem.System.__init__(self)
# create some HELP:
self.help="ALSA : Advanced Linux Sound Architecture\n Can be install with the package:\n - libasound2-dev"
# check if the library exist:
if not os.path.isfile("/usr/include/alsa/asoundlib.h") \
and not os.path.isfile("/usr/include/dssi/alsa/asoundlib.h"):
# we did not find the library reqiested (just return) (automaticly set at false)
return;
self.valid = True
# todo : create a searcher of the presence of the library:
self.add_export_flag_CC("-lasound")

View File

@ -0,0 +1,28 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import lutinDebug as debug
import lutinSystem
import lutinTools as tools
import os
class System(lutinSystem.System):
def __init__(self):
lutinSystem.System.__init__(self)
# create some HELP:
self.help="JACK : Jack Low-Latency Audio Server\n Can be install with the package:\n - libjack-jackd2-dev (new)\n - libjack-dev (old)"
# check if the library exist:
if not os.path.isfile("/usr/include/jack/jack.h"):
# we did not find the library reqiested (just return) (automaticly set at false)
return;
self.valid = True
# todo : create a searcher of the presence of the library:
self.add_export_flag_CC("-ljack")

View File

@ -0,0 +1,30 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import lutinDebug as debug
import lutinSystem
import lutinTools as tools
import os
class System(lutinSystem.System):
def __init__(self):
lutinSystem.System.__init__(self)
# create some HELP:
self.help="OSS : Linux Open Sound System\n Can be install with the package:\n - ... TODO ..."
# check if the library exist:
"""
if not os.path.isfile("/usr/include/jack/jack.h"):
# we did not find the library reqiested (just return) (automaticly set at false)
return;
self.valid = True
# todo : create a searcher of the presence of the library:
self.add_export_flag_CC("-ljack")
"""

View File

@ -0,0 +1,28 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import lutinDebug as debug
import lutinSystem
import lutinTools as tools
import os
class System(lutinSystem.System):
def __init__(self):
lutinSystem.System.__init__(self)
# create some HELP:
self.help="PULSE : The Linux PulseAudio\n Can be install with the package:\n - libpulse-dev"
# check if the library exist:
if not os.path.isfile("/usr/include/pulse/pulseaudio.h"):
# we did not find the library reqiested (just return) (automaticly set at false)
return;
self.valid = True
# todo : create a searcher of the presence of the library:
self.add_export_flag_CC(["-lpulse-simple", "-lpulse"])

View File

@ -0,0 +1,28 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import lutinDebug as debug
import lutinSystem
import lutinTools as tools
import os
class System(lutinSystem.System):
def __init__(self):
lutinSystem.System.__init__(self)
# create some HELP:
self.help="Z : z library \n Can be install with the package:\n - zlib1g-dev"
# check if the library exist:
if not os.path.isfile("/usr/include/zlib.h"):
# we did not find the library reqiested (just return) (automaticly set at false)
return;
self.valid = True
# todo : create a searcher of the presence of the library:
self.add_export_flag_CC(["-lz"])

View File

View File

View File