From f3b74bbc02bc94ce4e08442eee9b0445188f9177 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 21 Apr 2013 22:17:47 +0200 Subject: [PATCH] [DEV] Python 'lutin' build tool is nearly ok --- corePython/buildList.py | 89 --------- grc.conf.gcc | 58 ------ make.py => lutin.py | 42 ++--- corePython/debug.py => lutinDebug.py | 0 corePython/dependency.py => lutinDepend.py | 4 +- corePython/environement.py => lutinEnv.py | 2 +- corePython/heritage.py => lutinHeritage.py | 3 +- corePython/host.py => lutinHost.py | 2 +- lutinList.py | 44 +++++ corePython/module.py => lutinModule.py | 170 +++++++----------- corePython/target_Linux.py => lutinTarget.py | 112 ++++++++++-- ...target_Android.py => lutinTargetAndroid.py | 0 lutinTargetLinux.py | 12 ++ .../target_MacOs.py => lutinTargetMacOs.py | 0 ...target_Windows.py => lutinTargetWindows.py | 0 corePython/buildTools.py => lutinTools.py | 2 +- 16 files changed, 244 insertions(+), 296 deletions(-) delete mode 100644 corePython/buildList.py delete mode 100644 grc.conf.gcc rename make.py => lutin.py (85%) rename corePython/debug.py => lutinDebug.py (100%) rename corePython/dependency.py => lutinDepend.py (98%) rename corePython/environement.py => lutinEnv.py (96%) rename corePython/heritage.py => lutinHeritage.py (98%) rename corePython/host.py => lutinHost.py (92%) mode change 100755 => 100644 create mode 100644 lutinList.py rename corePython/module.py => lutinModule.py (82%) mode change 100755 => 100644 rename corePython/target_Linux.py => lutinTarget.py (52%) mode change 100755 => 100644 rename corePython/target_Android.py => lutinTargetAndroid.py (100%) mode change 100755 => 100644 create mode 100644 lutinTargetLinux.py rename corePython/target_MacOs.py => lutinTargetMacOs.py (100%) mode change 100755 => 100644 rename corePython/target_Windows.py => lutinTargetWindows.py (100%) mode change 100755 => 100644 rename corePython/buildTools.py => lutinTools.py (98%) diff --git a/corePython/buildList.py b/corePython/buildList.py deleted file mode 100644 index f090de9..0000000 --- a/corePython/buildList.py +++ /dev/null @@ -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 - diff --git a/grc.conf.gcc b/grc.conf.gcc deleted file mode 100644 index 30e7893..0000000 --- a/grc.conf.gcc +++ /dev/null @@ -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 \ No newline at end of file diff --git a/make.py b/lutin.py similarity index 85% rename from make.py rename to lutin.py index 0a749b0..439fcef 100755 --- a/make.py +++ b/lutin.py @@ -4,11 +4,8 @@ import sys import os import inspect import fnmatch -if __name__ == "__main__": - sys.path.append(os.path.dirname(__file__) + "/corePython/" ) - -import debug -import environement +import lutinDebug as debug +import lutinEnv """ @@ -64,7 +61,7 @@ def parseGenericArg(argument,active): return True elif argument == "-f" or argument == "--force": if active==True: - environement.SetForceMode(True) + lutinEnv.SetForceMode(True) return True return False @@ -75,26 +72,25 @@ if __name__ == "__main__": parseGenericArg(argument, True) # now import other standard module (must be done here and not before ... -import module -import host -import buildTools -import host -import buildList +import lutinModule as module +import lutinHost as host +import lutinTools +import lutinHost as host +import lutinList as buildList +import lutinTargetLinux """ Run everything that is needed in the system """ def Start(): + target = lutinTargetLinux.TargetLinux("gcc", "debug") actionDone=False # parse all argument for argument in sys.argv[1:]: if True==parseGenericArg(argument, False): None # nothing to do ... - elif argument == "dump": - module.Dump() - actionDone=True elif argument[:11] == "--platform=" or argument[:3] == "-p=": tmpArg="" if argument[:3] == "-p=": @@ -109,34 +105,34 @@ def Start(): else: tmpArg=argument[11:] if "debug"==tmpArg: - environement.SetDebugMode(1) + lutinEnv.SetDebugMode(1) elif "release"==tmpArg: - environement.SetDebugMode(0) + lutinEnv.SetDebugMode(0) else: 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=": tmpArg="" if argument[:3] == "-t=": tmpArg=argument[3:] else: tmpArg=argument[11:] - environement.SetCompileMode(tmpArg) + lutinEnv.SetCompileMode(tmpArg) else: - buildList.Build(argument) + target.Build(argument) actionDone=True # if no action done : we do "all" ... if actionDone==False: - buildList.Build("all") + target.Build("all") """ When the user use with make.py we initialise ourself """ if __name__ == '__main__': debug.verbose("Use Make as a make stadard") - sys.path.append(buildTools.GetRunFolder()) - debug.verbose(" try to impoert module 'Makefile.py'") - __import__("Makefile") + sys.path.append(lutinTools.GetRunFolder()) + debug.verbose(" try to impoert module 'lutinBase.py'") + __import__("lutinBase") Start() diff --git a/corePython/debug.py b/lutinDebug.py similarity index 100% rename from corePython/debug.py rename to lutinDebug.py diff --git a/corePython/dependency.py b/lutinDepend.py similarity index 98% rename from corePython/dependency.py rename to lutinDepend.py index e80c433..3343758 100644 --- a/corePython/dependency.py +++ b/lutinDepend.py @@ -1,7 +1,7 @@ #!/usr/bin/python import os -import debug -import environement +import lutinDebug as debug +import lutinEnv as environement def NeedReBuild(dst, src, dependFile): diff --git a/corePython/environement.py b/lutinEnv.py similarity index 96% rename from corePython/environement.py rename to lutinEnv.py index bd1d997..a4098bb 100644 --- a/corePython/environement.py +++ b/lutinEnv.py @@ -1,5 +1,5 @@ #!/usr/bin/python -import debug +import lutinDebug as debug debugMode=0 diff --git a/corePython/heritage.py b/lutinHeritage.py similarity index 98% rename from corePython/heritage.py rename to lutinHeritage.py index 28754eb..f43c6d7 100644 --- a/corePython/heritage.py +++ b/lutinHeritage.py @@ -1,7 +1,6 @@ #!/usr/bin/python import sys -import buildTools -import debug +import lutinDebug as debug diff --git a/corePython/host.py b/lutinHost.py old mode 100755 new mode 100644 similarity index 92% rename from corePython/host.py rename to lutinHost.py index ec1d6a0..2799063 --- a/corePython/host.py +++ b/lutinHost.py @@ -1,6 +1,6 @@ #!/usr/bin/python import platform -import debug +import lutinDebug as debug # print os.name # ==> 'posix' if platform.system() == "Linux": diff --git a/lutinList.py b/lutinList.py new file mode 100644 index 0000000..670de38 --- /dev/null +++ b/lutinList.py @@ -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 + diff --git a/corePython/module.py b/lutinModule.py old mode 100755 new mode 100644 similarity index 82% rename from corePython/module.py rename to lutinModule.py index cfc550e..3c12f9a --- a/corePython/module.py +++ b/lutinModule.py @@ -3,13 +3,13 @@ import sys import os import inspect import fnmatch -import module -import host -import buildTools -import debug -import buildList -import heritage -import dependency +import lutinModule as module +import lutinHost as host +import lutinTools +import lutinDebug as debug +import lutinList as buildList +import lutinHeritage as heritage +import lutinDepend as dependency def RunCommand(cmdLine): debug.debug(cmdLine) @@ -74,7 +74,7 @@ class module: debug.error(' ==> error : "%s" ' %moduleType) raise 'Input value error' self.originFile = file; - self.originFolder = buildTools.GetCurrentPath(self.originFile) + self.originFolder = lutinTools.GetCurrentPath(self.originFile) self.name=moduleName self.localHeritage = heritage.heritage(self) @@ -83,7 +83,7 @@ class module: ############################################################################### def Compile_mm_to_o(self, file, binary, target, depancy): # TODO : Check depedency ... - buildTools.CreateDirectoryOfFile(dst) + lutinTools.CreateDirectoryOfFile(dst) debug.printElement("m++", self.name, "<==", file) """ cmdLine= $(TARGET_CXX) \ @@ -104,7 +104,7 @@ class module: ############################################################################### def Compile_m_to_o(self, file, binary, target, depancy): # TODO : Check depedency ... - buildTools.CreateDirectoryOfFile(dst) + lutinTools.CreateDirectoryOfFile(dst) debug.printElement("m", self.name, "<==", file) """ $(TARGET_CC) \ @@ -129,14 +129,14 @@ class module: # check the dependency for this file : if False==dependency.NeedReBuild(tmpList[1], tmpList[0], tmpList[2]): return tmpList[1] - buildTools.CreateDirectoryOfFile(tmpList[1]) + lutinTools.CreateDirectoryOfFile(tmpList[1]) debug.printElement("c++", self.name, "<==", file) - cmdLine=buildTools.ListToStr([ + cmdLine=lutinTools.ListToStr([ target.xx, "-o", tmpList[1] , - buildTools.AddPrefix("-I",self.export_path), - buildTools.AddPrefix("-I",self.local_path), - buildTools.AddPrefix("-I",depancy.path), + lutinTools.AddPrefix("-I",self.export_path), + lutinTools.AddPrefix("-I",self.local_path), + lutinTools.AddPrefix("-I",depancy.path), target.global_flags_cc, target.global_flags_xx, depancy.flags_cc, @@ -167,14 +167,14 @@ class module: # check the dependency for this file : if False==dependency.NeedReBuild(tmpList[1], tmpList[0], tmpList[2]): return tmpList[1] - buildTools.CreateDirectoryOfFile(tmpList[1]) + lutinTools.CreateDirectoryOfFile(tmpList[1]) debug.printElement("c", self.name, "<==", file) - cmdLine=buildTools.ListToStr([ + cmdLine=lutinTools.ListToStr([ target.cc, "-o", tmpList[1], - buildTools.AddPrefix("-I",self.export_path), - buildTools.AddPrefix("-I",self.local_path), - buildTools.AddPrefix("-I",depancy.path), + lutinTools.AddPrefix("-I",self.export_path), + lutinTools.AddPrefix("-I",self.local_path), + lutinTools.AddPrefix("-I",depancy.path), target.global_flags_cc, depancy.flags_cc, self.flags_cc, @@ -205,13 +205,13 @@ class module: if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \ and False==dependency.NeedRePackage(tmpList[1], depancy.src, False): return tmpList[1] - buildTools.CreateDirectoryOfFile(tmpList[1]) + lutinTools.CreateDirectoryOfFile(tmpList[1]) debug.printElement("StaticLib", self.name, "==>", tmpList[1]) # explicitly remove the destination to prevent error ... if os.path.exists(tmpList[1]) and os.path.isfile(tmpList[1]): os.remove(tmpList[1]) #$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS) - cmdLine=buildTools.ListToStr([ + cmdLine=lutinTools.ListToStr([ target.ar, target.global_flags_ar, self.flags_ar, @@ -220,7 +220,7 @@ class module: depancy.src]) RunCommand(cmdLine) #$(Q)$(TARGET_RANLIB) $@ - cmdLine=buildTools.ListToStr([ + cmdLine=lutinTools.ListToStr([ target.ranlib, tmpList[1] ]) RunCommand(cmdLine) @@ -236,7 +236,7 @@ class module: if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \ and False==dependency.NeedRePackage(tmpList[1], depancy.src, False): return tmpList[1] - buildTools.CreateDirectoryOfFile(tmpList[1]) + lutinTools.CreateDirectoryOfFile(tmpList[1]) debug.error("SharedLib")# + self.name + " ==> " + dst) #debug.printElement("SharedLib", self.name, "==>", tmpList[1]) """$(Q)$(TARGET_CXX) \ @@ -268,10 +268,10 @@ class module: if False==dependency.NeedRePackage(tmpList[1], tmpList[0], True) \ and False==dependency.NeedRePackage(tmpList[1], depancy.src, False): return tmpList[1] - buildTools.CreateDirectoryOfFile(tmpList[1]) + lutinTools.CreateDirectoryOfFile(tmpList[1]) debug.printElement("Executable", self.name, "==>", tmpList[1]) #$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS) - cmdLine=buildTools.ListToStr([ + cmdLine=lutinTools.ListToStr([ target.xx, "-o", tmpList[1], tmpList[0], @@ -307,7 +307,7 @@ class module: baseFolder = target.GetStagingFolderData(binaryName) for element in self.files: 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 @@ -316,18 +316,18 @@ class module: baseFolder = target.GetStagingFolderData(binaryName) for element in self.folders: 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 - def Build(self, binaryName, target): + def Build(self, target, packageName): # ckeck if not previously build if target.IsModuleBuild(self.name)==True: return self.localHeritage - if binaryName==None \ + if packageName==None \ and self.type=='BINARY': # this is the endpoint binary ... - binaryName = self.name + packageName = self.name else : # TODO : Set it better ... None @@ -336,7 +336,7 @@ class module: listSubFileNeededToBuild = [] subHeritage = heritage.heritage(None) for dep in self.depends: - inherit = Build(dep, binaryName, target) + inherit = target.Build(dep, packageName) # add at the heritage list : subHeritage.AddSub(inherit) @@ -345,10 +345,10 @@ class module: #debug.info(" " + self.name + " <== " + file); fileExt = file.split(".")[-1] 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) 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) else: debug.verbose(" TODO : gcc " + self.originFolder + "/" + file) @@ -357,10 +357,10 @@ class module: # nothing to add ==> just dependence None 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) 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 self.BuildTree(target, self.name) else: @@ -371,16 +371,16 @@ class module: return self.localHeritage # call here to build the module - def BuildTree(self, target, binaryName): + def BuildTree(self, target, packageName): # ckeck if not previously build if target.IsModuleBuildTree(self.name)==True: return #build tree of all submodules for dep in self.depends: - inherit = BuildTree(dep, target, binaryName) + inherit = target.BuildTree(dep, packageName) # add all the elements - self.files_to_staging(binaryName, target) - self.folders_to_staging(binaryName, target) + self.files_to_staging(packageName, target) + self.folders_to_staging(packageName, target) # call here to Clean the module @@ -392,15 +392,15 @@ class module: # remove folder of the lib ... for this targer folderBuild = target.GetBuildFolder(self.name) debug.info("remove folder : '" + folderBuild + "'") - buildTools.RemoveFolderAndSubFolder(folderBuild) + lutinTools.RemoveFolderAndSubFolder(folderBuild) elif self.type=='BINARY': # remove folder of the lib ... for this targer folderBuild = target.GetBuildFolder(self.name) debug.info("remove folder : '" + folderBuild + "'") - buildTools.RemoveFolderAndSubFolder(folderBuild) + lutinTools.RemoveFolderAndSubFolder(folderBuild) folderStaging = target.GetStagingFolder(self.name) debug.info("remove folder : '" + folderStaging + "'") - buildTools.RemoveFolderAndSubFolder(folderStaging) + lutinTools.RemoveFolderAndSubFolder(folderStaging) else: debug.error("Dit not know the element type ... (impossible case) type=" + self.type) @@ -470,7 +470,7 @@ class module: for elem in list: print ' %s' %elem - def Display(self): + def Display(self, target): print '-----------------------------------------------' print ' package : "%s"' %self.name print '-----------------------------------------------' @@ -496,77 +496,39 @@ class module: 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): + global moduleList matches = [] debug.debug('Start find sub File : "%s"' %path) for root, dirnames, filenames in os.walk(path): - tmpList = fnmatch.filter(filenames, 'Makefile_*.py') + tmpList = fnmatch.filter(filenames, 'lutin_*.py') # Import the module : for filename in tmpList: debug.debug(' Find a file : "%s"' %os.path.join(root, filename)) #matches.append(os.path.join(root, filename)) sys.path.append(os.path.dirname(os.path.join(root, filename)) ) moduleName = filename.replace('.py', '') - debug.debug('try load : %s' %moduleName) - __import__(moduleName) - # note : Better to do a module system ==> proper ... - - - + moduleName = moduleName.replace('lutin_', '') + debug.debug("integrate module: '" + moduleName + "' from '" + os.path.join(root, filename) + "'") + 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 diff --git a/corePython/target_Linux.py b/lutinTarget.py old mode 100755 new mode 100644 similarity index 52% rename from corePython/target_Linux.py rename to lutinTarget.py index 78b13f5..17614c0 --- a/corePython/target_Linux.py +++ b/lutinTarget.py @@ -1,14 +1,14 @@ #!/usr/bin/python -import debug +import lutinDebug as debug import datetime -import buildTools -import environement +import lutinTools +import lutinModule class Target: - def __init__(self): - self.name='Linux' + def __init__(self, name, typeCompilator, debugMode): + self.name=name debug.info("create board target : "+self.name); - if "clang"==environement.GetClangMode(): + if "clang"==typeCompilator: self.cc='clang' self.xx='clang++' else: @@ -43,7 +43,7 @@ class Target: self.folder_arch="/" + self.name - if 1==environement.GetDebugMode(): + if "debug"==debugMode: self.buildMode = "debug" else: self.buildMode = "release" @@ -57,6 +57,7 @@ class Target: self.folder_doc="/usr/share/doc" self.buildDone=[] self.buildTreeDone=[] + self.moduleList=[] """ return a list of 3 elements : @@ -87,13 +88,13 @@ class Target: return list 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): return self.GetStagingFolder(binaryName) + self.folder_data + "/" 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): for mod in self.buildDone: @@ -109,11 +110,92 @@ class Target: self.buildTreeDone.append(module) 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 -""" \ No newline at end of file diff --git a/corePython/target_Android.py b/lutinTargetAndroid.py old mode 100755 new mode 100644 similarity index 100% rename from corePython/target_Android.py rename to lutinTargetAndroid.py diff --git a/lutinTargetLinux.py b/lutinTargetLinux.py new file mode 100644 index 0000000..6da0116 --- /dev/null +++ b/lutinTargetLinux.py @@ -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) + + diff --git a/corePython/target_MacOs.py b/lutinTargetMacOs.py old mode 100755 new mode 100644 similarity index 100% rename from corePython/target_MacOs.py rename to lutinTargetMacOs.py diff --git a/corePython/target_Windows.py b/lutinTargetWindows.py old mode 100755 new mode 100644 similarity index 100% rename from corePython/target_Windows.py rename to lutinTargetWindows.py diff --git a/corePython/buildTools.py b/lutinTools.py similarity index 98% rename from corePython/buildTools.py rename to lutinTools.py index 781a657..ab93e92 100644 --- a/corePython/buildTools.py +++ b/lutinTools.py @@ -2,7 +2,7 @@ import os import shutil import errno -import debug +import lutinDebug as debug import fnmatch