lutin/lutin.py

180 lines
6.2 KiB
Python
Raw Normal View History

2013-04-17 21:41:41 +02:00
#!/usr/bin/python
# for path inspection:
import sys
2013-04-17 21:41:41 +02:00
import os
import inspect
2013-04-17 21:41:41 +02:00
import fnmatch
import lutinDebug as debug
import lutinEnv
import lutinModule
import lutinMultiprocess
import lutinArg
mylutinArg = lutinArg.lutinArg()
mylutinArg.Add(lutinArg.argDefine("h", "help", desc="display this help"))
mylutinArg.AddSection("option", "Can be set one time in all case")
mylutinArg.Add(lutinArg.argDefine("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"]], desc="Display makefile debug level (verbose) default =2"))
mylutinArg.Add(lutinArg.argDefine("c", "color", desc="Display makefile output in color"))
mylutinArg.Add(lutinArg.argDefine("f", "force", desc="Force the rebuild without checking the dependency"))
mylutinArg.Add(lutinArg.argDefine("P", "pretty", desc="print the debug has pretty display"))
mylutinArg.Add(lutinArg.argDefine("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously"))
2013-08-27 21:11:03 +02:00
mylutinArg.Add(lutinArg.argDefine("s", "force-strip", desc="Force the stripping of the compile elements"))
mylutinArg.AddSection("properties", "keep in the sequency of the cible")
mylutinArg.Add(lutinArg.argDefine("t", "target", list=[["Android",""],["Linux",""],["MacOs",""],["Windows",""]], desc="Select a target (by default the platform is the computer that compile this"))
mylutinArg.Add(lutinArg.argDefine("C", "compilator", list=[["clang",""],["gcc",""]], desc="Compile with clang or Gcc mode (by default gcc will be used)"))
mylutinArg.Add(lutinArg.argDefine("m", "mode", list=[["debug",""],["release",""]], desc="Compile in release or debug mode (default release)"))
mylutinArg.Add(lutinArg.argDefine("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)"))
mylutinArg.AddSection("cible", "generate in order set")
localArgument = mylutinArg.Parse()
2013-04-17 21:41:41 +02:00
"""
Display the help of this makefile
2013-04-17 21:41:41 +02:00
"""
def usage():
# generic argument displayed :
mylutinArg.Display()
print " all"
print " Build all (only for the current selected board) (bynary and packages)"
print " clean"
print " Clean all (same as previous)"
print " dump"
print " Dump all the module dependency and properties"
listOfAllModule = lutinModule.ListAllModuleWithDesc()
for mod in listOfAllModule:
print " " + mod[0] + " / " + mod[0] + "-clean / " + mod[0] + "-dump"
print " " + mod[1]
2013-07-11 11:21:25 +02:00
print " ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all"
exit(0)
2013-04-17 21:41:41 +02:00
# preparse the argument to get the verbose element for debug mode
def parseGenericArg(argument,active):
if argument.GetOptionName() == "help":
#display help
if active==False:
usage()
return True
elif argument.GetOptionName()=="jobs":
if active==True:
lutinMultiprocess.SetCoreNumber(int(argument.GetArg()))
return True
elif argument.GetOptionName() == "verbose":
if active==True:
debug.SetLevel(int(argument.GetArg()))
return True
elif argument.GetOptionName() == "color":
if active==True:
debug.EnableColor()
return True
elif argument.GetOptionName() == "force":
if active==True:
lutinEnv.SetForceMode(True)
return True
elif argument.GetOptionName() == "pretty":
if active==True:
lutinEnv.SetPrintPrettyMode(True)
return True
2013-08-27 21:11:03 +02:00
elif argument.GetOptionName() == "force-strip":
if active==True:
lutinEnv.SetForceStripMode(True)
return True
return False
# parse default unique argument:
if __name__ == "__main__":
for argument in localArgument:
parseGenericArg(argument, True)
# now import other standard module (must be done here and not before ...
import lutinTarget
import lutinHost
import lutinTools
2013-04-17 21:41:41 +02:00
"""
Run everything that is needed in the system
2013-04-17 21:41:41 +02:00
"""
def Start():
#available target : Linux / MacOs / Windows / Android ...
targetName=lutinHost.OS
#compilation base
compilator="gcc"
# build mode
mode="release"
# package generationMode
generatePackage=True
# load the default target :
target = None
actionDone=False
# parse all argument
for argument in localArgument:
if True==parseGenericArg(argument, False):
None # nothing to do ...
elif argument.GetOptionName() == "package":
generatePackage=False
elif argument.GetOptionName() == "compilator":
if compilator!=argument.GetArg():
debug.debug("change compilator ==> " + argument.GetArg())
compilator=argument.GetArg()
#remove previous target
target = None
elif argument.GetOptionName() == "target":
# No check input ==> this will be verify automaticly chen the target will be loaded
if targetName!=argument.GetArg():
targetName=argument.GetArg()
debug.debug("change target ==> " + targetName + " & reset mode : gcc&release")
#reset properties by defauult:
compilator="gcc"
mode="release"
generatePackage=True
#remove previous target
target = None
elif argument.GetOptionName() == "mode":
if mode!=argument.GetArg():
mode = argument.GetArg()
debug.debug("change mode ==> " + mode)
#remove previous target
target = None
else:
2013-05-24 22:02:09 +02:00
if argument.GetOptionName() != "":
debug.warning("Can not understand argument : '" + argument.GetOptionName() + "'")
usage()
else:
#load the target if needed :
if target == None:
target = lutinTarget.TargetLoad(targetName, compilator, mode, generatePackage)
target.Build(argument.GetArg())
actionDone=True
# if no action done : we do "all" ...
if actionDone==False:
#load the target if needed :
if target == None:
target = lutinTarget.TargetLoad(targetName, compilator, mode, generatePackage)
target.Build("all")
# stop all started threads
lutinMultiprocess.UnInit()
2013-04-17 21:41:41 +02:00
"""
When the user use with make.py we initialise ourself
2013-04-17 21:41:41 +02:00
"""
if __name__ == '__main__':
debug.verbose("Use Make as a make stadard")
sys.path.append(lutinTools.GetRunFolder())
debug.verbose(" try to impoert module 'lutinBase.py'")
if os.path.exists("lutinBase.py" )==True:
__import__("lutinBase")
else:
debug.debug("missing file lutinBase.py ==> loading subPath...");
# Import all sub path without out and archive
for folder in os.listdir("."):
if os.path.isdir(folder)==True:
if folder.lower()!="android" \
and folder.lower()!="archive" \
and folder.lower()!="out" :
debug.debug("Automatic load path: '" + folder + "'")
lutinModule.ImportPath(folder)
Start()
2013-04-17 21:41:41 +02:00