[DEV] Python 'lutin' build tool is nearly ok

This commit is contained in:
Edouard DUPIN 2013-04-21 22:17:47 +02:00
parent 860d7607af
commit f3b74bbc02
16 changed files with 244 additions and 296 deletions

View File

@ -1,89 +0,0 @@
#!/usr/bin/python
import debug
import module
import target_Linux
import host
availlable=[]
def AddModule(name, type):
global availlable
if type=="BINARY":
availlable.append([name,"Module", "bin"])
else:
availlable.append([name,"Module", "other"])
def AddPackage(name):
global availlable
availlable.append([name,"Package", "pkg"])
def Build(name):
if name == "all":
debug.info("Build all")
for elem in availlable:
if elem[1] == "Module":
if elem[2] == "bin":
module.Build(elem[0], None, GetCurrentTarget())
else:
debug.error("TODO ... Build package '" + elem[0] + "'")
elif name == "clean":
debug.info("Clean all")
for elem in availlable:
if elem[1] == "Module":
module.Clean(elem[0], GetCurrentTarget())
else:
debug.error("TODO ... Clean package '" + elem[0] + "'")
else:
myLen = len(name)
if name[myLen-6:] == "-clean":
cleanName = name[:myLen-6]
# clean requested
for elem in availlable:
if elem[0] == cleanName:
if elem[1] == "Module":
debug.info("Clean module '" + cleanName + "'")
module.Clean(cleanName, GetCurrentTarget())
else:
debug.info("Clean package '" + cleanName + "'")
debug.error("TODO ... Clean package '" + cleanName + "'")
# todo : clean
return
debug.error("not know module name : '" + cleanName + "' to clean it")
else:
# Build requested
for elem in availlable:
if elem[0] == name:
if elem[1] == "Module":
debug.info("Build module '" + name + "'")
module.Build(name, None, GetCurrentTarget())
else:
debug.info("Build package '" + name + "'")
debug.error("TODO ... Build package '" + cleanName + "'")
# todo : build
return
debug.error("not know module name : '" + name + "' to build it")
currentTarget=None
def SetTarget(name):
global currentTarget
if name=="Linux":
currentTarget = target_Linux.Target()
elif name=="Windows":
debug.error("TODO : create target type :'" + name + "'")
elif name=="MacOs":
debug.error("TODO : create target type :'" + name + "'")
elif name=="Android":
debug.error("TODO : create target type :'" + name + "'")
else:
debug.error("Unknow target type :'" + name + "'")
def GetCurrentTarget():
global currentTarget
if currentTarget==None:
SetTarget(host.OS)
return currentTarget

View File

