[DEV] build all clean and correct dependency check if availlable
This commit is contained in:
parent
e5235b45df
commit
860d7607af
@ -23,7 +23,7 @@ def Build(name):
|
|||||||
for elem in availlable:
|
for elem in availlable:
|
||||||
if elem[1] == "Module":
|
if elem[1] == "Module":
|
||||||
if elem[2] == "bin":
|
if elem[2] == "bin":
|
||||||
module.Build(elem[0], GetCurrentTarget())
|
module.Build(elem[0], None, GetCurrentTarget())
|
||||||
else:
|
else:
|
||||||
debug.error("TODO ... Build package '" + elem[0] + "'")
|
debug.error("TODO ... Build package '" + elem[0] + "'")
|
||||||
elif name == "clean":
|
elif name == "clean":
|
||||||
@ -55,7 +55,7 @@ def Build(name):
|
|||||||
if elem[0] == name:
|
if elem[0] == name:
|
||||||
if elem[1] == "Module":
|
if elem[1] == "Module":
|
||||||
debug.info("Build module '" + name + "'")
|
debug.info("Build module '" + name + "'")
|
||||||
module.Build(name, GetCurrentTarget())
|
module.Build(name, None, GetCurrentTarget())
|
||||||
else:
|
else:
|
||||||
debug.info("Build package '" + name + "'")
|
debug.info("Build package '" + name + "'")
|
||||||
debug.error("TODO ... Build package '" + cleanName + "'")
|
debug.error("TODO ... Build package '" + cleanName + "'")
|
||||||
|
@ -26,6 +26,13 @@ def CreateDirectoryOfFile(file):
|
|||||||
os.makedirs(folder)
|
os.makedirs(folder)
|
||||||
|
|
||||||
|
|
||||||
|
def RemoveFolderAndSubFolder(path):
|
||||||
|
if os.path.isdir(path):
|
||||||
|
debug.verbose("remove folder : '" + path + "'")
|
||||||
|
shutil.rmtree(path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ListToStr(list):
|
def ListToStr(list):
|
||||||
if type(list) == type(str()):
|
if type(list) == type(str()):
|
||||||
return list + " "
|
return list + " "
|
||||||
|
104
corePython/dependency.py
Normal file
104
corePython/dependency.py
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import os
|
||||||
|
import debug
|
||||||
|
import environement
|
||||||
|
|
||||||
|
|
||||||
|
def NeedReBuild(dst, src, dependFile):
|
||||||
|
debug.verbose("Resuest check of dependency of :")
|
||||||
|
debug.verbose(" dst='" + dst + "'")
|
||||||
|
debug.verbose(" str='" + src + "'")
|
||||||
|
debug.verbose(" dept='" + dependFile + "'")
|
||||||
|
# if force mode selected ==> just force rebuild ...
|
||||||
|
if environement.GetForceMode():
|
||||||
|
debug.verbose(" ==> must rebuild (force mode)")
|
||||||
|
return True
|
||||||
|
|
||||||
|
# check if the destination existed:
|
||||||
|
if False==os.path.exists(dst):
|
||||||
|
debug.verbose(" ==> must rebuild (dst does not exist)")
|
||||||
|
return True
|
||||||
|
# chek the basic date if the 2 files
|
||||||
|
if os.path.getmtime(src) > os.path.getmtime(dst):
|
||||||
|
debug.verbose(" ==> must rebuild (source time greater)")
|
||||||
|
return True
|
||||||
|
# now we need to parse the file to find all the dependency file
|
||||||
|
# file is done like
|
||||||
|
# file : \
|
||||||
|
# dep1 \
|
||||||
|
# dep2
|
||||||
|
#
|
||||||
|
# dep2 : \
|
||||||
|
# dep4
|
||||||
|
#
|
||||||
|
|
||||||
|
if False==os.path.exists(dependFile):
|
||||||
|
debug.verbose(" ==> must rebuild (no depending file)")
|
||||||
|
return True
|
||||||
|
|
||||||
|
debug.verbose(" start parsing dependency file : '" + dependFile + "'")
|
||||||
|
file = open(dependFile, "r")
|
||||||
|
for curLine in file.readlines():
|
||||||
|
# normal file : end with : ": \\n"
|
||||||
|
curLine = curLine[:len(curLine)-1]
|
||||||
|
testFile=""
|
||||||
|
if curLine[len(curLine)-3:] == ': \\' \
|
||||||
|
or curLine[len(curLine)-2:] == ': ' \
|
||||||
|
or curLine[len(curLine)-1:] == ':':
|
||||||
|
debug.verbose(" Line (no check (already done) : '" + curLine + "'");
|
||||||
|
elif curLine[len(curLine)-2:] == ' \\':
|
||||||
|
testFile = curLine[1:len(curLine)-2]
|
||||||
|
debug.verbose(" Line (might check1) : '" + testFile + "'");
|
||||||
|
elif len(curLine) == 0:
|
||||||
|
debug.verbose(" Line (Not parsed) : '" + curLine + "'");
|
||||||
|
else:
|
||||||
|
testFile = curLine[1:]
|
||||||
|
debug.verbose(" Line (might check2) : '" + testFile + "'");
|
||||||
|
# really check files:
|
||||||
|
if testFile!="":
|
||||||
|
debug.verbose(" ==> test");
|
||||||
|
if False==os.path.exists(testFile):
|
||||||
|
debug.warning(" ==> must rebuild (a dependency file does not exist)")
|
||||||
|
return True
|
||||||
|
if os.path.getmtime(testFile) > os.path.getmtime(dst):
|
||||||
|
debug.warning(" ==> must rebuild (a dependency file time is newer)")
|
||||||
|
return True
|
||||||
|
|
||||||
|
debug.verbose(" ==> Not rebuild (all dependency is OK)")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def NeedRePackage(dst, srcList, mustHaveSrc):
|
||||||
|
debug.verbose("Resuest check of dependency of :")
|
||||||
|
debug.verbose(" dst='" + dst + "'")
|
||||||
|
debug.verbose(" src()=")
|
||||||
|
for src in srcList:
|
||||||
|
debug.verbose(" '" + src + "'")
|
||||||
|
|
||||||
|
if mustHaveSrc==False and len(srcList)==0:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# if force mode selected ==> just force rebuild ...
|
||||||
|
if environement.GetForceMode():
|
||||||
|
debug.verbose(" ==> must re-package (force mode)")
|
||||||
|
return True
|
||||||
|
|
||||||
|
# check if the destination existed:
|
||||||
|
if False==os.path.exists(dst):
|
||||||
|
debug.verbose(" ==> must re-package (dst does not exist)")
|
||||||
|
return True
|
||||||
|
# chek the basic date if the 2 files
|
||||||
|
if len(srcList)==0:
|
||||||
|
debug.verbose(" ==> must re-package (no source ???)")
|
||||||
|
return True
|
||||||
|
for src in srcList:
|
||||||
|
if os.path.getmtime(src) > os.path.getmtime(dst):
|
||||||
|
debug.verbose(" ==> must re-package (source time greater) : '" + src + "'")
|
||||||
|
return True
|
||||||
|
|
||||||
|
debug.verbose(" ==> Not re-package (all dependency is OK)")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
46
corePython/environement.py
Normal file
46
corePython/environement.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import debug
|
||||||
|
|
||||||
|
debugMode=0
|
||||||
|
|
||||||
|
def SetDebugMode(val):
|
||||||
|
global debugMode
|
||||||
|
if val==1:
|
||||||
|
debugMode = 1
|
||||||
|
else:
|
||||||
|
debugMode = 0
|
||||||
|
|
||||||
|
def GetDebugMode():
|
||||||
|
global debugMode
|
||||||
|
return debugMode
|
||||||
|
|
||||||
|
CompileMode="gcc"
|
||||||
|
|
||||||
|
def SetCompileMode(val):
|
||||||
|
global CompileMode
|
||||||
|
if val=="clang":
|
||||||
|
CompileMode = val
|
||||||
|
if val=="gcc":
|
||||||
|
CompileMode = val
|
||||||
|
else:
|
||||||
|
debug.error("not understand compiling tool mode : '" + val + "' can be [gcc/clang]")
|
||||||
|
CompileMode = "gcc"
|
||||||
|
|
||||||
|
def GetClangMode():
|
||||||
|
global CompileMode
|
||||||
|
return CompileMode
|
||||||
|
|
||||||
|
forceMode=False
|
||||||
|
|
||||||
|
def SetForceMode(val):
|
||||||
|
global forceMode
|
||||||
|
if val==1:
|
||||||
|
forceMode = 1
|
||||||
|
else:
|
||||||
|
forceMode = 0
|
||||||
|
|
||||||
|
def GetForceMode():
|
||||||
|
global forceMode
|
||||||
|
return forceMode
|
||||||
|
|
||||||
|
|
76
corePython/heritage.py
Normal file
76
corePython/heritage.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import sys
|
||||||
|
import buildTools
|
||||||
|
import debug
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class heritage:
|
||||||
|
def __init__(self, module):
|
||||||
|
## Remove all variable to prevent error of multiple definition
|
||||||
|
# all the parameter that the upper classe need when build
|
||||||
|
self.flags_ld=[]
|
||||||
|
self.flags_cc=[]
|
||||||
|
self.flags_xx=[]
|
||||||
|
self.flags_m=[]
|
||||||
|
self.flags_mm=[]
|
||||||
|
# sources list:
|
||||||
|
self.src=[]
|
||||||
|
self.path=[]
|
||||||
|
# update is set at true when data are newly created ==> force upper element to update
|
||||||
|
self.hasBeenUpdated=False
|
||||||
|
|
||||||
|
if type(module) != type(None):
|
||||||
|
# all the parameter that the upper classe need when build
|
||||||
|
self.flags_ld=module.export_flags_ld
|
||||||
|
self.flags_cc=module.export_flags_cc
|
||||||
|
self.flags_xx=module.export_flags_xx
|
||||||
|
self.flags_m=module.export_flags_m
|
||||||
|
self.flags_mm=module.export_flags_mm
|
||||||
|
self.path=module.export_path
|
||||||
|
|
||||||
|
def AppendToInternalList(self, listout, list):
|
||||||
|
if type(list) == type(str()):
|
||||||
|
listout.append(list)
|
||||||
|
else:
|
||||||
|
# mulyiple imput in the list ...
|
||||||
|
for elem in list:
|
||||||
|
listout.append(elem)
|
||||||
|
|
||||||
|
def AddFlag_LD(self, list):
|
||||||
|
self.AppendToInternalList(self.flags_ld, list)
|
||||||
|
|
||||||
|
def AddFlag_CC(self, list):
|
||||||
|
self.AppendToInternalList(self.flags_cc, list)
|
||||||
|
|
||||||
|
def AddFlag_XX(self, list):
|
||||||
|
self.AppendToInternalList(self.flags_xx, list)
|
||||||
|
|
||||||
|
def AddFlag_M(self, list):
|
||||||
|
self.AppendToInternalList(self.flags_m, list)
|
||||||
|
|
||||||
|
def AddFlag_MM(self, list):
|
||||||
|
self.AppendToInternalList(self.flags_mm, list)
|
||||||
|
|
||||||
|
def AddImportPath(self, list):
|
||||||
|
self.AppendToInternalList(self.path, list)
|
||||||
|
|
||||||
|
def AddSources(self, list):
|
||||||
|
self.AppendToInternalList(self.src, list)
|
||||||
|
|
||||||
|
def NeedUpdate(self, list):
|
||||||
|
self.hasBeenUpdated=True
|
||||||
|
|
||||||
|
def AddSub(self, other):
|
||||||
|
if type(other) == type(None):
|
||||||
|
debug.verbose("input of the heriatege class is None !!!")
|
||||||
|
return
|
||||||
|
if other.hasBeenUpdated==True:
|
||||||
|
self.hasBeenUpdated = True
|
||||||
|
self.AddFlag_LD(other.flags_ld)
|
||||||
|
self.AddFlag_CC(other.flags_cc)
|
||||||
|
self.AddFlag_XX(other.flags_xx)
|
||||||
|
self.AddFlag_M(other.flags_m)
|
||||||
|
self.AddFlag_MM(other.flags_mm)
|
||||||
|
self.AddImportPath(other.path)
|
||||||
|
self.AddSources(other.src)
|
@ -9,10 +9,12 @@ import buildTools
|
|||||||
import debug
|
import debug
|
||||||
import buildList
|
import buildList
|
||||||
import heritage
|
import heritage
|
||||||
|
import dependency
|
||||||
|
|
||||||
def RunCommand(cmdLine):
|
def RunCommand(cmdLine):
|
||||||
debug.debug(cmdLine)
|
debug.debug(cmdLine)
|
||||||
ret = os.system(cmdLine)
|
ret = os.system(cmdLine)
|
||||||
|
# TODO : Use "subprocess" instead ==> permit to pipline the renderings ...
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
#print "result val = " + str(ret)
|
#print "result val = " + str(ret)
|
||||||
debug.error("can not compile file ... ")
|
debug.error("can not compile file ... ")
|
||||||
@ -64,7 +66,8 @@ class module:
|
|||||||
## end of basic INIT ...
|
## end of basic INIT ...
|
||||||
if moduleType == 'BINARY' \
|
if moduleType == 'BINARY' \
|
||||||
or moduleType == 'LIBRARY' \
|
or moduleType == 'LIBRARY' \
|
||||||
or moduleType == 'PACKAGE':
|
or moduleType == 'PACKAGE' \
|
||||||
|
or moduleType == 'PREBUILD':
|
||||||
self.type=moduleType
|
self.type=moduleType
|
||||||
else :
|
else :
|
||||||
debug.error('for module "%s"' %moduleName)
|
debug.error('for module "%s"' %moduleName)
|
||||||
@ -78,7 +81,7 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for running gcc to compile a m++ file.
|
## Commands for running gcc to compile a m++ file.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
def Compile_mm_to_o(self, file, target, depancy):
|
def Compile_mm_to_o(self, file, binary, target, depancy):
|
||||||
# TODO : Check depedency ...
|
# TODO : Check depedency ...
|
||||||
buildTools.CreateDirectoryOfFile(dst)
|
buildTools.CreateDirectoryOfFile(dst)
|
||||||
debug.printElement("m++", self.name, "<==", file)
|
debug.printElement("m++", self.name, "<==", file)
|
||||||
@ -99,7 +102,7 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for running gcc to compile a m file.
|
## Commands for running gcc to compile a m file.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
def Compile_m_to_o(self, file, target, depancy):
|
def Compile_m_to_o(self, file, binary, target, depancy):
|
||||||
# TODO : Check depedency ...
|
# TODO : Check depedency ...
|
||||||
buildTools.CreateDirectoryOfFile(dst)
|
buildTools.CreateDirectoryOfFile(dst)
|
||||||
debug.printElement("m", self.name, "<==", file)
|
debug.printElement("m", self.name, "<==", file)
|
||||||
@ -121,12 +124,11 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for running gcc to compile a C++ file.
|
## Commands for running gcc to compile a C++ file.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
def Compile_xx_to_o(self, file, target, depancy):
|
def Compile_xx_to_o(self, file, binary, target, depancy):
|
||||||
tmpList = target.GenerateFile(self.name,self.originFolder,file,"obj")
|
tmpList = target.GenerateFile(binary, self.name,self.originFolder,file,"obj")
|
||||||
# TODO : Check depedency ...
|
# check the dependency for this file :
|
||||||
if os.path.exists(tmpList[1]):
|
if False==dependency.NeedReBuild(tmpList[1], tmpList[0], tmpList[2]):
|
||||||
if os.path.getmtime(tmpList[1]) > os.path.getmtime(tmpList[0]):
|
return tmpList[1]
|
||||||
return tmpList[1]
|
|
||||||
buildTools.CreateDirectoryOfFile(tmpList[1])
|
buildTools.CreateDirectoryOfFile(tmpList[1])
|
||||||
debug.printElement("c++", self.name, "<==", file)
|
debug.printElement("c++", self.name, "<==", file)
|
||||||
cmdLine=buildTools.ListToStr([
|
cmdLine=buildTools.ListToStr([
|
||||||
@ -160,13 +162,11 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for running gcc to compile a C file.
|
## Commands for running gcc to compile a C file.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
def Compile_cc_to_o(self, file, binary, target, depancy):
|
||||||
def Compile_cc_to_o(self, file, target, depancy):
|
tmpList = target.GenerateFile(binary,self.name,self.originFolder,file,"obj")
|
||||||
tmpList = target.GenerateFile(self.name,self.originFolder,file,"obj")
|
# check the dependency for this file :
|
||||||
# TODO : Check depedency ...
|
if False==dependency.NeedReBuild(tmpList[1], tmpList[0], tmpList[2]):
|
||||||
if os.path.exists(tmpList[1]):
|
return tmpList[1]
|
||||||
if os.path.getmtime(tmpList[1]) > os.path.getmtime(tmpList[0]):
|
|
||||||
return tmpList[1]
|
|
||||||
buildTools.CreateDirectoryOfFile(tmpList[1])
|
buildTools.CreateDirectoryOfFile(tmpList[1])
|
||||||
debug.printElement("c", self.name, "<==", file)
|
debug.printElement("c", self.name, "<==", file)
|
||||||
cmdLine=buildTools.ListToStr([
|
cmdLine=buildTools.ListToStr([
|
||||||
@ -199,10 +199,12 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for running ar.
|
## Commands for running ar.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
def Link_to_a(self, file, binary, target, depancy):
|
||||||
def Link_to_a(self, file, target, depancy):
|
tmpList = target.GenerateFile(binary, self.name,self.originFolder,file,"lib-static")
|
||||||
tmpList = target.GenerateFile(self.name,self.originFolder,file,"lib-static")
|
# check the dependency for this file :
|
||||||
# TODO : Check depedency ...
|
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])
|
buildTools.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 ...
|
||||||
@ -228,10 +230,12 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for running gcc to link a shared library.
|
## Commands for running gcc to link a shared library.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
def Link_to_so(self, file, binary, target, depancy):
|
||||||
def Link_to_so(self, file, target, depancy):
|
tmpList = target.GenerateFile(binary, self.name,self.originFolder,file,"lib-shared")
|
||||||
tmpList = target.GenerateFile(self.name,self.originFolder,file,"lib-shared")
|
# check the dependency for this file :
|
||||||
# TODO : Check depedency ...
|
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])
|
buildTools.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])
|
||||||
@ -258,9 +262,12 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for running gcc to link an executable.
|
## Commands for running gcc to link an executable.
|
||||||
###############################################################################
|
###############################################################################
|
||||||
def Link_to_bin(self, file, target, depancy):
|
def Link_to_bin(self, file, binary, target, depancy):
|
||||||
tmpList = target.GenerateFile(self.name,self.originFolder,file,"bin")
|
tmpList = target.GenerateFile(binary, self.name,self.originFolder,file,"bin")
|
||||||
# TODO : Check depedency ...
|
# check the dependency for this file :
|
||||||
|
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])
|
buildTools.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)
|
||||||
@ -296,8 +303,8 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for copying files
|
## Commands for copying files
|
||||||
###############################################################################
|
###############################################################################
|
||||||
def files_to_staging(self, target, binaryName):
|
def files_to_staging(self, binaryName, target):
|
||||||
baseFolder = target.GetStagingFolder(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])
|
buildTools.CopyFile(self.originFolder+"/"+element[0], baseFolder+"/"+element[1])
|
||||||
@ -305,22 +312,31 @@ class module:
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
## Commands for copying files
|
## Commands for copying files
|
||||||
###############################################################################
|
###############################################################################
|
||||||
def folders_to_staging(self, target, binaryName):
|
def folders_to_staging(self, binaryName, target):
|
||||||
baseFolder = target.GetStagingFolder(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])
|
buildTools.CopyAnything(self.originFolder+"/"+element[0], baseFolder+"/"+element[1])
|
||||||
|
|
||||||
# call here to build the module
|
# call here to build the module
|
||||||
def Build(self, target):
|
def Build(self, binaryName, target):
|
||||||
# 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 \
|
||||||
|
and self.type=='BINARY':
|
||||||
|
# this is the endpoint binary ...
|
||||||
|
binaryName = self.name
|
||||||
|
else :
|
||||||
|
# TODO : Set it better ...
|
||||||
|
None
|
||||||
|
|
||||||
# build dependency befor
|
# build dependency befor
|
||||||
listSubFileNeededToBuild = []
|
listSubFileNeededToBuild = []
|
||||||
subHeritage = heritage.heritage(None)
|
subHeritage = heritage.heritage(None)
|
||||||
for dep in self.depends:
|
for dep in self.depends:
|
||||||
inherit = Build(dep, target)
|
inherit = Build(dep, binaryName, target)
|
||||||
# add at the heritage list :
|
# add at the heritage list :
|
||||||
subHeritage.AddSub(inherit)
|
subHeritage.AddSub(inherit)
|
||||||
|
|
||||||
@ -329,21 +345,26 @@ 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, target, subHeritage)
|
resFile = self.Compile_cc_to_o(file, binaryName, 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, target, subHeritage)
|
resFile = self.Compile_xx_to_o(file, binaryName, target, subHeritage)
|
||||||
listSubFileNeededToBuild.append(resFile)
|
listSubFileNeededToBuild.append(resFile)
|
||||||
else:
|
else:
|
||||||
debug.verbose(" TODO : gcc " + self.originFolder + "/" + file)
|
debug.verbose(" TODO : gcc " + self.originFolder + "/" + file)
|
||||||
# generate end point:
|
# generate end point:
|
||||||
if self.type=='LIBRARY':
|
if self.type=='PREBUILD':
|
||||||
resFile = self.Link_to_a(listSubFileNeededToBuild, target, subHeritage)
|
# nothing to add ==> just dependence
|
||||||
|
None
|
||||||
|
elif self.type=='LIBRARY':
|
||||||
|
resFile = self.Link_to_a(listSubFileNeededToBuild, binaryName, target, subHeritage)
|
||||||
self.localHeritage.AddSources(resFile)
|
self.localHeritage.AddSources(resFile)
|
||||||
else:
|
elif self.type=='BINARY':
|
||||||
resFile = self.Link_to_bin(listSubFileNeededToBuild, target, subHeritage)
|
resFile = self.Link_to_bin(listSubFileNeededToBuild, binaryName, 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:
|
||||||
|
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
||||||
|
|
||||||
self.localHeritage.AddSub(subHeritage)
|
self.localHeritage.AddSub(subHeritage)
|
||||||
# return local dependency ...
|
# return local dependency ...
|
||||||
@ -358,19 +379,30 @@ class module:
|
|||||||
for dep in self.depends:
|
for dep in self.depends:
|
||||||
inherit = BuildTree(dep, target, binaryName)
|
inherit = BuildTree(dep, target, binaryName)
|
||||||
# add all the elements
|
# add all the elements
|
||||||
self.files_to_staging(target, binaryName)
|
self.files_to_staging(binaryName, target)
|
||||||
self.folders_to_staging(target, binaryName)
|
self.folders_to_staging(binaryName, target)
|
||||||
|
|
||||||
|
|
||||||
# call here to Clean the module
|
# call here to Clean the module
|
||||||
def Clean(self, target):
|
def Clean(self, target):
|
||||||
for file in self.src:
|
if self.type=='PREBUILD':
|
||||||
debug.error("TODO " + self.name + " <- (X) " + file);
|
# nothing to add ==> just dependence
|
||||||
|
None
|
||||||
def CleanTree(self, target, binaryName):
|
elif self.type=='LIBRARY':
|
||||||
for file in self.src:
|
# remove folder of the lib ... for this targer
|
||||||
debug.error("TODO " + self.name + " <- (X) " + file);
|
folderBuild = target.GetBuildFolder(self.name)
|
||||||
|
debug.info("remove folder : '" + folderBuild + "'")
|
||||||
|
buildTools.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)
|
||||||
|
folderStaging = target.GetStagingFolder(self.name)
|
||||||
|
debug.info("remove folder : '" + folderStaging + "'")
|
||||||
|
buildTools.RemoveFolderAndSubFolder(folderStaging)
|
||||||
|
else:
|
||||||
|
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
||||||
|
|
||||||
def AppendToInternalList(self, listout, list):
|
def AppendToInternalList(self, listout, list):
|
||||||
if type(list) == type(str()):
|
if type(list) == type(str()):
|
||||||
@ -494,10 +526,10 @@ def Dump():
|
|||||||
|
|
||||||
|
|
||||||
# return inherit packages ...
|
# return inherit packages ...
|
||||||
def Build(name,target):
|
def Build(name, binName, target):
|
||||||
for module in moduleList:
|
for module in moduleList:
|
||||||
if module.name == name:
|
if module.name == name:
|
||||||
return module.Build(target)
|
return module.Build(binName, target)
|
||||||
debug.error("request to build an un-existant module name : '" + name + "'")
|
debug.error("request to build an un-existant module name : '" + name + "'")
|
||||||
|
|
||||||
def BuildTree(name,target,binName):
|
def BuildTree(name,target,binName):
|
||||||
@ -512,6 +544,7 @@ def Clean(name,target):
|
|||||||
for module in moduleList:
|
for module in moduleList:
|
||||||
if module.name == name:
|
if module.name == name:
|
||||||
module.Clean(target)
|
module.Clean(target)
|
||||||
|
return
|
||||||
debug.error("request to clean an un-existant module name : '" + name + "'")
|
debug.error("request to clean an un-existant module name : '" + name + "'")
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ class Target:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name='Linux'
|
self.name='Linux'
|
||||||
debug.info("create board target : "+self.name);
|
debug.info("create board target : "+self.name);
|
||||||
if 1==environement.GetClangMode():
|
if "clang"==environement.GetClangMode():
|
||||||
self.cc='clang'
|
self.cc='clang'
|
||||||
self.xx='clang++'
|
self.xx='clang++'
|
||||||
else:
|
else:
|
||||||
@ -34,7 +34,7 @@ class Target:
|
|||||||
self.global_libs_ld=''
|
self.global_libs_ld=''
|
||||||
self.global_libs_ld_shared=''
|
self.global_libs_ld_shared=''
|
||||||
|
|
||||||
self.suffix_dependence='.o'
|
self.suffix_dependence='.d'
|
||||||
self.suffix_obj='.o'
|
self.suffix_obj='.o'
|
||||||
self.suffix_lib_static='.a'
|
self.suffix_lib_static='.a'
|
||||||
self.suffix_lib_dynamic='.so'
|
self.suffix_lib_dynamic='.so'
|
||||||
@ -64,30 +64,36 @@ class Target:
|
|||||||
1 : destination file
|
1 : destination file
|
||||||
2 : dependence files module (*.d)
|
2 : dependence files module (*.d)
|
||||||
"""
|
"""
|
||||||
def GenerateFile(self,moduleName,basePath,file,type):
|
def GenerateFile(self,binaryName,moduleName,basePath,file,type):
|
||||||
list=[]
|
list=[]
|
||||||
if (type=="bin"):
|
if (type=="bin"):
|
||||||
list.append(file)
|
list.append(file)
|
||||||
list.append(buildTools.GetRunFolder() + self.folder_out + self.folder_staging + self.folder_bin + "/" + moduleName + self.suffix_binary)
|
list.append(self.GetStagingFolder(binaryName) + self.folder_bin + "/" + moduleName + self.suffix_binary)
|
||||||
list.append(buildTools.GetRunFolder() + self.folder_out + self.folder_build + "/" + moduleName + "/" + moduleName + self.suffix_dependence)
|
list.append(self.GetBuildFolder(moduleName) + moduleName + self.suffix_dependence)
|
||||||
elif (type=="obj"):
|
elif (type=="obj"):
|
||||||
list.append(basePath + "/" + file)
|
list.append(basePath + "/" + file)
|
||||||
list.append(buildTools.GetRunFolder() + self.folder_out + self.folder_build + "/" + moduleName + "/" + file + self.suffix_obj)
|
list.append(self.GetBuildFolder(moduleName) + file + self.suffix_obj)
|
||||||
list.append(buildTools.GetRunFolder() + self.folder_out + self.folder_build + "/" + moduleName + "/" + file + self.suffix_dependence)
|
list.append(self.GetBuildFolder(moduleName) + file + self.suffix_dependence)
|
||||||
elif (type=="lib-shared"):
|
elif (type=="lib-shared"):
|
||||||
list.append(file)
|
list.append(file)
|
||||||
list.append(buildTools.GetRunFolder() + self.folder_out + self.folder_staging + self.folder_lib + "/" + moduleName + self.suffix_lib_dynamic)
|
list.append(self.GetStagingFolder(binaryName) + self.folder_lib + "/" + moduleName + self.suffix_lib_dynamic)
|
||||||
list.append(buildTools.GetRunFolder() + self.folder_out + self.folder_build + "/" + moduleName + "/" + moduleName + self.suffix_dependence)
|
list.append(self.GetBuildFolder(moduleName) + moduleName + self.suffix_dependence)
|
||||||
elif (type=="lib-static"):
|
elif (type=="lib-static"):
|
||||||
list.append(file)
|
list.append(file)
|
||||||
list.append(buildTools.GetRunFolder() + self.folder_out + self.folder_build + "/" + moduleName + "/" + moduleName + self.suffix_lib_static)
|
list.append(self.GetBuildFolder(moduleName) + moduleName + self.suffix_lib_static)
|
||||||
list.append(buildTools.GetRunFolder() + self.folder_out + self.folder_build + "/" + moduleName + "/" + moduleName + self.suffix_dependence)
|
list.append(self.GetBuildFolder(moduleName) + moduleName + self.suffix_dependence)
|
||||||
else:
|
else:
|
||||||
debug.error("unknow type : " + type)
|
debug.error("unknow type : " + type)
|
||||||
return list
|
return list
|
||||||
|
|
||||||
def GetStagingFolder(self, moduleName):
|
def GetStagingFolder(self, binaryName):
|
||||||
return buildTools.GetRunFolder() + self.folder_out + self.folder_staging + self.folder_data + "/" + moduleName
|
return buildTools.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 + "/"
|
||||||
|
|
||||||
def IsModuleBuild(self,module):
|
def IsModuleBuild(self,module):
|
||||||
for mod in self.buildDone:
|
for mod in self.buildDone:
|
||||||
|
158
make.py
158
make.py
@ -4,20 +4,77 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import inspect
|
import inspect
|
||||||
import fnmatch
|
import fnmatch
|
||||||
sys.path.append(os.path.dirname(__file__) + "/corePython/" )
|
if __name__ == "__main__":
|
||||||
|
sys.path.append(os.path.dirname(__file__) + "/corePython/" )
|
||||||
|
|
||||||
import debug
|
import debug
|
||||||
|
import environement
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Display the help of this makefile
|
||||||
|
"""
|
||||||
|
def usage():
|
||||||
|
print "usage:"
|
||||||
|
print " " + sys.argv[0] + " [options] [cible/properties] ..."
|
||||||
|
print " [help] display this help"
|
||||||
|
print " [option] : keep the last set"
|
||||||
|
print " [-h/--help] Display this help and break"
|
||||||
|
print " [-v?/--verbose=?] Display makefile debug level (verbose) default =2"
|
||||||
|
print " [-c/--color] Display makefile output in color"
|
||||||
|
print " [-f/--force] Force the rebuild without checking the dependency"
|
||||||
|
print " [properties] : keep in the sequency of the cible"
|
||||||
|
print " [-p=.../--platform=...] (Android/Linux/MacOs/Windows) Select a platform (by default the platform is the computer that compile this"
|
||||||
|
print " [-t/--tool] (clang/gcc) Compile with clang or Gcc mode (by default gcc will be used)"
|
||||||
|
print " [-m=.../--mode=...] (debug/release) Compile in release or debug mode (default release)"
|
||||||
|
print " [cible] : generate in order set"
|
||||||
|
print " [dump] Dump all the module dependency and properties"
|
||||||
|
print " [all] Build all (only for the current selected board) (bynary and packages)"
|
||||||
|
print " [clean] Clean all (same as previous)"
|
||||||
|
print " ... You can add 'module name' with at end : -clean to clean only this element"
|
||||||
|
print " ex: " + sys.argv[0] + " all board=Android all board=Windows all help"
|
||||||
|
exit(0)
|
||||||
|
|
||||||
countArgToPreventVerboseError = len(sys.argv)
|
|
||||||
# preparse the argument to get the erbose element for debug mode
|
# preparse the argument to get the erbose element for debug mode
|
||||||
for argument in sys.argv:
|
def parseGenericArg(argument,active):
|
||||||
if argument == "verbose":
|
if argument == "-h" or argument == "--help":
|
||||||
debug.SetLevel(5)
|
#display help
|
||||||
countArgToPreventVerboseError -= 1
|
usage()
|
||||||
elif argument == "color":
|
return True
|
||||||
debug.EnableColor()
|
elif argument[:2] == "-v":
|
||||||
countArgToPreventVerboseError -= 1
|
if active==True:
|
||||||
|
if len(argument)==2:
|
||||||
|
debug.SetLevel(5)
|
||||||
|
else:
|
||||||
|
debug.SetLevel(int(argument[2:]))
|
||||||
|
return True
|
||||||
|
elif argument[:9] == "--verbose":
|
||||||
|
if active==True:
|
||||||
|
if len(argument)==9:
|
||||||
|
debug.SetLevel(5)
|
||||||
|
else:
|
||||||
|
if argument[:10] == "--verbose=":
|
||||||
|
debug.SetLevel(int(argument[10:]))
|
||||||
|
else:
|
||||||
|
debug.SetLevel(int(argument[9:]))
|
||||||
|
return True
|
||||||
|
elif argument == "-c" or argument == "--color":
|
||||||
|
if active==True:
|
||||||
|
debug.EnableColor()
|
||||||
|
return True
|
||||||
|
elif argument == "-f" or argument == "--force":
|
||||||
|
if active==True:
|
||||||
|
environement.SetForceMode(True)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
# now import other standard module
|
# parse default unique argument:
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.path.append(os.path.dirname(__file__) + "/corePython/" )
|
||||||
|
for argument in sys.argv:
|
||||||
|
parseGenericArg(argument, True)
|
||||||
|
|
||||||
|
# now import other standard module (must be done here and not before ...
|
||||||
import module
|
import module
|
||||||
import host
|
import host
|
||||||
import buildTools
|
import buildTools
|
||||||
@ -25,55 +82,52 @@ import host
|
|||||||
import buildList
|
import buildList
|
||||||
|
|
||||||
|
|
||||||
"""
|
|
||||||
Display the help of this makefile
|
|
||||||
"""
|
|
||||||
def HelpDisplay():
|
|
||||||
print "usage:"
|
|
||||||
print " " + sys.argv[0] + " [help] [dump] [all] [clean] [board=...] [clang/gcc] [debug/release] [check] [verbose] [color]"
|
|
||||||
print " [help] display this help"
|
|
||||||
print " [dump] dump all the module dependency"
|
|
||||||
print " [all] build all (only for the current selected board)"
|
|
||||||
print " [clean] clean all (same as previous)"
|
|
||||||
print " [board=...] select a board (by default the board is the computer that compile this"
|
|
||||||
print " [clang/gcc] Compile with clang or Gcc mode (by default gcc will be used)"
|
|
||||||
print " [debug/release] compile in release or debug mode (default release)"
|
|
||||||
print " [check] Check if all dependency are resolved"
|
|
||||||
print " [verbose] display makefile debug"
|
|
||||||
print " [color] display makefile output in color"
|
|
||||||
print " you can add 'module name' with at end : -clean to clean only this element"
|
|
||||||
print " ex: " + sys.argv[0] + " all board=Android all board=Windows all help"
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Run everything that is needed in the system
|
Run everything that is needed in the system
|
||||||
"""
|
"""
|
||||||
def Start():
|
def Start():
|
||||||
|
actionDone=False
|
||||||
# parse all argument
|
# parse all argument
|
||||||
if countArgToPreventVerboseError==1:
|
for argument in sys.argv[1:]:
|
||||||
#by default we build all binary for the current board
|
if True==parseGenericArg(argument, False):
|
||||||
buildList.Build("all")
|
None # nothing to do ...
|
||||||
else:
|
elif argument == "dump":
|
||||||
for argument in sys.argv[1:]:
|
module.Dump()
|
||||||
if argument == "help":
|
actionDone=True
|
||||||
#display help
|
elif argument[:11] == "--platform=" or argument[:3] == "-p=":
|
||||||
HelpDisplay()
|
tmpArg=""
|
||||||
elif argument == "all":
|
if argument[:3] == "-p=":
|
||||||
#build all the board
|
tmpArg=argument[3:]
|
||||||
buildList.Build("all")
|
|
||||||
elif argument == "dump":
|
|
||||||
module.Dump()
|
|
||||||
elif argument == "verbose":
|
|
||||||
# nothing to do ...
|
|
||||||
None
|
|
||||||
elif argument == "color":
|
|
||||||
# nothing to do ...
|
|
||||||
None
|
|
||||||
else:
|
else:
|
||||||
buildList.Build(argument)
|
tmpArg=argument[11:]
|
||||||
|
# TODO ...
|
||||||
|
elif argument[:7] == "--mode=" or argument[:3] == "-m=":
|
||||||
|
tmpArg=""
|
||||||
|
if argument[:3] == "-m=":
|
||||||
|
tmpArg=argument[3:]
|
||||||
|
else:
|
||||||
|
tmpArg=argument[11:]
|
||||||
|
if "debug"==tmpArg:
|
||||||
|
environement.SetDebugMode(1)
|
||||||
|
elif "release"==tmpArg:
|
||||||
|
environement.SetDebugMode(0)
|
||||||
|
else:
|
||||||
|
debug.error("not understand build mode : '" + val + "' can be [debug/release]")
|
||||||
|
environement.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)
|
||||||
|
else:
|
||||||
|
buildList.Build(argument)
|
||||||
|
actionDone=True
|
||||||
|
# if no action done : we do "all" ...
|
||||||
|
if actionDone==False:
|
||||||
|
buildList.Build("all")
|
||||||
|
|
||||||
"""
|
"""
|
||||||
When the user use with make.py we initialise ourself
|
When the user use with make.py we initialise ourself
|
||||||
|
Loading…
x
Reference in New Issue
Block a user