2013-04-17 21:41:41 +02:00
#!/usr/bin/python
# for path inspection:
2013-04-18 01:46:47 +02:00
import sys
2013-04-17 21:41:41 +02:00
import os
2013-04-18 01:46:47 +02:00
import inspect
2013-04-17 21:41:41 +02:00
import fnmatch
2013-04-21 22:17:47 +02:00
import lutinDebug as debug
import lutinEnv
2013-04-22 21:37:13 +02:00
import lutinModule
2013-04-24 21:30:46 +02:00
import lutinMultiprocess
2013-05-24 21:25:03 +02:00
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 " ) )
2013-07-09 15:00:07 +02:00
mylutinArg . Add ( lutinArg . argDefine ( " P " , " pretty " , desc = " print the debug has pretty display " ) )
2013-05-24 21:25:03 +02:00
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 " ) )
2013-05-24 21:25:03 +02:00
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
"""
2013-04-18 01:46:47 +02:00
Display the help of this makefile
2013-04-17 21:41:41 +02:00
"""
2013-04-19 22:06:05 +02:00
def usage ( ) :
2013-05-24 21:25:03 +02:00
# generic argument displayed :
mylutinArg . Display ( )
2013-04-22 21:37:13 +02:00
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 "
2013-04-18 01:46:47 +02:00
exit ( 0 )
2013-04-17 21:41:41 +02:00
2013-07-09 15:00:07 +02:00
# preparse the argument to get the verbose element for debug mode
2013-04-19 22:06:05 +02:00
def parseGenericArg ( argument , active ) :
2013-05-24 21:25:03 +02:00
if argument . GetOptionName ( ) == " help " :
2013-04-19 22:06:05 +02:00
#display help
2013-04-22 21:37:13 +02:00
if active == False :
usage ( )
2013-04-19 22:06:05 +02:00
return True
2013-05-24 21:25:03 +02:00
elif argument . GetOptionName ( ) == " jobs " :
2013-04-19 22:06:05 +02:00
if active == True :
2013-05-24 21:25:03 +02:00
lutinMultiprocess . SetCoreNumber ( int ( argument . GetArg ( ) ) )
2013-04-19 22:06:05 +02:00
return True
2013-05-24 21:25:03 +02:00
elif argument . GetOptionName ( ) == " verbose " :
2013-04-19 22:06:05 +02:00
if active == True :
2013-05-24 21:25:03 +02:00
debug . SetLevel ( int ( argument . GetArg ( ) ) )
2013-04-19 22:06:05 +02:00
return True
2013-05-24 21:25:03 +02:00
elif argument . GetOptionName ( ) == " color " :
2013-04-19 22:06:05 +02:00
if active == True :
debug . EnableColor ( )
return True
2013-05-24 21:25:03 +02:00
elif argument . GetOptionName ( ) == " force " :
2013-04-19 22:06:05 +02:00
if active == True :
2013-04-21 22:17:47 +02:00
lutinEnv . SetForceMode ( True )
2013-04-19 22:06:05 +02:00
return True
2013-07-09 15:00:07 +02:00
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
2013-04-19 22:06:05 +02:00
return False
# parse default unique argument:
if __name__ == " __main__ " :
2013-05-24 21:25:03 +02:00
for argument in localArgument :
2013-04-19 22:06:05 +02:00
parseGenericArg ( argument , True )
# now import other standard module (must be done here and not before ...
2013-04-22 21:37:13 +02:00
import lutinTarget
import lutinHost
2013-04-21 22:17:47 +02:00
import lutinTools
2013-04-18 22:09:45 +02:00
2013-04-17 21:41:41 +02:00
"""
2013-04-18 01:46:47 +02:00
Run everything that is needed in the system
2013-04-17 21:41:41 +02:00
"""
2013-04-18 01:46:47 +02:00
def Start ( ) :
2013-04-22 21:37:13 +02:00
#available target : Linux / MacOs / Windows / Android ...
targetName = lutinHost . OS
#compilation base
compilator = " gcc "
# build mode
mode = " release "
2013-05-08 12:17:45 +02:00
# package generationMode
generatePackage = True
2013-04-22 21:37:13 +02:00
# load the default target :
target = None
2013-04-19 22:06:05 +02:00
actionDone = False
2013-04-18 01:46:47 +02:00
# parse all argument
2013-05-24 21:25:03 +02:00
for argument in localArgument :
2013-04-19 22:06:05 +02:00
if True == parseGenericArg ( argument , False ) :
None # nothing to do ...
2013-05-24 21:25:03 +02:00
elif argument . GetOptionName ( ) == " package " :
2013-05-08 12:17:45 +02:00
generatePackage = False
2013-05-24 21:25:03 +02:00
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 " :
2013-04-22 21:37:13 +02:00
# No check input ==> this will be verify automaticly chen the target will be loaded
2013-05-24 21:25:03 +02:00
if targetName != argument . GetArg ( ) :
targetName = argument . GetArg ( )
debug . debug ( " change target ==> " + targetName + " & reset mode : gcc&release " )
2013-04-22 21:37:13 +02:00
#reset properties by defauult:
compilator = " gcc "
mode = " release "
2013-05-08 12:17:45 +02:00
generatePackage = True
2013-04-22 21:37:13 +02:00
#remove previous target
target = None
2013-05-24 21:25:03 +02:00
elif argument . GetOptionName ( ) == " mode " :
if mode != argument . GetArg ( ) :
mode = argument . GetArg ( )
debug . debug ( " change mode ==> " + mode )
#remove previous target
target = None
2013-04-19 22:06:05 +02:00
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
2013-04-19 22:06:05 +02:00
# if no action done : we do "all" ...
if actionDone == False :
2013-04-22 21:37:13 +02:00
#load the target if needed :
if target == None :
2013-05-08 12:17:45 +02:00
target = lutinTarget . TargetLoad ( targetName , compilator , mode , generatePackage )
2013-04-21 22:17:47 +02:00
target . Build ( " all " )
2013-04-24 21:30:46 +02:00
# stop all started threads
lutinMultiprocess . UnInit ( )
2013-04-17 21:41:41 +02:00
"""
2013-04-18 01:46:47 +02:00
When the user use with make . py we initialise ourself
2013-04-17 21:41:41 +02:00
"""
2013-04-18 01:46:47 +02:00
if __name__ == ' __main__ ' :
debug . verbose ( " Use Make as a make stadard " )
2013-04-21 22:17:47 +02:00
sys . path . append ( lutinTools . GetRunFolder ( ) )
debug . verbose ( " try to impoert module ' lutinBase.py ' " )
2013-09-02 21:23:38 +02:00
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 )
2013-04-18 01:46:47 +02:00
Start ( )
2013-04-17 21:41:41 +02:00