@ -1,58 +0,0 @@
#
regexp=\bgcc\b
colours=yellow
count=more
.........
#
regexp=^[^:\s]*?:\d+:
colours=bold magenta
.........
regexp=^[^:\s]*?:
colours=cyan
count=once
.........
#
regexp=\`[A-Za-z0-9_():&*]+( const)?\'
colours=magenta
.........
# -O
regexp=\-O\d
colours=green
.........
# -o
regexp=\-o\s.+\b
colours=yellow
.........
# warning and error won't work, unless you redirect also
# stderr to grcat
#
# warning
regexp=warning:.*
colours=white
.........
regexp=warning:
colours=bold yellow
count=once
.........
# error
regexp=error:.*
colours=bold white
.........
regexp=error:
colours=bold white on_red
count=once
.........
#note
regexp=note:
colours=bold cyan
count=once
.........
# android compilation
regexp=(<==|==>)
colours=bold red
count=once
.........
#special extention files
regexp=[\.A-Za-z0-9_/]+\.(a|so|exe|bin|dll)
colours=bold green
count=once

View File

@ -4,11 +4,8 @@ import sys
import os import os
import inspect import inspect
import fnmatch import fnmatch
if __name__ == "__main__": import lutinDebug as debug
sys.path.append(os.path.dirname(__file__) + "/corePython/" ) import lutinEnv
import debug
import environement
""" """
@ -64,7 +61,7 @@ def parseGenericArg(argument,active):
return True return True
elif argument == "-f" or argument == "--force": elif argument == "-f" or argument == "--force":
if active==True: if active==True:
environement.SetForceMode(True) lutinEnv.SetForceMode(True)
return True return True
return False return False
@ -75,26 +72,25 @@ if __name__ == "__main__":
parseGenericArg(argument, True) parseGenericArg(argument, True)
# 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 module import lutinModule as module
import host import lutinHost as host
import buildTools import lutinTools
import host import lutinHost as host
import buildList import lutinList as buildList
import lutinTargetLinux
""" """
Run everything that is needed in the system Run everything that is needed in the system
""" """
def Start(): def Start():
target = lutinTargetLinux.TargetLinux("gcc", "debug")
actionDone=False actionDone=False
# parse all argument # parse all argument
for argument in sys.argv[1:]: for argument in sys.argv[1:]:
if True==parseGenericArg(argument, False): if True==parseGenericArg(argument, False):
None # nothing to do ... None # nothing to do ...
elif argument == "dump":
module.Dump()
actionDone=True
elif argument[:11] == "--platform=" or argument[:3] == "-p=": elif argument[:11] == "--platform=" or argument[:3] == "-p=":
tmpArg="" tmpArg=""
if argument[:3] == "-p=": if argument[:3] == "-p=":
@ -109,34 +105,34 @@ def Start():
else: else:
tmpArg=argument[11:] tmpArg=argument[11:]
if "debug"==tmpArg: if "debug"==tmpArg:
environement.SetDebugMode(1) lutinEnv.SetDebugMode(1)
elif "release"==tmpArg: elif "release"==tmpArg:
environement.SetDebugMode(0) lutinEnv.SetDebugMode(0)
else: else:
debug.error("not understand build mode : '" + val + "' can be [debug/release]") debug.error("not understand build mode : '" + val + "' can be [debug/release]")
environement.SetDebugMode(0) lutinEnv.SetDebugMode(0)
elif argument[:7] == "--tool=" or argument[:3] == "-t=": elif argument[:7] == "--tool=" or argument[:3] == "-t=":
tmpArg="" tmpArg=""
if argument[:3] == "-t=": if argument[:3] == "-t=":
tmpArg=argument[3:] tmpArg=argument[3:]
else: else:
tmpArg=argument[11:] tmpArg=argument[11:]
environement.SetCompileMode(tmpArg) lutinEnv.SetCompileMode(tmpArg)
else: else:
buildList.Build(argument) target.Build(argument)
actionDone=True actionDone=True
# if no action done : we do "all" ... # if no action done : we do "all" ...
if actionDone==False: if actionDone==False:
buildList.Build("all") target.Build("all")
""" """
When the user use with make.py we initialise ourself When the user use with make.py we initialise ourself
""" """
if __name__ == '__main__': if __name__ == '__main__':
debug.verbose("Use Make as a make stadard") debug.verbose("Use Make as a make stadard")
sys.path.append(buildTools.GetRunFolder()) sys.path.append(lutinTools.GetRunFolder())
debug.verbose(" try to impoert module 'Makefile.py'") debug.verbose(" try to impoert module 'lutinBase.py'")
__import__("Makefile") __import__("lutinBase")
Start() Start()

View File

@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
import os import os
import debug import lutinDebug as debug
import environement import lutinEnv as environement
def NeedReBuild(dst, src, dependFile): def NeedReBuild(dst, src, dependFile):

View File

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
import debug import lutinDebug as debug
debugMode=0 debugMode=0

View File

@ -1,7 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
import sys import sys
import buildTools import lutinDebug as debug
import debug

2
corePython/host.py → lutinHost.py Executable file → Normal file
View File

@ -1,6 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
import platform import platform
import debug import lutinDebug as debug
# print os.name # ==> 'posix' # print os.name # ==> 'posix'
if platform.system() == "Linux": if platform.system() == "Linux":

44
lutinList.py Normal file
View File

@ -0,0 +1,44 @@
#!/usr/bin/python
import lutinDebug as debug
import lutinModule as module
import lutinTargetLinux
import lutinHost
availlable=[]
def AddModule(name, type):
global availlable
if type=="BINARY":
availlable.append([name,"Module", "bin"])
else:
availlable.append([name,"Module", "other"])
def AddPackage(name):
global availlable
availlable.append([name,"Package", "pkg"])
currentTarget=None
def SetTarget(name):
global currentTarget
if name=="Linux":
currentTarget = lutinTargetLinux.Target()
elif name=="Windows":
debug.error("TODO : create target type :'" + name + "'")
elif name=="MacOs":
debug.error("TODO : create target type :'" + name + "'")
elif name=="Android":
debug.error("TODO : create target type :'" + name + "'")
else:
debug.error("Unknow target type :'" + name + "'")
def GetCurrentTarget():
global currentTarget
if currentTarget==None:
SetTarget(lutinHost.OS)
return currentTarget

170
corePython/module.py → lutinModule.py Executable file → Normal file
View File

@ -3,13 +3,13 @@ import sys
import os import os
import inspect import inspect
import fnmatch import fnmatch
import module import lutinModule as module
import host import lutinHost as host
import buildTools import lutinTools
import debug import lutinDebug as debug
import buildList import lutinList as buildList
import heritage import lutinHeritage as heritage
import dependency import lutinDepend as dependency
def RunCommand(cmdLine): def RunCommand(cmdLine):
debug.debug(cmdLine) debug.debug(cmdLine)
@ -74,7 +74,7 @@ class module:
debug.error(' ==> error : "%s" ' %moduleType) debug.error(' ==> error : "%s" ' %moduleType)
raise 'Input value error' raise 'Input value error'
self.originFile = file; self.originFile = file;
self.originFolder = buildTools.GetCurrentPath(self.originFile) self.originFolder = lutinTools.GetCurrentPath(self.originFile)
self.name=moduleName self.name=moduleName
self.localHeritage = heritage.heritage(self) self.localHeritage = heritage.heritage(self)
@ -83,7 +83,7 @@ class module:
############################################################################### ###############################################################################
def Compile_mm_to_o(self, file, binary, target, depancy): def Compile_mm_to_o(self, file, binary, target, depancy):
# TODO : Check depedency ... # TODO : Check depedency ...
buildTools.CreateDirectoryOfFile(dst) lutinTools.CreateDirectoryOfFile(dst)
debug.printElement("m++", self.name, "<==", file) debug.printElement("m++", self.name, "<==", file)
""" """
cmdLine= $(TARGET_CXX) \ cmdLine= $(TARGET_CXX) \
@ -104,7 +104,7 @@ class module:
############################################################################### ###############################################################################
def Compile_m_to_o(self, file, binary, target, depancy): def Compile_m_to_o(self, file, binary, target, depancy):
# TODO : Check depedency ... # TODO : Check depedency ...
buildTools.CreateDirectoryOfFile(dst) lutinTools.CreateDirectoryOfFile(dst)
debug.printElement("m", self.name, "<==", file) debug.printElement("m", self.name, "<==", file)
""" """
$(TARGET_CC) \ $(TARGET_CC) \
@ -129,14 +129,14 @@ class module:
# check the dependency for this file : # check the dependency for this file :
if False==dependency.NeedReBuild(tmpList[1], tmpList[0], tmpList[2]): if False==dependency.NeedReBuild(tmpList[1], tmpList[0], tmpList[2]):
return tmpList[1] return tmpList[1]
buildTools.CreateDirectoryOfFile(tmpList[1]) lutinTools.CreateDirectoryOfFile(tmpList[1])
debug.printElement("c++", self.name, "<==", file) debug.printElement("c++", self.name, "<==", file)
cmdLine=buildTools.ListToStr([ cmdLine=lutinTools.ListToStr([
target.xx, target.xx,
"-o", tmpList[1] , "-o", tmpList[1] ,
buildTools.AddPrefix("-I",self.export_path), lutinTools.AddPrefix("-I",self.export_path),
buildTools.AddPrefix("-I",self.local_path), lutinTools.AddPrefix("-I",self.local_path),
buildTools.AddPrefix("-I",depancy.path), lutinTools.AddPrefix("-I",depancy.path),
target.global_flags_cc, target.global_flags_cc,
target.global_flags_xx, target.global_flags_xx,
depancy.flags_cc, depancy.flags_cc,
@ -167,14 +167,14 @@ class module:
# check the dependency for this file : # check the dependency for this file :
if False==dependency.NeedReBuild(tmpList[1], tmpList[0], tmpList[2]): if False==dependency.NeedReBuild(tmpList[1], tmpList[0], tmpList[2]):
return tmpList[1] return tmpList[1]
buildTools.CreateDirectoryOfFile(tmpList[1]) lutinTools.CreateDirectoryOfFile(tmpList[1])
debug.printElement("c", self.name, "<==", file) debug.printElement("c", self.name, "<==", file)
cmdLine=buildTools.ListToStr([ cmdLine=lutinTools.ListToStr([
target.cc, target.cc,
"-o", tmpList[1], "-o", tmpList[1],
buildTools.AddPrefix("-I",self.export_path), lutinTools.AddPrefix("-I",self.export_path),
buildTools.AddPrefix("-I",self.local_path), lutinTools.AddPrefix("-I",self.local_path),
buildTools.AddPrefix("-I",depancy.path), lutinTools.AddPrefix("-I",depancy.path),
target.global_flags_cc, target.global_flags_cc,
depancy.flags_cc, depancy.flags_cc,
self.flags_cc, self.flags_cc,
@ -205,13 +205,13 @@ class module:
if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \ if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \
and False==dependency.NeedRePackage(tmpList[1], depancy.src, False): and False==dependency.NeedRePackage(tmpList[1], depancy.src, False):
return tmpList[1] return tmpList[1]
buildTools.CreateDirectoryOfFile(tmpList[1]) lutinTools.CreateDirectoryOfFile(tmpList[1])
debug.printElement("StaticLib", self.name, "==>", tmpList[1]) debug.printElement("StaticLib", self.name, "==>", tmpList[1])
# explicitly remove the destination to prevent error ... # explicitly remove the destination to prevent error ...
if os.path.exists(tmpList[1]) and os.path.isfile(tmpList[1]): if os.path.exists(tmpList[1]) and os.path.isfile(tmpList[1]):
os.remove(tmpList[1]) os.remove(tmpList[1])
#$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS) #$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS)
cmdLine=buildTools.ListToStr([ cmdLine=lutinTools.ListToStr([
target.ar, target.ar,
target.global_flags_ar, target.global_flags_ar,
self.flags_ar, self.flags_ar,
@ -220,7 +220,7 @@ class module:
depancy.src]) depancy.src])
RunCommand(cmdLine) RunCommand(cmdLine)
#$(Q)$(TARGET_RANLIB) $@ #$(Q)$(TARGET_RANLIB) $@
cmdLine=buildTools.ListToStr([ cmdLine=lutinTools.ListToStr([
target.ranlib, target.ranlib,
tmpList[1] ]) tmpList[1] ])
RunCommand(cmdLine) RunCommand(cmdLine)
@ -236,7 +236,7 @@ class module:
if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \ if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \
and False==dependency.NeedRePackage(tmpList[1], depancy.src, False): and False==dependency.NeedRePackage(tmpList[1], depancy.src, False):
return tmpList[1] return tmpList[1]
buildTools.CreateDirectoryOfFile(tmpList[1]) lutinTools.CreateDirectoryOfFile(tmpList[1])
debug.error("SharedLib")# + self.name + " ==> " + dst) debug.error("SharedLib")# + self.name + " ==> " + dst)
#debug.printElement("SharedLib", self.name, "==>", tmpList[1]) #debug.printElement("SharedLib", self.name, "==>", tmpList[1])
"""$(Q)$(TARGET_CXX) \ """$(Q)$(TARGET_CXX) \
@ -268,10 +268,10 @@ class module:
if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \ if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \
and False==dependency.NeedRePackage(tmpList[1], depancy.src, False): and False==dependency.NeedRePackage(tmpList[1], depancy.src, False):
return tmpList[1] return tmpList[1]
buildTools.CreateDirectoryOfFile(tmpList[1]) lutinTools.CreateDirectoryOfFile(tmpList[1])
debug.printElement("Executable", self.name, "==>", tmpList[1]) debug.printElement("Executable", self.name, "==>", tmpList[1])
#$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS) #$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS)
cmdLine=buildTools.ListToStr([ cmdLine=lutinTools.ListToStr([
target.xx, target.xx,
"-o", tmpList[1], "-o", tmpList[1],
tmpList[0], tmpList[0],
@ -307,7 +307,7 @@ class module:
baseFolder = target.GetStagingFolderData(binaryName) baseFolder = target.GetStagingFolderData(binaryName)
for element in self.files: for element in self.files:
debug.verbose("Might copy file : " + element[0] + " ==> " + element[1]) debug.verbose("Might copy file : " + element[0] + " ==> " + element[1])
buildTools.CopyFile(self.originFolder+"/"+element[0], baseFolder+"/"+element[1]) lutinTools.CopyFile(self.originFolder+"/"+element[0], baseFolder+"/"+element[1])
############################################################################### ###############################################################################
## Commands for copying files ## Commands for copying files
@ -316,18 +316,18 @@ class module:
baseFolder = target.GetStagingFolderData(binaryName) baseFolder = target.GetStagingFolderData(binaryName)
for element in self.folders: for element in self.folders:
debug.verbose("Might copy folder : " + element[0] + "==>" + element[1]) debug.verbose("Might copy folder : " + element[0] + "==>" + element[1])
buildTools.CopyAnything(self.originFolder+"/"+element[0], baseFolder+"/"+element[1]) lutinTools.CopyAnything(self.originFolder+"/"+element[0], baseFolder+"/"+element[1])
# call here to build the module # call here to build the module
def Build(self, binaryName, target): def Build(self, target, packageName):
# ckeck if not previously build # ckeck if not previously build
if target.IsModuleBuild(self.name)==True: if target.IsModuleBuild(self.name)==True:
return self.localHeritage return self.localHeritage
if binaryName==None \ if packageName==None \
and self.type=='BINARY': and self.type=='BINARY':
# this is the endpoint binary ... # this is the endpoint binary ...
binaryName = self.name packageName = self.name
else : else :
# TODO : Set it better ... # TODO : Set it better ...
None None
@ -336,7 +336,7 @@ class module:
listSubFileNeededToBuild = [] listSubFileNeededToBuild = []
subHeritage = heritage.heritage(None) subHeritage = heritage.heritage(None)
for dep in self.depends: for dep in self.depends:
inherit = Build(dep, binaryName, target) inherit = target.Build(dep, packageName)
# add at the heritage list : # add at the heritage list :
subHeritage.AddSub(inherit) subHeritage.AddSub(inherit)
@ -345,10 +345,10 @@ class module:
#debug.info(" " + self.name + " <== " + file); #debug.info(" " + self.name + " <== " + file);
fileExt = file.split(".")[-1] fileExt = file.split(".")[-1]
if fileExt == "c" or fileExt == "C": if fileExt == "c" or fileExt == "C":
resFile = self.Compile_cc_to_o(file, binaryName, target, subHeritage) resFile = self.Compile_cc_to_o(file, packageName, target, subHeritage)
listSubFileNeededToBuild.append(resFile) listSubFileNeededToBuild.append(resFile)
elif fileExt == "cpp" or fileExt == "CPP" or fileExt == "cxx" or fileExt == "CXX" or fileExt == "xx" or fileExt == "XX": elif fileExt == "cpp" or fileExt == "CPP" or fileExt == "cxx" or fileExt == "CXX" or fileExt == "xx" or fileExt == "XX":
resFile = self.Compile_xx_to_o(file, binaryName, target, subHeritage) resFile = self.Compile_xx_to_o(file, packageName, target, subHeritage)
listSubFileNeededToBuild.append(resFile) listSubFileNeededToBuild.append(resFile)
else: else:
debug.verbose(" TODO : gcc " + self.originFolder + "/" + file) debug.verbose(" TODO : gcc " + self.originFolder + "/" + file)
@ -357,10 +357,10 @@ class module:
# nothing to add ==> just dependence # nothing to add ==> just dependence
None None
elif self.type=='LIBRARY': elif self.type=='LIBRARY':
resFile = self.Link_to_a(listSubFileNeededToBuild, binaryName, target, subHeritage) resFile = self.Link_to_a(listSubFileNeededToBuild, packageName, target, subHeritage)
self.localHeritage.AddSources(resFile) self.localHeritage.AddSources(resFile)
elif self.type=='BINARY': elif self.type=='BINARY':
resFile = self.Link_to_bin(listSubFileNeededToBuild, binaryName, target, subHeritage) resFile = self.Link_to_bin(listSubFileNeededToBuild, packageName, target, subHeritage)
# generate tree for this special binary # generate tree for this special binary
self.BuildTree(target, self.name) self.BuildTree(target, self.name)
else: else:
@ -371,16 +371,16 @@ class module:
return self.localHeritage return self.localHeritage
# call here to build the module # call here to build the module
def BuildTree(self, target, binaryName): def BuildTree(self, target, packageName):
# ckeck if not previously build # ckeck if not previously build
if target.IsModuleBuildTree(self.name)==True: if target.IsModuleBuildTree(self.name)==True:
return return
#build tree of all submodules #build tree of all submodules
for dep in self.depends: for dep in self.depends:
inherit = BuildTree(dep, target, binaryName) inherit = target.BuildTree(dep, packageName)
# add all the elements # add all the elements
self.files_to_staging(binaryName, target) self.files_to_staging(packageName, target)
self.folders_to_staging(binaryName, target) self.folders_to_staging(packageName, target)
# call here to Clean the module # call here to Clean the module
@ -392,15 +392,15 @@ class module:
# remove folder of the lib ... for this targer # remove folder of the lib ... for this targer
folderBuild = target.GetBuildFolder(self.name) folderBuild = target.GetBuildFolder(self.name)
debug.info("remove folder : '" + folderBuild + "'") debug.info("remove folder : '" + folderBuild + "'")
buildTools.RemoveFolderAndSubFolder(folderBuild) lutinTools.RemoveFolderAndSubFolder(folderBuild)
elif self.type=='BINARY': elif self.type=='BINARY':
# remove folder of the lib ... for this targer # remove folder of the lib ... for this targer
folderBuild = target.GetBuildFolder(self.name) folderBuild = target.GetBuildFolder(self.name)
debug.info("remove folder : '" + folderBuild + "'") debug.info("remove folder : '" + folderBuild + "'")
buildTools.RemoveFolderAndSubFolder(folderBuild) lutinTools.RemoveFolderAndSubFolder(folderBuild)
folderStaging = target.GetStagingFolder(self.name) folderStaging = target.GetStagingFolder(self.name)
debug.info("remove folder : '" + folderStaging + "'") debug.info("remove folder : '" + folderStaging + "'")
buildTools.RemoveFolderAndSubFolder(folderStaging) lutinTools.RemoveFolderAndSubFolder(folderStaging)
else: else:
debug.error("Dit not know the element type ... (impossible case) type=" + self.type) debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
@ -470,7 +470,7 @@ class module:
for elem in list: for elem in list:
print ' %s' %elem print ' %s' %elem
def Display(self): def Display(self, target):
print '-----------------------------------------------' print '-----------------------------------------------'
print ' package : "%s"' %self.name print ' package : "%s"' %self.name
print '-----------------------------------------------' print '-----------------------------------------------'
@ -496,77 +496,39 @@ class module:
self.PrintList('local_path',self.local_path) self.PrintList('local_path',self.local_path)
# the list of all module is named : moduleList
moduleList = []
"""
"""
def AddModule(newModule):
global moduleList
for tmpMod in moduleList:
if (tmpMod.name == newModule.name):
debug.error("try to insert a secont time the same module name : " + newModule.name)
return
moduleList.append(newModule)
# with "all" we just build the bianties and packages
buildList.AddModule(newModule.name, newModule.type)
"""
"""
def Dump():
print 'Dump all module properties'
if 'moduleList' in globals():
for mod in moduleList:
mod.Display()
else:
print ' ==> no module added ...'
# return inherit packages ...
def Build(name, binName, target):
for module in moduleList:
if module.name == name:
return module.Build(binName, target)
debug.error("request to build an un-existant module name : '" + name + "'")
def BuildTree(name,target,binName):
for module in moduleList:
if module.name == name:
module.BuildTree(target,binName)
return
debug.error("request to build tree on un-existant module name : '" + name + "'")
def Clean(name,target):
for module in moduleList:
if module.name == name:
module.Clean(target)
return
debug.error("request to clean an un-existant module name : '" + name + "'")
moduleList=[]
def ImportPath(path): def ImportPath(path):
global moduleList
matches = [] matches = []
debug.debug('Start find sub File : "%s"' %path) debug.debug('Start find sub File : "%s"' %path)
for root, dirnames, filenames in os.walk(path): for root, dirnames, filenames in os.walk(path):
tmpList = fnmatch.filter(filenames, 'Makefile_*.py') tmpList = fnmatch.filter(filenames, 'lutin_*.py')
# Import the module : # Import the module :
for filename in tmpList: for filename in tmpList:
debug.debug(' Find a file : "%s"' %os.path.join(root, filename)) debug.debug(' Find a file : "%s"' %os.path.join(root, filename))
#matches.append(os.path.join(root, filename)) #matches.append(os.path.join(root, filename))
sys.path.append(os.path.dirname(os.path.join(root, filename)) ) sys.path.append(os.path.dirname(os.path.join(root, filename)) )
moduleName = filename.replace('.py', '') moduleName = filename.replace('.py', '')
debug.debug('try load : %s' %moduleName) moduleName = moduleName.replace('lutin_', '')
__import__(moduleName) debug.debug("integrate module: '" + moduleName + "' from '" + os.path.join(root, filename) + "'")
# note : Better to do a module system ==> proper ... moduleList.append([moduleName,os.path.join(root, filename)])
def LoadModule(target, name):
global moduleList
for mod in moduleList:
if mod[0]==name:
sys.path.append(os.path.dirname(mod[1]))
theModule = __import__("lutin_" + name)
tmpElement = theModule.Create(target)
target.AddModule(tmpElement)
def ListAllModule():
global moduleList
tmpListName = []
for mod in moduleList:
tmpListName.append(mod[0])
return tmpListName

112
corePython/target_Linux.py → lutinTarget.py Executable file → Normal file
View File

@ -1,14 +1,14 @@
#!/usr/bin/python #!/usr/bin/python
import debug import lutinDebug as debug
import datetime import datetime
import buildTools import lutinTools
import environement import lutinModule
class Target: class Target:
def __init__(self): def __init__(self, name, typeCompilator, debugMode):
self.name='Linux' self.name=name
debug.info("create board target : "+self.name); debug.info("create board target : "+self.name);
if "clang"==environement.GetClangMode(): if "clang"==typeCompilator:
self.cc='clang' self.cc='clang'
self.xx='clang++' self.xx='clang++'
else: else:
@ -43,7 +43,7 @@ class Target:
self.folder_arch="/" + self.name self.folder_arch="/" + self.name
if 1==environement.GetDebugMode(): if "debug"==debugMode:
self.buildMode = "debug" self.buildMode = "debug"
else: else:
self.buildMode = "release" self.buildMode = "release"
@ -57,6 +57,7 @@ class Target:
self.folder_doc="/usr/share/doc" self.folder_doc="/usr/share/doc"
self.buildDone=[] self.buildDone=[]
self.buildTreeDone=[] self.buildTreeDone=[]
self.moduleList=[]
""" """
return a list of 3 elements : return a list of 3 elements :
@ -87,13 +88,13 @@ class Target:
return list return list
def GetStagingFolder(self, binaryName): def GetStagingFolder(self, binaryName):
return buildTools.GetRunFolder() + self.folder_out + self.folder_staging + "/" + binaryName + "/" return lutinTools.GetRunFolder() + self.folder_out + self.folder_staging + "/" + binaryName + "/"
def GetStagingFolderData(self, binaryName): def GetStagingFolderData(self, binaryName):
return self.GetStagingFolder(binaryName) + self.folder_data + "/" return self.GetStagingFolder(binaryName) + self.folder_data + "/"
def GetBuildFolder(self, moduleName): def GetBuildFolder(self, moduleName):
return buildTools.GetRunFolder() + self.folder_out + self.folder_build + "/" + moduleName + "/" return lutinTools.GetRunFolder() + self.folder_out + self.folder_build + "/" + moduleName + "/"
def IsModuleBuild(self,module): def IsModuleBuild(self,module):
for mod in self.buildDone: for mod in self.buildDone:
@ -109,11 +110,92 @@ class Target:
self.buildTreeDone.append(module) self.buildTreeDone.append(module)
return False return False
def AddModule(self, newModule):
debug.debug("Import nodule for Taget : " + newModule.name)
self.moduleList.append(newModule)
# return inherit packages ...
"""
def Build(self, name, packagesName):
for module in self.moduleList:
if module.name == name:
return module.Build(self, packagesName)
debug.error("request to build an un-existant module name : '" + name + "'")
"""
def BuildTree(self, name, packagesName):
for module in self.moduleList:
if module.name == name:
module.BuildTree(self, packagesName)
return
debug.error("request to build tree on un-existant module name : '" + name + "'")
def Clean(self, name):
for module in self.moduleList:
if module.name == name:
module.Clean(self)
return
debug.error("request to clean an un-existant module name : '" + name + "'")
def LoadIfNeeded(self, name):
for elem in self.moduleList:
if elem.name == name:
return
lutinModule.LoadModule(self, name)
def LoadAll(self):
listOfAllTheModule = lutinModule.ListAllModule()
for modName in listOfAllTheModule:
self.LoadIfNeeded(modName)
def Build(self, name, packagesName=None):
if name == "dump":
debug.info("dump all")
self.LoadAll()
print 'Dump all module properties'
for mod in self.moduleList:
mod.Display(self)
elif name == "all":
debug.info("Build all")
self.LoadAll()
for mod in self.moduleList:
if mod.type == 'BINARY':
mod.Build(self, None)
elif name == "clean":
debug.info("Clean all")
self.LoadAll()
for mod in self.moduleList:
mod.Clean(self)
else:
myLen = len(name)
if name[myLen-5:] == "-dump":
tmpName = name[:myLen-5]
self.LoadIfNeeded(tmpName)
# clean requested
for mod in self.moduleList:
if mod.name == tmpName:
debug.info("dump module '" + tmpName + "'")
mod.Display(self)
return
debug.error("not know module name : '" + cleanName + "' to clean it")
elif name[myLen-6:] == "-clean":
cleanName = name[:myLen-6]
self.LoadIfNeeded(cleanName)
# clean requested
for mod in self.moduleList:
if mod.name == cleanName:
debug.info("Clean module '" + cleanName + "'")
mod.Clean(self)
return
debug.error("not know module name : '" + cleanName + "' to clean it")
else:
# Build requested
self.LoadIfNeeded(name)
for mod in self.moduleList:
if mod.name == name:
debug.info("Build module '" + name + "'")
return mod.Build(self, None)
debug.error("not know module name : '" + name + "' to build it")
"""
TARGET_GLOBAL_LDFLAGS = "-L$(TARGET_OUT_STAGING)/lib
TARGET_GLOBAL_LDFLAGS += -L$(TARGET_OUT_STAGING)/usr/lib
TARGET_GLOBAL_LDFLAGS_SHARED += -L$(TARGET_OUT_STAGING)/lib
TARGET_GLOBAL_LDFLAGS_SHARED += -L$(TARGET_OUT_STAGING)/usr/lib
"""

0
corePython/target_Android.py → lutinTargetAndroid.py Executable file → Normal file
View File

12
lutinTargetLinux.py Normal file
View File

@ -0,0 +1,12 @@
#!/usr/bin/python
import lutinDebug as debug
import datetime
import lutinTools
import lutinEnv as environement
import lutinTarget
class TargetLinux(lutinTarget.Target):
def __init__(self, typeCompilator, debugMode):
lutinTarget.Target.__init__(self, "Linux", typeCompilator, debugMode)

0
corePython/target_MacOs.py → lutinTargetMacOs.py Executable file → Normal file
View File

0
corePython/target_Windows.py → lutinTargetWindows.py Executable file → Normal file
View File

View File

@ -2,7 +2,7 @@
import os import os
import shutil import shutil
import errno import errno
import debug import lutinDebug as debug
import fnmatch import fnmatch