Compare commits
46 Commits
Author | SHA1 | Date | |
---|---|---|---|
78322882ff | |||
5546a1726a | |||
575f90ebbe | |||
d8d2be822b | |||
a509b08611 | |||
ee6c01f278 | |||
801e2e8209 | |||
78336f359e | |||
63e46b8487 | |||
2ccb26acdd | |||
94212dd2f7 | |||
6d0894a134 | |||
8a654def1b | |||
a40a25dba5 | |||
50103d4c74 | |||
e531092bea | |||
0ba120d0d9 | |||
35d514e9a9 | |||
b0d300e3ff | |||
4b3072ddf2 | |||
ffeb404d52 | |||
185d3c290c | |||
e3a2e19fe6 | |||
91b0cecc28 | |||
95b2206da6 | |||
512651e746 | |||
03e67ae8d6 | |||
fc77789f93 | |||
220364c116 | |||
1ec26df856 | |||
134e0b523e | |||
2a58657df5 | |||
288207e4e1 | |||
dd03e46832 | |||
7c72aa8b84 | |||
0f4349e65a | |||
d0fb9045c4 | |||
0042e68581 | |||
0cb58135fd | |||
33dc55d84b | |||
67297b3063 | |||
e46e6add5e | |||
b1cbee3b4b | |||
02a72568c9 | |||
dd46d2d7b4 | |||
92c552fd59 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1 +1,9 @@
|
|||||||
|
# Compiled python modules.
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|
||||||
|
# Setuptools distribution folder.
|
||||||
|
/dist/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
# Python egg metadata, regenerated from source files by setuptools.
|
||||||
|
/*.egg-info
|
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
include README.rst
|
@@ -1,29 +1,47 @@
|
|||||||
build
|
Lutin
|
||||||
=====
|
=====
|
||||||
|
|
||||||
`lutin` is a generic package maker is a FREE software tool.
|
`lutin` is a generic builder and package maker is a FREE software tool.
|
||||||
|
|
||||||
Instructions
|
Instructions
|
||||||
============
|
------------
|
||||||
|
|
||||||
This is a tool to generate the binary, shared library, static library and package independently of the OS
|
This is a tool to generate the binary, shared library, static library and package independently of the OS
|
||||||
|
|
||||||
|
This software builds C, C++, m, m++, to object file and generate associated libraries (.so & .a) end create final Executable file
|
||||||
|
|
||||||
This tool can generate package for Linux, MacOs, Android
|
This tool can generate package for Linux, MacOs, Android
|
||||||
|
|
||||||
|
|
||||||
Create a lutin module
|
Lutin is under a FREE license that can be found in the COPYING file.
|
||||||
=====================
|
Any contribution is more than welcome ;)
|
||||||
|
|
||||||
Set the lutin module maker with the name :
|
git repository
|
||||||
lutin_xxxxx.py
|
--------------
|
||||||
xxx : represent the name of the module/binary/package and must be lower case and no special characters
|
|
||||||
|
http://github.com/HeeroYui/lutin/
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
http://github.io/HeeroYui/lutin/
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
Requirements: ``Python >= 2.7`` and ``pip``
|
||||||
|
|
||||||
|
Just run::
|
||||||
|
|
||||||
|
pip install lutin
|
||||||
|
|
||||||
|
On mac-os you may install pip before:
|
||||||
|
|
||||||
|
sudo easy_install pip
|
||||||
|
|
||||||
you can see exemple for some type in :
|
|
||||||
ewol : library
|
|
||||||
edn : package
|
|
||||||
glew : prebuild
|
|
||||||
|
|
||||||
License (APACHE v2.0)
|
License (APACHE v2.0)
|
||||||
=====================
|
---------------------
|
||||||
|
|
||||||
Copyright lutin Edouard DUPIN
|
Copyright lutin Edouard DUPIN
|
||||||
|
|
210
bin/lutin
Executable file
210
bin/lutin
Executable file
@@ -0,0 +1,210 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
# for path inspection:
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import lutin.debug as debug
|
||||||
|
import lutin.arg as arguments
|
||||||
|
import lutin.host as host
|
||||||
|
import lutin.module as module
|
||||||
|
import lutin.target as target
|
||||||
|
import lutin.multiprocess as multiprocess
|
||||||
|
|
||||||
|
myArgs = arguments.LutinArg()
|
||||||
|
myArgs.add(arguments.ArgDefine("h", "help", desc="display this help"))
|
||||||
|
myArgs.add_section("option", "Can be set one time in all case")
|
||||||
|
myArgs.add(arguments.ArgDefine("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"],["6","extreme_verbose"]], desc="display makefile debug level (verbose) default =2"))
|
||||||
|
myArgs.add(arguments.ArgDefine("C", "color", desc="display makefile output in color"))
|
||||||
|
myArgs.add(arguments.ArgDefine("f", "force", desc="Force the rebuild without checking the dependency"))
|
||||||
|
myArgs.add(arguments.ArgDefine("P", "pretty", desc="print the debug has pretty display"))
|
||||||
|
myArgs.add(arguments.ArgDefine("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously"))
|
||||||
|
myArgs.add(arguments.ArgDefine("s", "force-strip", desc="Force the stripping of the compile elements"))
|
||||||
|
|
||||||
|
myArgs.add_section("properties", "keep in the sequency of the cible")
|
||||||
|
myArgs.add(arguments.ArgDefine("t", "target", haveParam=True, desc="Select a target (by default the platform is the computer that compile this) To know list : 'lutin.py --list-target'"))
|
||||||
|
myArgs.add(arguments.ArgDefine("c", "compilator", list=[["clang",""],["gcc",""]], desc="Compile with clang or Gcc mode (by default gcc will be used)"))
|
||||||
|
myArgs.add(arguments.ArgDefine("m", "mode", list=[["debug",""],["release",""]], desc="Compile in release or debug mode (default release)"))
|
||||||
|
myArgs.add(arguments.ArgDefine("a", "arch", list=[["auto","Automatic choice"],["arm","Arm processer"],["x86","Generic PC : AMD/Intel"],["ppc","Power PC"]], desc="Architecture to compile"))
|
||||||
|
myArgs.add(arguments.ArgDefine("b", "bus", list=[["auto","Automatic choice"],["32","32 bits"],["64","64 bits"]], desc="Adressing size (Bus size)"))
|
||||||
|
myArgs.add(arguments.ArgDefine("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)"))
|
||||||
|
myArgs.add(arguments.ArgDefine("g", "gcov", desc="Enable code coverage intrusion in code"))
|
||||||
|
myArgs.add(arguments.ArgDefine("", "simulation", desc="simulater mode (availlable only for IOS)"))
|
||||||
|
myArgs.add(arguments.ArgDefine("", "list-target", desc="list all availlables targets ==> for auto completion"))
|
||||||
|
myArgs.add(arguments.ArgDefine("", "list-module", desc="list all availlables module ==> for auto completion"))
|
||||||
|
|
||||||
|
myArgs.add_section("cible", "generate in order set")
|
||||||
|
localArgument = myArgs.parse()
|
||||||
|
|
||||||
|
"""
|
||||||
|
display the help of this makefile
|
||||||
|
"""
|
||||||
|
def usage():
|
||||||
|
# generic argument displayed :
|
||||||
|
myArgs.display()
|
||||||
|
print(" All target can finish with '?clean' '?dump' ... ?action")
|
||||||
|
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 = module.list_all_module_with_desc()
|
||||||
|
for mod in listOfAllModule:
|
||||||
|
print(" " + mod[0])
|
||||||
|
if mod[1] != "":
|
||||||
|
print(" " + mod[1])
|
||||||
|
print(" ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all")
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
# preparse the argument to get the verbose element for debug mode
|
||||||
|
def parseGenericArg(argument, active):
|
||||||
|
if argument.get_option_nName() == "help":
|
||||||
|
#display help
|
||||||
|
if active==False:
|
||||||
|
usage()
|
||||||
|
return True
|
||||||
|
if argument.get_option_nName() == "list-module":
|
||||||
|
if active==False:
|
||||||
|
listOfModule = module.list_all_module()
|
||||||
|
retValue = ""
|
||||||
|
for moduleName in listOfModule:
|
||||||
|
if retValue != "":
|
||||||
|
retValue += " "
|
||||||
|
retValue += moduleName
|
||||||
|
print(retValue)
|
||||||
|
exit(0)
|
||||||
|
return True
|
||||||
|
if argument.get_option_nName() == "list-target":
|
||||||
|
if active==False:
|
||||||
|
listOfTarget = target.list_all_target()
|
||||||
|
retValue = ""
|
||||||
|
for targetName in listOfTarget:
|
||||||
|
if retValue != "":
|
||||||
|
retValue += " "
|
||||||
|
retValue += targetName
|
||||||
|
print(retValue)
|
||||||
|
exit(0)
|
||||||
|
return True
|
||||||
|
elif argument.get_option_nName()=="jobs":
|
||||||
|
if active==True:
|
||||||
|
multiprocess.set_core_number(int(argument.get_arg()))
|
||||||
|
return True
|
||||||
|
elif argument.get_option_nName() == "verbose":
|
||||||
|
if active==True:
|
||||||
|
debug.set_level(int(argument.get_arg()))
|
||||||
|
return True
|
||||||
|
elif argument.get_option_nName() == "color":
|
||||||
|
if active==True:
|
||||||
|
debug.enable_color()
|
||||||
|
return True
|
||||||
|
elif argument.get_option_nName() == "force":
|
||||||
|
if active==True:
|
||||||
|
lutinEnv.set_force_mode(True)
|
||||||
|
return True
|
||||||
|
elif argument.get_option_nName() == "pretty":
|
||||||
|
if active==True:
|
||||||
|
lutinEnv.set_print_pretty_mode(True)
|
||||||
|
return True
|
||||||
|
elif argument.get_option_nName() == "force-strip":
|
||||||
|
if active==True:
|
||||||
|
lutinEnv.set_force_strip_mode(True)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
# parse default unique argument:
|
||||||
|
for argument in localArgument:
|
||||||
|
parseGenericArg(argument, True)
|
||||||
|
|
||||||
|
|
||||||
|
import lutin
|
||||||
|
|
||||||
|
|
||||||
|
import lutin.host as lutinHost
|
||||||
|
import lutin.tools as lutinTools
|
||||||
|
|
||||||
|
#available target : Linux / MacOs / Windows / Android ...
|
||||||
|
targetName = host.OS
|
||||||
|
config = {
|
||||||
|
"compilator":"gcc",
|
||||||
|
"mode":"release",
|
||||||
|
"bus-size":"auto",
|
||||||
|
"arch":"auto",
|
||||||
|
"generate-package":True,
|
||||||
|
"simulation":False,
|
||||||
|
"gcov":False
|
||||||
|
}
|
||||||
|
# load the default target :
|
||||||
|
my_target = None
|
||||||
|
actionDone=False
|
||||||
|
# parse all argument
|
||||||
|
for argument in localArgument:
|
||||||
|
if parseGenericArg(argument, False) == True:
|
||||||
|
continue
|
||||||
|
elif argument.get_option_nName() == "package":
|
||||||
|
config["generate-package"]=False
|
||||||
|
elif argument.get_option_nName() == "simulation":
|
||||||
|
config["simulation"]=True
|
||||||
|
elif argument.get_option_nName() == "gcov":
|
||||||
|
config["gcov"]=True
|
||||||
|
elif argument.get_option_nName() == "bus":
|
||||||
|
config["bus-size"]=argument.get_arg()
|
||||||
|
elif argument.get_option_nName() == "arch":
|
||||||
|
config["arch"]=argument.get_arg()
|
||||||
|
elif argument.get_option_nName() == "compilator":
|
||||||
|
if config["compilator"] != argument.get_arg():
|
||||||
|
debug.debug("change compilator ==> " + argument.get_arg())
|
||||||
|
config["compilator"] = argument.get_arg()
|
||||||
|
#remove previous target
|
||||||
|
my_target = None
|
||||||
|
elif argument.get_option_nName() == "target":
|
||||||
|
# No check input ==> this will be verify automaticly chen the target will be loaded
|
||||||
|
if targetName != argument.get_arg():
|
||||||
|
targetName = argument.get_arg()
|
||||||
|
debug.debug("change target ==> '" + targetName + "' & reset mode : gcc&release")
|
||||||
|
#reset properties by defauult:
|
||||||
|
config = {
|
||||||
|
"compilator":"gcc",
|
||||||
|
"mode":"release",
|
||||||
|
"bus-size":"auto",
|
||||||
|
"arch":"auto",
|
||||||
|
"generate-package":True,
|
||||||
|
"simulation":False,
|
||||||
|
"gcov":False
|
||||||
|
}
|
||||||
|
#remove previous target
|
||||||
|
my_target = None
|
||||||
|
elif argument.get_option_nName() == "mode":
|
||||||
|
if config["mode"] != argument.get_arg():
|
||||||
|
config["mode"] = argument.get_arg()
|
||||||
|
debug.debug("change mode ==> " + config["mode"])
|
||||||
|
#remove previous target
|
||||||
|
my_target = None
|
||||||
|
else:
|
||||||
|
if argument.get_option_nName() != "":
|
||||||
|
debug.warning("Can not understand argument : '" + argument.get_option_nName() + "'")
|
||||||
|
usage()
|
||||||
|
else:
|
||||||
|
#load the target if needed :
|
||||||
|
if my_target == None:
|
||||||
|
my_target = target.load_target(targetName, config)
|
||||||
|
my_target.build(argument.get_arg())
|
||||||
|
actionDone=True
|
||||||
|
|
||||||
|
# if no action done : we do "all" ...
|
||||||
|
if actionDone==False:
|
||||||
|
#load the target if needed :
|
||||||
|
if my_target == None:
|
||||||
|
my_target = target.load_target(targetName, config)
|
||||||
|
my_target.build("all")
|
||||||
|
|
||||||
|
# stop all started threads;
|
||||||
|
multiprocess.un_init()
|
||||||
|
|
||||||
|
|
214
lutin.py
214
lutin.py
@@ -1,214 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# for path inspection:
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import inspect
|
|
||||||
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.add_section("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"))
|
|
||||||
myLutinArg.add(lutinArg.ArgDefine("s", "force-strip", desc="Force the stripping of the compile elements"))
|
|
||||||
|
|
||||||
myLutinArg.add_section("properties", "keep in the sequency of the cible")
|
|
||||||
myLutinArg.add(lutinArg.ArgDefine("t", "target", list=[["Android",""],["Linux",""],["MacOs",""],["IOs",""],["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("r", "prj", desc="Use external project management (not build with lutin..."))
|
|
||||||
myLutinArg.add(lutinArg.ArgDefine("p", "package", desc="Disable the package generation (usefull when just compile for test on linux ...)"))
|
|
||||||
myLutinArg.add(lutinArg.ArgDefine("", "simulation", desc="simulater mode (availlable only for IOS)"))
|
|
||||||
myLutinArg.add(lutinArg.ArgDefine("", "list-target", desc="list all availlables targets ==> for auto completion"))
|
|
||||||
myLutinArg.add(lutinArg.ArgDefine("", "list-module", desc="list all availlables module ==> for auto completion"))
|
|
||||||
|
|
||||||
myLutinArg.add_section("cible", "generate in order set")
|
|
||||||
localArgument = myLutinArg.parse()
|
|
||||||
|
|
||||||
"""
|
|
||||||
display the help of this makefile
|
|
||||||
"""
|
|
||||||
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.list_all_module_with_desc()
|
|
||||||
for mod in listOfAllModule:
|
|
||||||
print " " + mod[0] + " / " + mod[0] + "-clean / " + mod[0] + "-dump"
|
|
||||||
if mod[1] != "":
|
|
||||||
print " " + mod[1]
|
|
||||||
print " ex: " + sys.argv[0] + " all --target=Android all -t Windows -m debug all"
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
# preparse the argument to get the verbose element for debug mode
|
|
||||||
def parseGenericArg(argument,active):
|
|
||||||
if argument.get_option_nName() == "help":
|
|
||||||
#display help
|
|
||||||
if active==False:
|
|
||||||
usage()
|
|
||||||
return True
|
|
||||||
if argument.get_option_nName() == "list-module":
|
|
||||||
if active==False:
|
|
||||||
listOfModule = lutinModule.list_all_module()
|
|
||||||
retValue = ""
|
|
||||||
for moduleName in listOfModule:
|
|
||||||
if retValue != "":
|
|
||||||
retValue += " "
|
|
||||||
retValue += moduleName
|
|
||||||
print retValue
|
|
||||||
exit(0)
|
|
||||||
return True
|
|
||||||
if argument.get_option_nName() == "list-target":
|
|
||||||
if active==False:
|
|
||||||
listOfTarget = lutinTarget.list_all_target()
|
|
||||||
retValue = ""
|
|
||||||
for targetName in listOfTarget:
|
|
||||||
if retValue != "":
|
|
||||||
retValue += " "
|
|
||||||
retValue += targetName
|
|
||||||
print retValue
|
|
||||||
exit(0)
|
|
||||||
return True
|
|
||||||
elif argument.get_option_nName()=="jobs":
|
|
||||||
if active==True:
|
|
||||||
lutinMultiprocess.set_core_number(int(argument.get_arg()))
|
|
||||||
return True
|
|
||||||
elif argument.get_option_nName() == "verbose":
|
|
||||||
if active==True:
|
|
||||||
debug.set_level(int(argument.get_arg()))
|
|
||||||
return True
|
|
||||||
elif argument.get_option_nName() == "color":
|
|
||||||
if active==True:
|
|
||||||
debug.enable_color()
|
|
||||||
return True
|
|
||||||
elif argument.get_option_nName() == "force":
|
|
||||||
if active==True:
|
|
||||||
lutinEnv.set_force_mode(True)
|
|
||||||
return True
|
|
||||||
elif argument.get_option_nName() == "pretty":
|
|
||||||
if active==True:
|
|
||||||
lutinEnv.set_print_pretty_mode(True)
|
|
||||||
return True
|
|
||||||
elif argument.get_option_nName() == "force-strip":
|
|
||||||
if active==True:
|
|
||||||
lutinEnv.set_force_strip_mode(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
|
|
||||||
|
|
||||||
"""
|
|
||||||
Run everything that is needed in the system
|
|
||||||
"""
|
|
||||||
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
|
|
||||||
simulationMode=False
|
|
||||||
actionDone=False
|
|
||||||
#build with extern tool
|
|
||||||
externBuild=False
|
|
||||||
# parse all argument
|
|
||||||
for argument in localArgument:
|
|
||||||
if True==parseGenericArg(argument, False):
|
|
||||||
continue
|
|
||||||
elif argument.get_option_nName() == "package":
|
|
||||||
generatePackage=False
|
|
||||||
elif argument.get_option_nName() == "simulation":
|
|
||||||
simulationMode=True
|
|
||||||
elif argument.get_option_nName() == "prj":
|
|
||||||
externBuild=True
|
|
||||||
elif argument.get_option_nName() == "compilator":
|
|
||||||
if compilator!=argument.get_arg():
|
|
||||||
debug.debug("change compilator ==> " + argument.get_arg())
|
|
||||||
compilator=argument.get_arg()
|
|
||||||
#remove previous target
|
|
||||||
target = None
|
|
||||||
elif argument.get_option_nName() == "target":
|
|
||||||
# No check input ==> this will be verify automaticly chen the target will be loaded
|
|
||||||
if targetName!=argument.get_arg():
|
|
||||||
targetName=argument.get_arg()
|
|
||||||
debug.debug("change target ==> " + targetName + " & reset mode : gcc&release")
|
|
||||||
#reset properties by defauult:
|
|
||||||
compilator="gcc"
|
|
||||||
mode="release"
|
|
||||||
generatePackage=True
|
|
||||||
simulationMode=False
|
|
||||||
#remove previous target
|
|
||||||
target = None
|
|
||||||
elif argument.get_option_nName() == "mode":
|
|
||||||
if mode!=argument.get_arg():
|
|
||||||
mode = argument.get_arg()
|
|
||||||
debug.debug("change mode ==> " + mode)
|
|
||||||
#remove previous target
|
|
||||||
target = None
|
|
||||||
else:
|
|
||||||
if argument.get_option_nName() != "":
|
|
||||||
debug.warning("Can not understand argument : '" + argument.get_option_nName() + "'")
|
|
||||||
usage()
|
|
||||||
else:
|
|
||||||
#load the target if needed :
|
|
||||||
if target == None:
|
|
||||||
target = lutinTarget.target_load(targetName, compilator, mode, generatePackage, externBuild, simulationMode)
|
|
||||||
target.build(argument.get_arg())
|
|
||||||
actionDone=True
|
|
||||||
# if no action done : we do "all" ...
|
|
||||||
if actionDone==False:
|
|
||||||
#load the target if needed :
|
|
||||||
if target == None:
|
|
||||||
target = lutinTarget.target_load(targetName, compilator, mode, generatePackage, externBuild, simulationMode)
|
|
||||||
target.build("all")
|
|
||||||
# stop all started threads
|
|
||||||
lutinMultiprocess.un_init()
|
|
||||||
|
|
||||||
"""
|
|
||||||
When the user use with make.py we initialise ourself
|
|
||||||
"""
|
|
||||||
if __name__ == '__main__':
|
|
||||||
debug.verbose("Use Make as a make stadard")
|
|
||||||
sys.path.append(lutinTools.get_run_folder())
|
|
||||||
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.import_path(folder)
|
|
||||||
Start()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
47
lutin/__init__.py
Executable file
47
lutin/__init__.py
Executable file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
# Local import
|
||||||
|
from . import target
|
||||||
|
from . import builder
|
||||||
|
from . import system
|
||||||
|
from . import host
|
||||||
|
from . import tools
|
||||||
|
from . import debug
|
||||||
|
from . import module
|
||||||
|
|
||||||
|
is_init = False
|
||||||
|
|
||||||
|
if is_init == False:
|
||||||
|
debug.verbose("Use Make as a make stadard")
|
||||||
|
sys.path.append(tools.get_run_folder())
|
||||||
|
builder.import_path(tools.get_current_path(__file__))
|
||||||
|
module.import_path(tools.get_current_path(__file__))
|
||||||
|
system.import_path(tools.get_current_path(__file__))
|
||||||
|
target.import_path(tools.get_current_path(__file__))
|
||||||
|
|
||||||
|
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 + "'")
|
||||||
|
builder.import_path(folder)
|
||||||
|
module.import_path(folder)
|
||||||
|
system.import_path(folder)
|
||||||
|
target.import_path(folder)
|
||||||
|
|
||||||
|
builder.init()
|
||||||
|
|
||||||
|
is_init = True
|
||||||
|
|
||||||
|
|
@@ -1,6 +1,14 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
import sys
|
import sys
|
||||||
import lutinDebug as debug
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
|
||||||
class ArgElement:
|
class ArgElement:
|
||||||
def __init__(self, option, value=""):
|
def __init__(self, option, value=""):
|
||||||
@@ -241,10 +249,10 @@ class LutinArg:
|
|||||||
|
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
print "usage:"
|
print("usage:")
|
||||||
listOfPropertiesArg = "";
|
listOfPropertiesArg = "";
|
||||||
for element in self.m_listProperties :
|
for element in self.m_listProperties :
|
||||||
listOfPropertiesArg += element.get_porperties()
|
listOfPropertiesArg += element.get_porperties()
|
||||||
print " " + sys.argv[0] + listOfPropertiesArg + " ..."
|
print(" " + sys.argv[0] + listOfPropertiesArg + " ...")
|
||||||
for element in self.m_listProperties :
|
for element in self.m_listProperties :
|
||||||
element.display()
|
element.display()
|
74
lutin/builder.py
Normal file
74
lutin/builder.py
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import inspect
|
||||||
|
import fnmatch
|
||||||
|
import datetime
|
||||||
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
from . import heritage
|
||||||
|
|
||||||
|
##
|
||||||
|
## constitution of dictionnary:
|
||||||
|
## - "type": "compiler", "linker"
|
||||||
|
## - "in": input type file
|
||||||
|
## - "out": extention of the files
|
||||||
|
## - "builder": pointer on the element
|
||||||
|
##
|
||||||
|
builder_list=[]
|
||||||
|
__start_builder_name="lutinBuilder_"
|
||||||
|
|
||||||
|
|
||||||
|
def import_path(path):
|
||||||
|
global builder_list
|
||||||
|
matches = []
|
||||||
|
debug.debug('BUILDER: Start find sub File : "%s"' %path)
|
||||||
|
for root, dirnames, filenames in os.walk(path):
|
||||||
|
tmpList = fnmatch.filter(filenames, __start_builder_name + "*.py")
|
||||||
|
# Import the module :
|
||||||
|
for filename in tmpList:
|
||||||
|
debug.debug('BUILDER: 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)) )
|
||||||
|
builder_name = filename.replace('.py', '')
|
||||||
|
the_builder = __import__(builder_name)
|
||||||
|
builder_list.append({"name":builder_name,
|
||||||
|
"element":the_builder
|
||||||
|
})
|
||||||
|
debug.debug('BUILDER: type=' + the_builder.get_type() + " in=" + str(the_builder.get_input_type()) + " out=" + str(the_builder.get_output_type()))
|
||||||
|
|
||||||
|
# we must have call all import before ...
|
||||||
|
def init():
|
||||||
|
global builder_list
|
||||||
|
debug.debug('BUILDER: Initialize all ...')
|
||||||
|
for element in builder_list:
|
||||||
|
if element["element"] != None:
|
||||||
|
element["element"].init()
|
||||||
|
|
||||||
|
def get_builder(input_type):
|
||||||
|
global builder_list
|
||||||
|
for element in builder_list:
|
||||||
|
if element["element"] != None:
|
||||||
|
if input_type in element["element"].get_input_type():
|
||||||
|
return element["element"]
|
||||||
|
# we can not find the builder ...
|
||||||
|
debug.error("Can not find builder for type : '" + str(input_type) + "'")
|
||||||
|
raise ValueError('type error :' + str(input_type))
|
||||||
|
|
||||||
|
|
||||||
|
def get_builder_with_output(input_type):
|
||||||
|
global builder_list
|
||||||
|
for element in builder_list:
|
||||||
|
if element["element"] != None:
|
||||||
|
if input_type in element["element"].get_output_type():
|
||||||
|
return element["element"]
|
||||||
|
# we can not find the builder ...
|
||||||
|
debug.error("Can not find builder for type : '" + str(input_type) + "'")
|
||||||
|
raise ValueError('type error :' + str(input_type))
|
108
lutin/builder/lutinBuilder_binary.py
Normal file
108
lutin/builder/lutinBuilder_binary.py
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
##
|
||||||
|
## Executable/binary builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import depend
|
||||||
|
from lutin import env
|
||||||
|
import os
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "linker"
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["o"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["", "exe", "bin"]
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for running gcc to link an executable.
|
||||||
|
##
|
||||||
|
def link(file, binary, target, depancy, name, basic_folder):
|
||||||
|
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, name, basic_folder, file, "bin")
|
||||||
|
#create comdLine :
|
||||||
|
cmd = [
|
||||||
|
target.xx
|
||||||
|
]
|
||||||
|
try:
|
||||||
|
cmd.append(target.arch)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.sysroot)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_sysroot)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(["-o", file_dst])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(file_src)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.src)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["link"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["link"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_ld)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cmdLine=tools.list_to_str(cmd)
|
||||||
|
# check the dependency for this file :
|
||||||
|
if depend.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) == False \
|
||||||
|
and depend.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine) == False:
|
||||||
|
return file_dst
|
||||||
|
tools.create_directory_of_file(file_dst)
|
||||||
|
debug.print_element("Executable", name, "==>", file_dst)
|
||||||
|
|
||||||
|
multiprocess.run_command(cmdLine)
|
||||||
|
if target.config["mode"] == "release"\
|
||||||
|
or env.get_force_strip_mode() == True:
|
||||||
|
# get the file size of the non strip file
|
||||||
|
originSize = tools.file_size(file_dst);
|
||||||
|
debug.print_element("Executable(strip)", name, "", "")
|
||||||
|
cmdLineStrip=tools.list_to_str([
|
||||||
|
target.strip,
|
||||||
|
file_dst])
|
||||||
|
multiprocess.run_command(cmdLineStrip)
|
||||||
|
# get the stip size of the binary
|
||||||
|
stripSize = tools.file_size(file_dst)
|
||||||
|
debug.debug("file reduce size : " + str(originSize/1024) + "ko ==> " + str(stripSize/1024) + "ko")
|
||||||
|
# write cmd line only after to prevent errors ...
|
||||||
|
multiprocess.store_command(cmdLine, file_cmd)
|
||||||
|
|
136
lutin/builder/lutinBuilder_c.py
Normal file
136
lutin/builder/lutinBuilder_c.py
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
##
|
||||||
|
## C builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import depend
|
||||||
|
|
||||||
|
# C version:
|
||||||
|
default_version = 1989
|
||||||
|
default_version_gnu = False
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "compiler"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["c", "C"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["o"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for running gcc to compile a C file in object file.
|
||||||
|
##
|
||||||
|
def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||||
|
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary, name, basic_folder,file)
|
||||||
|
|
||||||
|
# create the command line befor requesting start:
|
||||||
|
cmd = [
|
||||||
|
target.cc,
|
||||||
|
"-o", file_dst,
|
||||||
|
target.arch,
|
||||||
|
target.sysroot,
|
||||||
|
target.global_include_cc]
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I", path["export"]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I", path["local"]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I", depancy.path))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(get_version_compilation_flags(flags, depancy.flags))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_cc)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["export"]["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cmd.append("-c")
|
||||||
|
cmd.append("-MMD")
|
||||||
|
cmd.append("-MP")
|
||||||
|
cmd.append(file_src)
|
||||||
|
# Create cmd line
|
||||||
|
cmdLine=tools.list_to_str(cmd)
|
||||||
|
# check the dependency for this file :
|
||||||
|
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||||
|
return file_dst
|
||||||
|
tools.create_directory_of_file(file_dst)
|
||||||
|
comment = ["c", name, "<==", file]
|
||||||
|
# process element
|
||||||
|
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||||
|
return file_dst
|
||||||
|
|
||||||
|
|
||||||
|
def get_version_compilation_flags(flags, dependency_flags):
|
||||||
|
try:
|
||||||
|
version_local = flags["local"]["c-version"]["version"]
|
||||||
|
except:
|
||||||
|
version_local = default_version
|
||||||
|
try:
|
||||||
|
dependency_version = dependency_flags["c-version"]
|
||||||
|
except:
|
||||||
|
dependency_version = default_version
|
||||||
|
try:
|
||||||
|
is_gnu = flags["local"]["c-version"]["gnu"]
|
||||||
|
except:
|
||||||
|
is_gnu = default_version_gnu
|
||||||
|
|
||||||
|
version = max(version_local, dependency_version)
|
||||||
|
if version == 2011:
|
||||||
|
if is_gnu ==True:
|
||||||
|
out = ["-std=gnu11", "-D__C_VERSION__=2011"]
|
||||||
|
else:
|
||||||
|
out = ["-std=c11", "-D__C_VERSION__=1989"]
|
||||||
|
elif version == 1999:
|
||||||
|
if is_gnu ==True:
|
||||||
|
out = ["-std=gnu99", "-D__C_VERSION__=1999"]
|
||||||
|
else:
|
||||||
|
out = ["-std=c99", "-D__C_VERSION__=1989"]
|
||||||
|
elif version == 1990:
|
||||||
|
if is_gnu ==True:
|
||||||
|
out = ["-std=gnu90", "-D__C_VERSION__=1990"]
|
||||||
|
else:
|
||||||
|
out = ["-std=c90", "-D__C_VERSION__=1989"]
|
||||||
|
else:
|
||||||
|
if is_gnu ==True:
|
||||||
|
out = ["-std=gnu89", "-D__C_VERSION__=1989"]
|
||||||
|
else:
|
||||||
|
out = ["-std=c89", "-D__C_VERSION__=1989"]
|
||||||
|
return out
|
151
lutin/builder/lutinBuilder_cpp.py
Normal file
151
lutin/builder/lutinBuilder_cpp.py
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
##
|
||||||
|
## C++ builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import depend
|
||||||
|
# C++ default version:
|
||||||
|
default_version = 1999
|
||||||
|
default_version_gnu = False
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "compiler"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["cpp", "CPP", "cxx", "CXX", "xx", "XX", "CC", "cc"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["o"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for running gcc to compile a C++ file in object file.
|
||||||
|
##
|
||||||
|
def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||||
|
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary, name, basic_folder, file)
|
||||||
|
|
||||||
|
# create the command line befor requesting start:
|
||||||
|
cmd = [
|
||||||
|
target.xx,
|
||||||
|
"-o", file_dst,
|
||||||
|
target.arch,
|
||||||
|
target.sysroot,
|
||||||
|
target.global_include_cc
|
||||||
|
]
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",path["export"]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",path["local"]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",depancy.path))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(get_version_compilation_flags(flags, depancy.flags))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_cc)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_xx)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["c++"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["c++"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["export"]["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["export"]["c++"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cmd.append(["-c", "-MMD", "-MP"])
|
||||||
|
cmd.append(file_src)
|
||||||
|
# Create cmd line
|
||||||
|
cmdLine=tools.list_to_str(cmd)
|
||||||
|
|
||||||
|
# check the dependency for this file :
|
||||||
|
if depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine) == False:
|
||||||
|
return file_dst
|
||||||
|
tools.create_directory_of_file(file_dst)
|
||||||
|
comment = ["c++", name, "<==", file]
|
||||||
|
#process element
|
||||||
|
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||||
|
return file_dst
|
||||||
|
|
||||||
|
def get_version_compilation_flags(flags, dependency_flags):
|
||||||
|
try:
|
||||||
|
version_local = flags["local"]["c++-version"]["version"]
|
||||||
|
except:
|
||||||
|
version_local = default_version
|
||||||
|
try:
|
||||||
|
dependency_version = dependency_flags["c++-version"]
|
||||||
|
except:
|
||||||
|
dependency_version = default_version
|
||||||
|
try:
|
||||||
|
is_gnu = flags["local"]["c++-version"]["gnu"]
|
||||||
|
except:
|
||||||
|
is_gnu = default_version_gnu
|
||||||
|
|
||||||
|
version = max(version_local, dependency_version)
|
||||||
|
if version == 2014:
|
||||||
|
debug.error("not supported flags for X14 ...");
|
||||||
|
if is_gnu == True:
|
||||||
|
out = ["-std=gnu++14", "-D__CPP_VERSION__=2014"]
|
||||||
|
else:
|
||||||
|
out = ["-std=c++14", "-D__CPP_VERSION__=2014"]
|
||||||
|
elif version == 2011:
|
||||||
|
if is_gnu == True:
|
||||||
|
out = ["-std=gnu++11", "-D__CPP_VERSION__=2011"]
|
||||||
|
else:
|
||||||
|
out = ["-std=c++11", "-D__CPP_VERSION__=2011"]
|
||||||
|
elif version == 2003:
|
||||||
|
if is_gnu == True:
|
||||||
|
out = ["-std=gnu++03", "-D__CPP_VERSION__=2003"]
|
||||||
|
else:
|
||||||
|
out = ["-std=c++03", "-D__CPP_VERSION__=2003"]
|
||||||
|
else:
|
||||||
|
if is_gnu == True:
|
||||||
|
out = ["-std=gnu++98", "-D__CPP_VERSION__=1999"]
|
||||||
|
else:
|
||||||
|
out = ["-std=c++98", "-D__CPP_VERSION__=1999"]
|
||||||
|
return out
|
34
lutin/builder/lutinBuilder_java.py
Normal file
34
lutin/builder/lutinBuilder_java.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
##
|
||||||
|
## Java builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import depend
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "compiler"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["java"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["class"]
|
100
lutin/builder/lutinBuilder_libraryDynamic.py
Normal file
100
lutin/builder/lutinBuilder_libraryDynamic.py
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
##
|
||||||
|
## Dynamic library builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import depend
|
||||||
|
from lutin import env
|
||||||
|
import os
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "linker"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["o"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["so", "dynlib", "dll"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for running gcc to link a shared library.
|
||||||
|
##
|
||||||
|
def link(file, binary, target, depancy, name, basic_folder):
|
||||||
|
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, name, basic_folder, file, "lib-shared")
|
||||||
|
#create command Line
|
||||||
|
cmd = [
|
||||||
|
target.xx,
|
||||||
|
"-o", file_dst
|
||||||
|
]
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_sysroot)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.arch)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cmd.append("-shared")
|
||||||
|
try:
|
||||||
|
cmd.append(file_src)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.src)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["link"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["link"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_ld)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cmdLine=tools.list_to_str(cmd)
|
||||||
|
# check the dependency for this file :
|
||||||
|
if depend.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) == False \
|
||||||
|
and depend.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine) == False:
|
||||||
|
return tmpList[1]
|
||||||
|
tools.create_directory_of_file(file_dst)
|
||||||
|
debug.print_element("SharedLib", name, "==>", file_dst)
|
||||||
|
multiprocess.run_command(cmdLine)
|
||||||
|
# strip the output file:
|
||||||
|
if target.config["mode"] == "release" \
|
||||||
|
or env.get_force_strip_mode() == True:
|
||||||
|
# get the file size of the non strip file
|
||||||
|
originSize = tools.file_size(file_dst);
|
||||||
|
debug.print_element("SharedLib(strip)", name, "", "")
|
||||||
|
cmdLineStrip=tools.list_to_str([
|
||||||
|
target.strip,
|
||||||
|
file_dst])
|
||||||
|
multiprocess.run_command(cmdLineStrip)
|
||||||
|
# get the stip size of the binary
|
||||||
|
stripSize = tools.file_size(file_dst)
|
||||||
|
debug.debug("file reduce size : " + str(originSize/1024) + "ko ==> " + str(stripSize/1024) + "ko")
|
||||||
|
# write cmd line only after to prevent errors ...
|
||||||
|
multiprocess.store_command(cmdLine, file_cmd)
|
||||||
|
#debug.print_element("SharedLib", self.name, "==>", tmpList[1])
|
82
lutin/builder/lutinBuilder_libraryStatic.py
Normal file
82
lutin/builder/lutinBuilder_libraryStatic.py
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
##
|
||||||
|
## Static library builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import depend
|
||||||
|
from lutin import env
|
||||||
|
import os
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "linker"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["o"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["a"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for running ar.
|
||||||
|
##
|
||||||
|
def link(file, binary, target, depancy, name, basic_folder):
|
||||||
|
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, name, basic_folder, file, "lib-static")
|
||||||
|
#$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS)
|
||||||
|
cmd = [
|
||||||
|
target.ar
|
||||||
|
]
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_ar)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["link"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(file_dst)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(file_src)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cmdLine=tools.list_to_str(cmd)
|
||||||
|
# check the dependency for this file :
|
||||||
|
if depend.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) == False \
|
||||||
|
and depend.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine) == False:
|
||||||
|
return file_dst
|
||||||
|
tools.create_directory_of_file(file_dst)
|
||||||
|
debug.print_element("StaticLib", name, "==>", file_dst)
|
||||||
|
# explicitly remove the destination to prevent error ...
|
||||||
|
if os.path.exists(file_dst) and os.path.isfile(file_dst):
|
||||||
|
os.remove(file_dst)
|
||||||
|
multiprocess.run_command(cmdLine)
|
||||||
|
#$(Q)$(TARGET_RANLIB) $@
|
||||||
|
if target.ranlib != "":
|
||||||
|
cmdLineRanLib=tools.list_to_str([
|
||||||
|
target.ranlib,
|
||||||
|
file_dst ])
|
||||||
|
multiprocess.run_command(cmdLineRanLib)
|
||||||
|
# write cmd line only after to prevent errors ...
|
||||||
|
multiprocess.store_command(cmdLine, file_cmd)
|
||||||
|
return file_dst
|
114
lutin/builder/lutinBuilder_m.py
Normal file
114
lutin/builder/lutinBuilder_m.py
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
##
|
||||||
|
## Objective-C builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import builder
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import depend
|
||||||
|
|
||||||
|
local_ref_on_builder_c = None
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
global local_ref_on_builder_c
|
||||||
|
debug.debug("m builder get dependency on the C builder")
|
||||||
|
local_ref_on_builder_c = builder.get_builder("c")
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "compiler"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["m", "M"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["o"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for running gcc to compile a m file in object file.
|
||||||
|
##
|
||||||
|
def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||||
|
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary, name, basic_folder, file)
|
||||||
|
# create the command line befor requesting start:
|
||||||
|
cmd = [
|
||||||
|
target.cc,
|
||||||
|
"-o", file_dst ,
|
||||||
|
target.arch,
|
||||||
|
target.sysroot,
|
||||||
|
target.global_include_cc]
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",path["export"]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",path["local"]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",depancy.path))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(local_ref_on_builder_c.get_version_compilation_flags(flags, depancy.flags))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_cc)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_m)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["m"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["m"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["export"]["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["export"]["m"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cmd.append("-c -MMD -MP")
|
||||||
|
cmd.append("-x objective-c")
|
||||||
|
cmd.append(file_src)
|
||||||
|
# Create cmd line
|
||||||
|
cmdLine=tools.list_to_str(cmd)
|
||||||
|
# check the dependency for this file :
|
||||||
|
if False==depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||||
|
return file_dst
|
||||||
|
tools.create_directory_of_file(file_dst)
|
||||||
|
comment = ["m", name, "<==", file]
|
||||||
|
#process element
|
||||||
|
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||||
|
return file_dst
|
||||||
|
|
125
lutin/builder/lutinBuilder_mm.py
Normal file
125
lutin/builder/lutinBuilder_mm.py
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
##
|
||||||
|
## Objective C++ builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import builder
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import depend
|
||||||
|
|
||||||
|
local_ref_on_builder_cpp = None
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
global local_ref_on_builder_cpp
|
||||||
|
debug.debug("mm builder get dependency on the CPP builder")
|
||||||
|
local_ref_on_builder_cpp = builder.get_builder("cpp")
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "compiler"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["mm", "MM"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["o"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for running gcc to compile a m++ file in object file.
|
||||||
|
##
|
||||||
|
def compile(file, binary, target, depancy, flags, path, name, basic_folder):
|
||||||
|
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary, name, basic_folder, file)
|
||||||
|
# create the command line befor requesting start:
|
||||||
|
cmd = [
|
||||||
|
target.xx,
|
||||||
|
"-o", file_dst,
|
||||||
|
target.arch,
|
||||||
|
target.sysroot,
|
||||||
|
target.global_include_cc]
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",path["export"]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",path["local"]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(tools.add_prefix("-I",depancy.path))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(local_ref_on_builder_cpp.get_version_compilation_flags(flags, depancy.flags))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_cc)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(target.global_flags_mm)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["c++"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(depancy.flags["mm"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["c++"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["local"]["mm"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["export"]["c"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["export"]["c++"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
cmd.append(flags["export"]["mm"])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cmd.append("-c -MMD -MP")
|
||||||
|
cmd.append("-x objective-c++")
|
||||||
|
cmd.append(file_src)
|
||||||
|
# Create cmd line
|
||||||
|
cmdLine=tools.list_to_str(cmd)
|
||||||
|
# check the dependency for this file :
|
||||||
|
if False==depend.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
||||||
|
return file_dst
|
||||||
|
tools.create_directory_of_file(file_dst)
|
||||||
|
comment = ["m++", name, "<==", file]
|
||||||
|
#process element
|
||||||
|
multiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
||||||
|
return file_dst
|
33
lutin/builder/lutinBuilder_s.py
Normal file
33
lutin/builder/lutinBuilder_s.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
##
|
||||||
|
## ASM builder
|
||||||
|
##
|
||||||
|
from lutin import multiprocess
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import depend
|
||||||
|
|
||||||
|
##
|
||||||
|
## Initialize the builder, if needed ... to get dependency between builder (for example)
|
||||||
|
##
|
||||||
|
def init():
|
||||||
|
pass
|
||||||
|
|
||||||
|
##
|
||||||
|
## Get the current builder type.
|
||||||
|
## Return the type of builder
|
||||||
|
##
|
||||||
|
def get_type():
|
||||||
|
return "compiler"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder input file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_input_type():
|
||||||
|
return ["s", "S"]
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get builder output file type
|
||||||
|
## @return List of extention supported
|
||||||
|
##
|
||||||
|
def get_output_type():
|
||||||
|
return ["o"]
|
141
lutin/debug.py
Normal file
141
lutin/debug.py
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
import re
|
||||||
|
|
||||||
|
debugLevel=3
|
||||||
|
debugColor=False
|
||||||
|
|
||||||
|
color_default= ""
|
||||||
|
color_red = ""
|
||||||
|
color_green = ""
|
||||||
|
color_yellow = ""
|
||||||
|
color_blue = ""
|
||||||
|
color_purple = ""
|
||||||
|
color_cyan = ""
|
||||||
|
|
||||||
|
|
||||||
|
debugLock = threading.Lock()
|
||||||
|
|
||||||
|
def set_level(id):
|
||||||
|
global debugLevel
|
||||||
|
debugLevel = id
|
||||||
|
#print "SetDebug level at " + str(debugLevel)
|
||||||
|
|
||||||
|
def get_level():
|
||||||
|
global debugLevel
|
||||||
|
return debugLevel
|
||||||
|
|
||||||
|
def enable_color():
|
||||||
|
global debugColor
|
||||||
|
debugColor = True
|
||||||
|
global color_default
|
||||||
|
color_default= "\033[00m"
|
||||||
|
global color_red
|
||||||
|
color_red = "\033[31m"
|
||||||
|
global color_green
|
||||||
|
color_green = "\033[32m"
|
||||||
|
global color_yellow
|
||||||
|
color_yellow = "\033[33m"
|
||||||
|
global color_blue
|
||||||
|
color_blue = "\033[34m"
|
||||||
|
global color_purple
|
||||||
|
color_purple = "\033[35m"
|
||||||
|
global color_cyan
|
||||||
|
color_cyan = "\033[36m"
|
||||||
|
|
||||||
|
def extreme_verbose(input, force=False):
|
||||||
|
global debugLock
|
||||||
|
global debugLevel
|
||||||
|
if debugLevel >= 6 \
|
||||||
|
or force == True:
|
||||||
|
debugLock.acquire()
|
||||||
|
print(color_blue + input + color_default)
|
||||||
|
debugLock.release()
|
||||||
|
|
||||||
|
def verbose(input, force=False):
|
||||||
|
global debugLock
|
||||||
|
global debugLevel
|
||||||
|
if debugLevel >= 5 \
|
||||||
|
or force == True:
|
||||||
|
debugLock.acquire()
|
||||||
|
print(color_blue + input + color_default)
|
||||||
|
debugLock.release()
|
||||||
|
|
||||||
|
def debug(input, force=False):
|
||||||
|
global debugLock
|
||||||
|
global debugLevel
|
||||||
|
if debugLevel >= 4 \
|
||||||
|
or force == True:
|
||||||
|
debugLock.acquire()
|
||||||
|
print(color_green + input + color_default)
|
||||||
|
debugLock.release()
|
||||||
|
|
||||||
|
def info(input, force=False):
|
||||||
|
global debugLock
|
||||||
|
global debugLevel
|
||||||
|
if debugLevel >= 3 \
|
||||||
|
or force == True:
|
||||||
|
debugLock.acquire()
|
||||||
|
print(input + color_default)
|
||||||
|
debugLock.release()
|
||||||
|
|
||||||
|
def warning(input, force=False):
|
||||||
|
global debugLock
|
||||||
|
global debugLevel
|
||||||
|
if debugLevel >= 2 \
|
||||||
|
or force == True:
|
||||||
|
debugLock.acquire()
|
||||||
|
print(color_purple + "[WARNING] " + input + color_default)
|
||||||
|
debugLock.release()
|
||||||
|
|
||||||
|
def error(input, threadID=-1, force=False, crash=True):
|
||||||
|
global debugLock
|
||||||
|
global debugLevel
|
||||||
|
if debugLevel >= 1 \
|
||||||
|
or force == True:
|
||||||
|
debugLock.acquire()
|
||||||
|
print(color_red + "[ERROR] " + input + color_default)
|
||||||
|
debugLock.release()
|
||||||
|
if crash==True:
|
||||||
|
from . import multiprocess
|
||||||
|
multiprocess.error_occured()
|
||||||
|
if threadID != -1:
|
||||||
|
threading.interrupt_main()
|
||||||
|
exit(-1)
|
||||||
|
#os_exit(-1)
|
||||||
|
#raise "error happend"
|
||||||
|
|
||||||
|
def print_element(type, lib, dir, name, force=False):
|
||||||
|
global debugLock
|
||||||
|
global debugLevel
|
||||||
|
if debugLevel >= 3 \
|
||||||
|
or force == True:
|
||||||
|
debugLock.acquire()
|
||||||
|
print(color_cyan + type + color_default + " : " + color_yellow + lib + color_default + " " + dir + " " + color_blue + name + color_default)
|
||||||
|
debugLock.release()
|
||||||
|
|
||||||
|
def print_compilator(myString):
|
||||||
|
global debugColor
|
||||||
|
global debugLock
|
||||||
|
if debugColor == True:
|
||||||
|
myString = myString.replace('\\n', '\n')
|
||||||
|
myString = myString.replace('\\t', '\t')
|
||||||
|
myString = myString.replace('error:', color_red+'error:'+color_default)
|
||||||
|
myString = myString.replace('warning:', color_purple+'warning:'+color_default)
|
||||||
|
myString = myString.replace('note:', color_green+'note:'+color_default)
|
||||||
|
myString = re.sub(r'([/\w_-]+\.\w+):', r'-COLORIN-\1-COLOROUT-:', myString)
|
||||||
|
myString = myString.replace('-COLORIN-', color_yellow)
|
||||||
|
myString = myString.replace('-COLOROUT-', color_default)
|
||||||
|
|
||||||
|
debugLock.acquire()
|
||||||
|
print(myString)
|
||||||
|
debugLock.release()
|
@@ -1,51 +1,63 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
import os
|
import os
|
||||||
import lutinDebug as debug
|
# Local import
|
||||||
import lutinEnv as environement
|
from . import debug
|
||||||
|
from . import env
|
||||||
|
|
||||||
def need_re_build(dst, src, dependFile=None, file_cmd="", cmdLine=""):
|
def need_re_build(dst, src, dependFile=None, file_cmd="", cmdLine=""):
|
||||||
debug.verbose("Resuest check of dependency of :")
|
debug.extreme_verbose("Resuest check of dependency of :")
|
||||||
debug.verbose(" dst='" + str(dst) + "'")
|
debug.extreme_verbose(" dst='" + str(dst) + "'")
|
||||||
debug.verbose(" str='" + str(src) + "'")
|
debug.extreme_verbose(" str='" + str(src) + "'")
|
||||||
debug.verbose(" dept='" + str(dependFile) + "'")
|
debug.extreme_verbose(" dept='" + str(dependFile) + "'")
|
||||||
debug.verbose(" cmd='" + str(file_cmd) + "'")
|
debug.extreme_verbose(" cmd='" + str(file_cmd) + "'")
|
||||||
# if force mode selected ==> just force rebuild ...
|
# if force mode selected ==> just force rebuild ...
|
||||||
if environement.get_force_mode():
|
if env.get_force_mode():
|
||||||
debug.verbose(" ==> must rebuild (force mode)")
|
debug.extreme_verbose(" ==> must rebuild (force mode)")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# check if the destination existed:
|
# check if the destination existed:
|
||||||
if dst != "" \
|
if dst != "" \
|
||||||
and dst != None \
|
and dst != None \
|
||||||
and os.path.exists(dst) == False:
|
and os.path.exists(dst) == False:
|
||||||
debug.verbose(" ==> must rebuild (dst does not exist)")
|
debug.extreme_verbose(" ==> must rebuild (dst does not exist)")
|
||||||
|
return True
|
||||||
|
if dst != "" \
|
||||||
|
and dst != None \
|
||||||
|
and os.path.exists(src) == False:
|
||||||
|
debug.warning(" ==> unexistant file :'" + src + "'")
|
||||||
return True
|
return True
|
||||||
# chek the basic date if the 2 files
|
# chek the basic date if the 2 files
|
||||||
if dst != "" \
|
if dst != "" \
|
||||||
and dst != None \
|
and dst != None \
|
||||||
and os.path.getmtime(src) > os.path.getmtime(dst):
|
and os.path.getmtime(src) > os.path.getmtime(dst):
|
||||||
debug.verbose(" ==> must rebuild (source time greater)")
|
debug.extreme_verbose(" ==> must rebuild (source time greater)")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if dependFile != "" \
|
if dependFile != "" \
|
||||||
and dependFile != None \
|
and dependFile != None \
|
||||||
and os.path.exists(dependFile) == False:
|
and os.path.exists(dependFile) == False:
|
||||||
debug.verbose(" ==> must rebuild (no depending file)")
|
debug.extreme_verbose(" ==> must rebuild (no depending file)")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if file_cmd != "" \
|
if file_cmd != "" \
|
||||||
and file_cmd != None:
|
and file_cmd != None:
|
||||||
if os.path.exists(file_cmd) == False:
|
if os.path.exists(file_cmd) == False:
|
||||||
debug.verbose(" ==> must rebuild (no commandLine file)")
|
debug.extreme_verbose(" ==> must rebuild (no commandLine file)")
|
||||||
return True
|
return True
|
||||||
# check if the 2 cmdline are similar :
|
# check if the 2 cmdline are similar :
|
||||||
file2 = open(file_cmd, "r")
|
file2 = open(file_cmd, "r")
|
||||||
firstAndUniqueLine = file2.read()
|
firstAndUniqueLine = file2.read()
|
||||||
if firstAndUniqueLine != cmdLine:
|
if firstAndUniqueLine != cmdLine:
|
||||||
debug.verbose(" ==> must rebuild (cmdLines are not identical)")
|
debug.extreme_verbose(" ==> must rebuild (cmdLines are not identical)")
|
||||||
debug.verbose(" ==> '" + cmdLine + "'")
|
debug.extreme_verbose(" ==> '" + cmdLine + "'")
|
||||||
debug.verbose(" ==> '" + firstAndUniqueLine + "'")
|
debug.extreme_verbose(" ==> '" + firstAndUniqueLine + "'")
|
||||||
file2.close()
|
file2.close()
|
||||||
return True
|
return True
|
||||||
# the cmdfile is correct ...
|
# the cmdfile is correct ...
|
||||||
@@ -53,7 +65,7 @@ def need_re_build(dst, src, dependFile=None, file_cmd="", cmdLine=""):
|
|||||||
|
|
||||||
if dependFile != "" \
|
if dependFile != "" \
|
||||||
and dependFile != None:
|
and dependFile != None:
|
||||||
debug.verbose(" start parsing dependency file : '" + dependFile + "'")
|
debug.extreme_verbose(" start parsing dependency file : '" + dependFile + "'")
|
||||||
file = open(dependFile, "r")
|
file = open(dependFile, "r")
|
||||||
for curLine in file.readlines():
|
for curLine in file.readlines():
|
||||||
# normal file : end with : ": \\n"
|
# normal file : end with : ": \\n"
|
||||||
@@ -68,36 +80,36 @@ def need_re_build(dst, src, dependFile=None, file_cmd="", cmdLine=""):
|
|||||||
|
|
||||||
testFile=""
|
testFile=""
|
||||||
if curLine[len(curLine)-1:] == ':':
|
if curLine[len(curLine)-1:] == ':':
|
||||||
debug.verbose(" Line (no check (already done) : '" + curLine + "'");
|
debug.extreme_verbose(" Line (no check (already done) : '" + curLine + "'");
|
||||||
elif len(curLine) == 0 \
|
elif len(curLine) == 0 \
|
||||||
or curLine == '\\':
|
or curLine == '\\':
|
||||||
debug.verbose(" Line (Not parsed) : '" + curLine + "'");
|
debug.extreme_verbose(" Line (Not parsed) : '" + curLine + "'");
|
||||||
else:
|
else:
|
||||||
testFile = curLine
|
testFile = curLine
|
||||||
debug.verbose(" Line (might check) : '" + testFile + "'");
|
debug.extreme_verbose(" Line (might check) : '" + testFile + "'");
|
||||||
# really check files:
|
# really check files:
|
||||||
if testFile!="":
|
if testFile!="":
|
||||||
debug.verbose(" ==> test");
|
debug.extreme_verbose(" ==> test");
|
||||||
if False==os.path.exists(testFile):
|
if False==os.path.exists(testFile):
|
||||||
debug.verbose(" ==> must rebuild (a dependency file does not exist)")
|
debug.extreme_verbose(" ==> must rebuild (a dependency file does not exist)")
|
||||||
file.close()
|
file.close()
|
||||||
return True
|
return True
|
||||||
if os.path.getmtime(testFile) > os.path.getmtime(dst):
|
if os.path.getmtime(testFile) > os.path.getmtime(dst):
|
||||||
debug.verbose(" ==> must rebuild (a dependency file time is newer)")
|
debug.extreme_verbose(" ==> must rebuild (a dependency file time is newer)")
|
||||||
file.close()
|
file.close()
|
||||||
return True
|
return True
|
||||||
# close the current file :
|
# close the current file :
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
debug.verbose(" ==> Not rebuild (all dependency is OK)")
|
debug.extreme_verbose(" ==> Not rebuild (all dependency is OK)")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def need_re_package(dst, srcList, mustHaveSrc, file_cmd="", cmdLine=""):
|
def need_re_package(dst, srcList, mustHaveSrc, file_cmd="", cmdLine=""):
|
||||||
debug.verbose("Resuest check of dependency of :")
|
debug.extreme_verbose("Resuest check of dependency of :")
|
||||||
debug.verbose(" dst='" + dst + "'")
|
debug.extreme_verbose(" dst='" + dst + "'")
|
||||||
debug.verbose(" src()=")
|
debug.extreme_verbose(" src()=")
|
||||||
for src in srcList:
|
for src in srcList:
|
||||||
debug.verbose(" '" + src + "'")
|
debug.verbose(" '" + src + "'")
|
||||||
|
|
||||||
@@ -105,40 +117,40 @@ def need_re_package(dst, srcList, mustHaveSrc, file_cmd="", cmdLine=""):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# if force mode selected ==> just force rebuild ...
|
# if force mode selected ==> just force rebuild ...
|
||||||
if environement.get_force_mode():
|
if env.get_force_mode():
|
||||||
debug.verbose(" ==> must re-package (force mode)")
|
debug.extreme_verbose(" ==> must re-package (force mode)")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# check if the destination existed:
|
# check if the destination existed:
|
||||||
if False==os.path.exists(dst):
|
if False==os.path.exists(dst):
|
||||||
debug.verbose(" ==> must re-package (dst does not exist)")
|
debug.extreme_verbose(" ==> must re-package (dst does not exist)")
|
||||||
return True
|
return True
|
||||||
# chek the basic date if the 2 files
|
# chek the basic date if the 2 files
|
||||||
if len(srcList)==0:
|
if len(srcList)==0:
|
||||||
debug.verbose(" ==> must re-package (no source ???)")
|
debug.extreme_verbose(" ==> must re-package (no source ???)")
|
||||||
return True
|
return True
|
||||||
for src in srcList:
|
for src in srcList:
|
||||||
if os.path.getmtime(src) > os.path.getmtime(dst):
|
if os.path.getmtime(src) > os.path.getmtime(dst):
|
||||||
debug.verbose(" ==> must re-package (source time greater) : '" + src + "'")
|
debug.extreme_verbose(" ==> must re-package (source time greater) : '" + src + "'")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if ""!=file_cmd:
|
if ""!=file_cmd:
|
||||||
if False==os.path.exists(file_cmd):
|
if False==os.path.exists(file_cmd):
|
||||||
debug.verbose(" ==> must rebuild (no commandLine file)")
|
debug.extreme_verbose(" ==> must rebuild (no commandLine file)")
|
||||||
return True
|
return True
|
||||||
# check if the 2 cmdline are similar :
|
# check if the 2 cmdline are similar :
|
||||||
file2 = open(file_cmd, "r")
|
file2 = open(file_cmd, "r")
|
||||||
firstAndUniqueLine = file2.read()
|
firstAndUniqueLine = file2.read()
|
||||||
if firstAndUniqueLine != cmdLine:
|
if firstAndUniqueLine != cmdLine:
|
||||||
debug.verbose(" ==> must rebuild (cmdLines are not identical)")
|
debug.extreme_verbose(" ==> must rebuild (cmdLines are not identical)")
|
||||||
debug.verbose(" ==> '" + cmdLine + "'")
|
debug.extreme_verbose(" ==> '" + cmdLine + "'")
|
||||||
debug.verbose(" ==> '" + firstAndUniqueLine + "'")
|
debug.extreme_verbose(" ==> '" + firstAndUniqueLine + "'")
|
||||||
file2.close()
|
file2.close()
|
||||||
return True
|
return True
|
||||||
# the cmdfile is correct ...
|
# the cmdfile is correct ...
|
||||||
file2.close()
|
file2.close()
|
||||||
|
|
||||||
debug.verbose(" ==> Not re-package (all dependency is OK)")
|
debug.extreme_verbose(" ==> Not re-package (all dependency is OK)")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@@ -1,5 +1,14 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutinDebug as debug
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -21,7 +30,7 @@ printPrettyMode=False
|
|||||||
|
|
||||||
def set_print_pretty_mode(val):
|
def set_print_pretty_mode(val):
|
||||||
global printPrettyMode
|
global printPrettyMode
|
||||||
if val==True:
|
if val == True:
|
||||||
printPrettyMode = True
|
printPrettyMode = True
|
||||||
else:
|
else:
|
||||||
printPrettyMode = False
|
printPrettyMode = False
|
||||||
@@ -30,9 +39,10 @@ def get_print_pretty_mode():
|
|||||||
global printPrettyMode
|
global printPrettyMode
|
||||||
return printPrettyMode
|
return printPrettyMode
|
||||||
|
|
||||||
def print_pretty(myString):
|
def print_pretty(myString, force=False):
|
||||||
global printPrettyMode
|
global printPrettyMode
|
||||||
if True==printPrettyMode:
|
if printPrettyMode == True \
|
||||||
|
or force == True:
|
||||||
if myString[len(myString)-1]==' ' :
|
if myString[len(myString)-1]==' ' :
|
||||||
tmpcmdLine = myString[:len(myString)-1]
|
tmpcmdLine = myString[:len(myString)-1]
|
||||||
else :
|
else :
|
||||||
@@ -41,7 +51,27 @@ def print_pretty(myString):
|
|||||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||||
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
tmpcmdLine = tmpcmdLine.replace('\n\t\n\t', '\n\t')
|
||||||
baseElementList = ["-o", "-D", "-I", "-L", "g++", "gcc", "clang", "clang++", "ar", "ld", "ranlib", "-framework", "-isysroot", "-arch"]
|
baseElementList = ["-o",
|
||||||
|
"-D",
|
||||||
|
"-I",
|
||||||
|
"-L",
|
||||||
|
"g++",
|
||||||
|
"gcc",
|
||||||
|
"clang",
|
||||||
|
"clang++",
|
||||||
|
"ar",
|
||||||
|
"ld",
|
||||||
|
"ranlib",
|
||||||
|
"-framework",
|
||||||
|
"-isysroot",
|
||||||
|
"-arch",
|
||||||
|
"-keystore",
|
||||||
|
"-sigalg",
|
||||||
|
"-digestalg",
|
||||||
|
"<",
|
||||||
|
"<<",
|
||||||
|
">",
|
||||||
|
">>"]
|
||||||
for element in baseElementList:
|
for element in baseElementList:
|
||||||
tmpcmdLine = tmpcmdLine.replace(element+'\n\t', element+' ')
|
tmpcmdLine = tmpcmdLine.replace(element+'\n\t', element+' ')
|
||||||
baseElementList = ["g++", "gcc", "clang", "clang++", "ar", "ld", "ranlib"]
|
baseElementList = ["g++", "gcc", "clang", "clang++", "ar", "ld", "ranlib"]
|
@@ -1,6 +1,15 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
import sys
|
import sys
|
||||||
import lutinDebug as debug
|
import copy
|
||||||
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
|
||||||
|
|
||||||
def append_to_list(listout, list):
|
def append_to_list(listout, list):
|
||||||
@@ -17,11 +26,7 @@ def append_to_list(listout, list):
|
|||||||
|
|
||||||
class HeritageList:
|
class HeritageList:
|
||||||
def __init__(self, heritage = None):
|
def __init__(self, heritage = None):
|
||||||
self.flags_ld=[]
|
self.flags={}
|
||||||
self.flags_cc=[]
|
|
||||||
self.flags_xx=[]
|
|
||||||
self.flags_m=[]
|
|
||||||
self.flags_mm=[]
|
|
||||||
# sources list:
|
# sources list:
|
||||||
self.src=[]
|
self.src=[]
|
||||||
self.path=[]
|
self.path=[]
|
||||||
@@ -31,13 +36,14 @@ class HeritageList:
|
|||||||
self.add_heritage(heritage)
|
self.add_heritage(heritage)
|
||||||
|
|
||||||
def add_heritage(self, heritage):
|
def add_heritage(self, heritage):
|
||||||
if type(heritage) == type(None) or heritage.name == "":
|
if type(heritage) == type(None) \
|
||||||
|
or heritage.name == "":
|
||||||
return
|
return
|
||||||
for element in self.listHeritage:
|
for element in self.listHeritage:
|
||||||
if element.name == heritage.name:
|
if element.name == heritage.name:
|
||||||
return
|
return
|
||||||
self.listHeritage.append(heritage)
|
self.listHeritage.append(heritage)
|
||||||
self.regenerateTree()
|
self.regenerate_tree()
|
||||||
|
|
||||||
def add_heritage_list(self, heritage_list):
|
def add_heritage_list(self, heritage_list):
|
||||||
if type(heritage_list) == type(None):
|
if type(heritage_list) == type(None):
|
||||||
@@ -49,14 +55,10 @@ class HeritageList:
|
|||||||
find = True
|
find = True
|
||||||
if find == False:
|
if find == False:
|
||||||
self.listHeritage.append(herit)
|
self.listHeritage.append(herit)
|
||||||
self.regenerateTree()
|
self.regenerate_tree()
|
||||||
|
|
||||||
def regenerateTree(self):
|
def regenerate_tree(self):
|
||||||
self.flags_ld=[]
|
self.flags={}
|
||||||
self.flags_cc=[]
|
|
||||||
self.flags_xx=[]
|
|
||||||
self.flags_m=[]
|
|
||||||
self.flags_mm=[]
|
|
||||||
# sources list:
|
# sources list:
|
||||||
self.src=[]
|
self.src=[]
|
||||||
self.path=[]
|
self.path=[]
|
||||||
@@ -89,14 +91,28 @@ class HeritageList:
|
|||||||
for element in self.listHeritage:
|
for element in self.listHeritage:
|
||||||
debug.verbose(" " + element.name + " " + str(element.depends))
|
debug.verbose(" " + element.name + " " + str(element.depends))
|
||||||
for element in reversed(self.listHeritage):
|
for element in reversed(self.listHeritage):
|
||||||
append_to_list(self.flags_ld, element.flags_ld)
|
for flags in element.flags:
|
||||||
append_to_list(self.flags_cc, element.flags_cc)
|
if flags in ["c-version", "c++-version"]:
|
||||||
append_to_list(self.flags_xx, element.flags_xx)
|
continue
|
||||||
append_to_list(self.flags_m, element.flags_m)
|
value = element.flags[flags]
|
||||||
append_to_list(self.flags_mm, element.flags_mm)
|
if flags not in self.flags:
|
||||||
|
self.flags[flags] = value
|
||||||
|
else:
|
||||||
|
append_to_list(self.flags[flags], value)
|
||||||
append_to_list(self.path, element.path)
|
append_to_list(self.path, element.path)
|
||||||
append_to_list(self.src, element.src)
|
append_to_list(self.src, element.src)
|
||||||
|
if "c-version" in element.flags:
|
||||||
|
ver = element.flags["c-version"]
|
||||||
|
if "c-version" in self.flags:
|
||||||
|
if self.flags["c-version"] > ver:
|
||||||
|
ver = self.flags["c-version"]
|
||||||
|
self.flags["c-version"] = ver
|
||||||
|
if "c++-version" in element.flags:
|
||||||
|
ver = element.flags["c++-version"]
|
||||||
|
if "c++-version" in self.flags:
|
||||||
|
if self.flags["c++-version"] > ver:
|
||||||
|
ver = self.flags["c++-version"]
|
||||||
|
self.flags["c++-version"] = ver
|
||||||
|
|
||||||
|
|
||||||
class heritage:
|
class heritage:
|
||||||
@@ -105,11 +121,7 @@ class heritage:
|
|||||||
self.depends=[]
|
self.depends=[]
|
||||||
## Remove all variable to prevent error of multiple definition
|
## Remove all variable to prevent error of multiple definition
|
||||||
# all the parameter that the upper classe need when build
|
# all the parameter that the upper classe need when build
|
||||||
self.flags_ld=[]
|
self.flags={}
|
||||||
self.flags_cc=[]
|
|
||||||
self.flags_xx=[]
|
|
||||||
self.flags_m=[]
|
|
||||||
self.flags_mm=[]
|
|
||||||
# sources list:
|
# sources list:
|
||||||
self.src=[]
|
self.src=[]
|
||||||
self.path=[]
|
self.path=[]
|
||||||
@@ -119,28 +131,13 @@ class heritage:
|
|||||||
if type(module) != type(None):
|
if type(module) != type(None):
|
||||||
# all the parameter that the upper classe need when build
|
# all the parameter that the upper classe need when build
|
||||||
self.name = module.name
|
self.name = module.name
|
||||||
self.depends = module.depends
|
self.depends = copy.deepcopy(module.depends)
|
||||||
self.flags_ld = module.export_flags_ld
|
# keep reference because the flags can change in time
|
||||||
self.flags_cc = module.export_flags_cc
|
self.flags = module.flags["export"]
|
||||||
self.flags_xx = module.export_flags_xx
|
self.path = module.path["export"]
|
||||||
self.flags_m = module.export_flags_m
|
|
||||||
self.flags_mm = module.export_flags_mm
|
|
||||||
self.path = module.export_path
|
|
||||||
|
|
||||||
def add_flag_LD(self, list):
|
def add_depends(self, depend):
|
||||||
append_to_list(self.flags_ld, list)
|
self.depends.append(depend)
|
||||||
|
|
||||||
def add_flag_CC(self, list):
|
|
||||||
append_to_list(self.flags_cc, list)
|
|
||||||
|
|
||||||
def add_flag_XX(self, list):
|
|
||||||
append_to_list(self.flags_xx, list)
|
|
||||||
|
|
||||||
def add_flag_M(self, list):
|
|
||||||
append_to_list(self.flags_m, list)
|
|
||||||
|
|
||||||
def add_flag_MM(self, list):
|
|
||||||
append_to_list(self.flags_mm, list)
|
|
||||||
|
|
||||||
def add_import_path(self, list):
|
def add_import_path(self, list):
|
||||||
append_to_list(self.path, list)
|
append_to_list(self.path, list)
|
||||||
@@ -157,10 +154,25 @@ class heritage:
|
|||||||
return
|
return
|
||||||
if other.hasBeenUpdated == True:
|
if other.hasBeenUpdated == True:
|
||||||
self.hasBeenUpdated = True
|
self.hasBeenUpdated = True
|
||||||
self.add_flag_LD(other.flags_ld)
|
for flags in other.flags:
|
||||||
self.add_flag_CC(other.flags_cc)
|
value = other.flags[flags]
|
||||||
self.add_flag_XX(other.flags_xx)
|
if flags not in self.flags:
|
||||||
self.add_flag_M(other.flags_m)
|
self.flags[flags] = value
|
||||||
self.add_flag_MM(other.flags_mm)
|
else:
|
||||||
|
append_to_list(self.flags[flags], value)
|
||||||
self.add_import_path(other.path)
|
self.add_import_path(other.path)
|
||||||
self.add_sources(other.src)
|
self.add_sources(other.src)
|
||||||
|
if "c-version" in module.flags["export"]:
|
||||||
|
ver = module.flags["export"]["c-version"]
|
||||||
|
if "c-version" in self.flags:
|
||||||
|
if self.flags["c-version"] > ver:
|
||||||
|
ver = self.flags["c-version"]
|
||||||
|
self.flags["c-version"] = ver
|
||||||
|
if "c++-version" in module.flags["export"]:
|
||||||
|
ver = module.flags["export"]["c++-version"]
|
||||||
|
if "c++-version" in self.flags:
|
||||||
|
if self.flags["c++-version"] > ver:
|
||||||
|
ver = self.flags["c++-version"]
|
||||||
|
self.flags["c++-version"] = ver
|
||||||
|
|
||||||
|
|
33
lutin/host.py
Normal file
33
lutin/host.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
|
||||||
|
# print os.name # ==> 'posix'
|
||||||
|
if platform.system() == "Linux":
|
||||||
|
OS = "Linux"
|
||||||
|
elif platform.system() == "Windows":
|
||||||
|
OS = "Windows"
|
||||||
|
elif platform.system() == "Darwin":
|
||||||
|
OS = "MacOs"
|
||||||
|
else:
|
||||||
|
debug.error("Unknow the Host OS ... '" + platform.system() + "'")
|
||||||
|
|
||||||
|
debug.debug("host.OS = " + OS)
|
||||||
|
|
||||||
|
|
||||||
|
if sys.maxsize > 2**32:
|
||||||
|
BUS_SIZE = 64
|
||||||
|
else:
|
||||||
|
BUS_SIZE = 32
|
||||||
|
|
||||||
|
debug.debug("host.BUS_SIZE = " + str(BUS_SIZE))
|
||||||
|
|
@@ -1,15 +1,28 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutinDebug as debug
|
##
|
||||||
import lutinTools as tools
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
import platform
|
import platform
|
||||||
import os
|
import os
|
||||||
import lutinMultiprocess
|
# Local import
|
||||||
import lutinDepend as dependency
|
from . import debug
|
||||||
|
from . import tools
|
||||||
|
from . import multiprocess
|
||||||
|
from . import depend
|
||||||
|
|
||||||
if platform.system() == "Darwin":
|
enableResizeImage = True
|
||||||
|
try:
|
||||||
|
if platform.system() == "Darwin":
|
||||||
import CoreGraphics
|
import CoreGraphics
|
||||||
else:
|
else:
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
except:
|
||||||
|
enableResizeImage = False
|
||||||
|
debug.warning("Missing python tools : CoreGraphics (MacOs) or PIL")
|
||||||
|
|
||||||
def get_pow_2_multiple(size):
|
def get_pow_2_multiple(size):
|
||||||
base = 2
|
base = 2
|
||||||
@@ -22,10 +35,12 @@ def get_pow_2_multiple(size):
|
|||||||
# check if time change
|
# check if time change
|
||||||
# check if command line change
|
# check if command line change
|
||||||
def resize(srcFile, destFile, x, y, cmd_file=None):
|
def resize(srcFile, destFile, x, y, cmd_file=None):
|
||||||
|
if enableResizeImage == False:
|
||||||
|
return
|
||||||
if os.path.exists(srcFile) == False:
|
if os.path.exists(srcFile) == False:
|
||||||
debug.error("Request a resize an image that does not existed : '" + srcFile + "'")
|
debug.error("Request a resize an image that does not existed : '" + srcFile + "'")
|
||||||
cmd_line = "resize Image : " + srcFile + " ==> " + destFile + " newSize=(" + str(x) + "x" + str(y) + ")"
|
cmd_line = "resize Image : " + srcFile + " ==> " + destFile + " newSize=(" + str(x) + "x" + str(y) + ")"
|
||||||
if False==dependency.need_re_build(destFile, srcFile, file_cmd=cmd_file , cmdLine=cmd_line):
|
if False==depend.need_re_build(destFile, srcFile, file_cmd=cmd_file , cmdLine=cmd_line):
|
||||||
return
|
return
|
||||||
# add cmdLine ...
|
# add cmdLine ...
|
||||||
x = get_pow_2_multiple(x)
|
x = get_pow_2_multiple(x)
|
||||||
@@ -75,4 +90,4 @@ def resize(srcFile, destFile, x, y, cmd_file=None):
|
|||||||
tmpImage = im1.resize((x, y), Image.ANTIALIAS)
|
tmpImage = im1.resize((x, y), Image.ANTIALIAS)
|
||||||
tools.create_directory_of_file(destFile)
|
tools.create_directory_of_file(destFile)
|
||||||
tmpImage.save(destFile)
|
tmpImage.save(destFile)
|
||||||
lutinMultiprocess.store_command(cmd_line, cmd_file)
|
multiprocess.store_command(cmd_line, cmd_file)
|
630
lutin/module.py
Normal file
630
lutin/module.py
Normal file
@@ -0,0 +1,630 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import inspect
|
||||||
|
import fnmatch
|
||||||
|
# Local import
|
||||||
|
from . import host
|
||||||
|
from . import tools
|
||||||
|
from . import debug
|
||||||
|
from . import heritage
|
||||||
|
from . import builder
|
||||||
|
from . import multiprocess
|
||||||
|
|
||||||
|
class Module:
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Module class represent all system needed for a specific
|
||||||
|
## module like
|
||||||
|
## - type (bin/lib ...)
|
||||||
|
## - dependency
|
||||||
|
## - flags
|
||||||
|
## - files
|
||||||
|
## - ...
|
||||||
|
##
|
||||||
|
def __init__(self, file, moduleName, moduleType):
|
||||||
|
## Remove all variable to prevent error of multiple deffinition of the module ...
|
||||||
|
debug.verbose("Create a new module : '" + moduleName + "' TYPE=" + moduleType)
|
||||||
|
self.origin_file=''
|
||||||
|
self.origin_folder=''
|
||||||
|
# type of the module:
|
||||||
|
self.type='LIBRARY'
|
||||||
|
# Name of the module
|
||||||
|
self.name=moduleName
|
||||||
|
# Dependency list:
|
||||||
|
self.depends = []
|
||||||
|
# Dependency list (optionnal module):
|
||||||
|
self.depends_optionnal = []
|
||||||
|
self.depends_find = []
|
||||||
|
# Documentation list:
|
||||||
|
self.documentation = None
|
||||||
|
# export PATH
|
||||||
|
self.path = {"export":[],
|
||||||
|
"local":[]
|
||||||
|
}
|
||||||
|
self.flags = {"export":{},
|
||||||
|
"local":{}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
self.export_flags_ld = []
|
||||||
|
self.export_flags_cc = []
|
||||||
|
self.export_flags_xx = []
|
||||||
|
self.export_flags_m = []
|
||||||
|
self.export_flags_mm = []
|
||||||
|
# list of all flags:
|
||||||
|
self.flags_ld = []
|
||||||
|
self.flags_cc = []
|
||||||
|
self.flags_xx = []
|
||||||
|
self.flags_m = []
|
||||||
|
self.flags_mm = []
|
||||||
|
self.flags_s = []
|
||||||
|
self.flags_ar = []
|
||||||
|
"""
|
||||||
|
# sources list:
|
||||||
|
self.src = []
|
||||||
|
# copy files and folders:
|
||||||
|
self.imageToCopy = []
|
||||||
|
self.files = []
|
||||||
|
self.folders = []
|
||||||
|
self.isbuild = False
|
||||||
|
|
||||||
|
## end of basic INIT ...
|
||||||
|
if moduleType == 'BINARY' \
|
||||||
|
or moduleType == 'LIBRARY' \
|
||||||
|
or moduleType == 'PACKAGE' \
|
||||||
|
or moduleType == 'PREBUILD':
|
||||||
|
self.type=moduleType
|
||||||
|
else :
|
||||||
|
debug.error('for module "%s"' %moduleName)
|
||||||
|
debug.error(' ==> error : "%s" ' %moduleType)
|
||||||
|
raise 'Input value error'
|
||||||
|
self.origin_file = file;
|
||||||
|
self.origin_folder = tools.get_current_path(self.origin_file)
|
||||||
|
self.local_heritage = heritage.heritage(self)
|
||||||
|
|
||||||
|
self.package_prop = { "COMPAGNY_TYPE" : set(""),
|
||||||
|
"COMPAGNY_NAME" : set(""),
|
||||||
|
"COMPAGNY_NAME2" : set(""),
|
||||||
|
"MAINTAINER" : set([]),
|
||||||
|
#"ICON" : set(""),
|
||||||
|
"SECTION" : set([]),
|
||||||
|
"PRIORITY" : set(""),
|
||||||
|
"DESCRIPTION" : set(""),
|
||||||
|
"VERSION" : set("0.0.0"),
|
||||||
|
"VERSION_CODE" : "",
|
||||||
|
"NAME" : set("no-name"), # name of the application
|
||||||
|
"ANDROID_MANIFEST" : "", # By default generate the manifest
|
||||||
|
"ANDROID_JAVA_FILES" : ["DEFAULT"], # when user want to create his own services and activities
|
||||||
|
"ANDROID_RESOURCES" : [],
|
||||||
|
"ANDROID_APPL_TYPE" : "APPL", # the other mode is "WALLPAPER" ... and later "WIDGET"
|
||||||
|
"ANDROID_WALLPAPER_PROPERTIES" : [], # To create properties of the wallpaper (no use of EWOL display)
|
||||||
|
"RIGHT" : [],
|
||||||
|
"ADMOD_POSITION" : "top"
|
||||||
|
}
|
||||||
|
self.sub_heritage_list = None
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief add Some copilation flags for this module (and only this one)
|
||||||
|
##
|
||||||
|
def add_extra_compile_flags(self):
|
||||||
|
self.compile_flags('c', [
|
||||||
|
"-Wall",
|
||||||
|
"-Wsign-compare",
|
||||||
|
"-Wreturn-type",
|
||||||
|
#"-Wint-to-pointer-cast",
|
||||||
|
"-Wno-write-strings",
|
||||||
|
"-Woverloaded-virtual",
|
||||||
|
"-Wnon-virtual-dtor",
|
||||||
|
"-Wno-unused-variable"]);
|
||||||
|
#only for gcc : "-Wunused-variable", "-Wunused-but-set-variable",
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief remove all unneeded warning on compilation ==> for extern libs ...
|
||||||
|
##
|
||||||
|
def remove_compile_warning(self):
|
||||||
|
self.compile_flags('c', [
|
||||||
|
"-Wno-int-to-pointer-cast"
|
||||||
|
]);
|
||||||
|
self.compile_flags('c++', [
|
||||||
|
"-Wno-c++11-narrowing"
|
||||||
|
])
|
||||||
|
# only for gcc :"-Wno-unused-but-set-variable"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for copying files
|
||||||
|
##
|
||||||
|
def image_to_staging(self, binary_name, target):
|
||||||
|
for source, destination, sizeX, sizeY in self.imageToCopy:
|
||||||
|
extension = source[source.rfind('.'):]
|
||||||
|
if extension != ".png" \
|
||||||
|
and extension != ".jpg" \
|
||||||
|
and sizeX > 0:
|
||||||
|
debug.error("Can not manage image other than .png and jpg to resize : " + source);
|
||||||
|
displaySource = source
|
||||||
|
source = self.origin_folder + "/" + source
|
||||||
|
if destination == "":
|
||||||
|
destination = source[source.rfind('/')+1:]
|
||||||
|
debug.verbose("Regenerate Destination : '" + destination + "'")
|
||||||
|
file_cmd = target.generate_file(binary_name, self.name, self.origin_folder, destination, "image")[0]
|
||||||
|
if sizeX > 0:
|
||||||
|
debug.verbose("Image file : " + displaySource + " ==> " + destination + " resize=(" + str(sizeX) + "," + str(sizeY) + ")")
|
||||||
|
fileName, fileExtension = os.path.splitext(self.origin_folder+"/" + source)
|
||||||
|
target.add_image_staging(source, destination, sizeX, sizeY, file_cmd)
|
||||||
|
else:
|
||||||
|
debug.verbose("Might copy file : " + displaySource + " ==> " + destination)
|
||||||
|
target.add_file_staging(source, destination, file_cmd)
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for copying files
|
||||||
|
##
|
||||||
|
def files_to_staging(self, binary_name, target):
|
||||||
|
for source, destination in self.files:
|
||||||
|
displaySource = source
|
||||||
|
source = self.origin_folder + "/" + source
|
||||||
|
if destination == "":
|
||||||
|
destination = source[source.rfind('/')+1:]
|
||||||
|
debug.verbose("Regenerate Destination : '" + destination + "'")
|
||||||
|
file_cmd = target.generate_file(binary_name, self.name, self.origin_folder, destination, "image")[0]
|
||||||
|
# TODO : when destination is missing ...
|
||||||
|
debug.verbose("Might copy file : " + displaySource + " ==> " + destination)
|
||||||
|
target.add_file_staging(source, destination, file_cmd)
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Commands for copying files
|
||||||
|
##
|
||||||
|
def folders_to_staging(self, binary_name, target):
|
||||||
|
for source, destination in self.folders:
|
||||||
|
debug.debug("Might copy folder : " + source + "==>" + destination)
|
||||||
|
tools.copy_anything_target(target, self.origin_folder + "/" + source, destination)
|
||||||
|
|
||||||
|
# call here to build the module
|
||||||
|
def build(self, target, package_name):
|
||||||
|
# ckeck if not previously build
|
||||||
|
if target.is_module_build(self.name)==True:
|
||||||
|
if self.sub_heritage_list == None:
|
||||||
|
self.local_heritage = heritage.heritage(self)
|
||||||
|
return self.sub_heritage_list
|
||||||
|
# create the package heritage
|
||||||
|
self.local_heritage = heritage.heritage(self)
|
||||||
|
|
||||||
|
if package_name==None \
|
||||||
|
and ( self.type=="BINARY" \
|
||||||
|
or self.type=="PACKAGE" ) :
|
||||||
|
# this is the endpoint binary ...
|
||||||
|
package_name = self.name
|
||||||
|
else :
|
||||||
|
# TODO : Set it better ...
|
||||||
|
None
|
||||||
|
|
||||||
|
# build dependency before
|
||||||
|
list_sub_file_needed_to_build = []
|
||||||
|
self.sub_heritage_list = heritage.HeritageList()
|
||||||
|
# optionnal dependency :
|
||||||
|
for dep, option, export in self.depends_optionnal:
|
||||||
|
inherit_list, isBuilt = target.build_optionnal(dep, package_name)
|
||||||
|
if isBuilt == True:
|
||||||
|
self.local_heritage.add_depends(dep);
|
||||||
|
# TODO : Add optionnal Flags ...
|
||||||
|
# ==> do it really better ...
|
||||||
|
if export == False:
|
||||||
|
self.compile_flags(option[0], option[1]);
|
||||||
|
else:
|
||||||
|
self.add_export_flag(option[0], option[1]);
|
||||||
|
# add at the heritage list :
|
||||||
|
self.sub_heritage_list.add_heritage_list(inherit_list)
|
||||||
|
for dep in self.depends:
|
||||||
|
inherit_list = target.build(dep, package_name)
|
||||||
|
# add at the heritage list :
|
||||||
|
self.sub_heritage_list.add_heritage_list(inherit_list)
|
||||||
|
|
||||||
|
# build local sources
|
||||||
|
for file in self.src:
|
||||||
|
#debug.info(" " + self.name + " <== " + file);
|
||||||
|
fileExt = file.split(".")[-1]
|
||||||
|
try:
|
||||||
|
tmp_builder = builder.get_builder(fileExt);
|
||||||
|
resFile = tmp_builder.compile(file,
|
||||||
|
package_name,
|
||||||
|
target,
|
||||||
|
self.sub_heritage_list,
|
||||||
|
flags = self.flags,
|
||||||
|
path = self.path,
|
||||||
|
name = self.name,
|
||||||
|
basic_folder = self.origin_folder)
|
||||||
|
list_sub_file_needed_to_build.append(resFile)
|
||||||
|
except ValueError:
|
||||||
|
debug.warning(" UN-SUPPORTED file format: '" + self.origin_folder + "/" + file + "'")
|
||||||
|
|
||||||
|
# when multiprocess availlable, we need to synchronize here ...
|
||||||
|
multiprocess.pool_synchrosize()
|
||||||
|
|
||||||
|
# generate end point:
|
||||||
|
if self.type=='PREBUILD':
|
||||||
|
debug.print_element("Prebuild", self.name, "==>", "find")
|
||||||
|
elif self.type=='LIBRARY':
|
||||||
|
try:
|
||||||
|
tmp_builder = builder.get_builder_with_output("a");
|
||||||
|
resFile = tmp_builder.link(list_sub_file_needed_to_build,
|
||||||
|
package_name,
|
||||||
|
target,
|
||||||
|
self.sub_heritage_list,
|
||||||
|
name = self.name,
|
||||||
|
basic_folder = self.origin_folder)
|
||||||
|
self.local_heritage.add_sources(resFile)
|
||||||
|
except ValueError:
|
||||||
|
debug.error(" UN-SUPPORTED link format: '.a'")
|
||||||
|
elif self.type=='BINARY':
|
||||||
|
try:
|
||||||
|
tmp_builder = builder.get_builder_with_output("bin");
|
||||||
|
resFile = tmp_builder.link(list_sub_file_needed_to_build,
|
||||||
|
package_name,
|
||||||
|
target,
|
||||||
|
self.sub_heritage_list,
|
||||||
|
name = self.name,
|
||||||
|
basic_folder = self.origin_folder)
|
||||||
|
except ValueError:
|
||||||
|
debug.error(" UN-SUPPORTED link format: '.bin'")
|
||||||
|
# generate tree for this special binary
|
||||||
|
target.clean_module_tree()
|
||||||
|
self.build_tree(target, self.name)
|
||||||
|
target.copy_to_staging(self.name)
|
||||||
|
elif self.type=="PACKAGE":
|
||||||
|
if target.name=="Android":
|
||||||
|
# special case for android wrapper :
|
||||||
|
try:
|
||||||
|
tmp_builder = builder.get_builder_with_output("so");
|
||||||
|
resFile = tmp_builder.link(list_sub_file_needed_to_build,
|
||||||
|
package_name,
|
||||||
|
target,
|
||||||
|
self.sub_heritage_list,
|
||||||
|
name = "libewol",
|
||||||
|
basic_folder = self.origin_folder)
|
||||||
|
except ValueError:
|
||||||
|
debug.error(" UN-SUPPORTED link format: '.so'")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
tmp_builder = builder.get_builder_with_output("bin");
|
||||||
|
resFile = tmp_builder.link(list_sub_file_needed_to_build,
|
||||||
|
package_name,
|
||||||
|
target,
|
||||||
|
self.sub_heritage_list,
|
||||||
|
name = self.name,
|
||||||
|
basic_folder = self.origin_folder)
|
||||||
|
except ValueError:
|
||||||
|
debug.error(" UN-SUPPORTED link format: 'binary'")
|
||||||
|
target.clean_module_tree()
|
||||||
|
# generate tree for this special binary
|
||||||
|
self.build_tree(target, self.name)
|
||||||
|
target.copy_to_staging(self.name)
|
||||||
|
if target.endGeneratePackage==True:
|
||||||
|
# generate the package with his properties ...
|
||||||
|
target.make_package(self.name, self.package_prop, self.origin_folder + "/..")
|
||||||
|
else:
|
||||||
|
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
||||||
|
|
||||||
|
self.sub_heritage_list.add_heritage(self.local_heritage)
|
||||||
|
# return local dependency ...
|
||||||
|
return self.sub_heritage_list
|
||||||
|
|
||||||
|
# call here to build the module
|
||||||
|
def build_tree(self, target, package_name):
|
||||||
|
# ckeck if not previously build
|
||||||
|
if target.is_module_buildTree(self.name)==True:
|
||||||
|
return
|
||||||
|
debug.verbose("build tree of " + self.name)
|
||||||
|
# add all the elements (first added only one keep ==> permit to everload sublib element)
|
||||||
|
self.image_to_staging(package_name, target)
|
||||||
|
self.files_to_staging(package_name, target)
|
||||||
|
self.folders_to_staging(package_name, target)
|
||||||
|
#build tree of all submodules
|
||||||
|
for dep in self.depends:
|
||||||
|
inherit = target.build_tree(dep, package_name)
|
||||||
|
|
||||||
|
|
||||||
|
# call here to clean the module
|
||||||
|
def clean(self, target):
|
||||||
|
if self.type=='PREBUILD':
|
||||||
|
# nothing to add ==> just dependence
|
||||||
|
None
|
||||||
|
elif self.type=='LIBRARY':
|
||||||
|
# remove folder of the lib ... for this targer
|
||||||
|
folderbuild = target.get_build_folder(self.name)
|
||||||
|
debug.info("remove folder : '" + folderbuild + "'")
|
||||||
|
tools.remove_folder_and_sub_folder(folderbuild)
|
||||||
|
elif self.type=='BINARY' \
|
||||||
|
or self.type=='PACKAGE':
|
||||||
|
# remove folder of the lib ... for this targer
|
||||||
|
folderbuild = target.get_build_folder(self.name)
|
||||||
|
debug.info("remove folder : '" + folderbuild + "'")
|
||||||
|
tools.remove_folder_and_sub_folder(folderbuild)
|
||||||
|
folderStaging = target.get_staging_folder(self.name)
|
||||||
|
debug.info("remove folder : '" + folderStaging + "'")
|
||||||
|
tools.remove_folder_and_sub_folder(folderStaging)
|
||||||
|
else:
|
||||||
|
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
||||||
|
|
||||||
|
def append_and_check(self, listout, newElement, order):
|
||||||
|
for element in listout:
|
||||||
|
if element==newElement:
|
||||||
|
return
|
||||||
|
listout.append(newElement)
|
||||||
|
if True==order:
|
||||||
|
listout.sort()
|
||||||
|
|
||||||
|
def append_to_internalList2(self, listout, module, list, order=False):
|
||||||
|
# add list in the Map
|
||||||
|
if module not in listout:
|
||||||
|
listout[module] = []
|
||||||
|
# add elements...
|
||||||
|
self.append_to_internalList(listout[module], list, order)
|
||||||
|
|
||||||
|
def append_to_internalList(self, listout, list, order=False):
|
||||||
|
if type(list) == type(str()):
|
||||||
|
self.append_and_check(listout, list, order)
|
||||||
|
else:
|
||||||
|
# mulyiple imput in the list ...
|
||||||
|
for elem in list:
|
||||||
|
self.append_and_check(listout, elem, order)
|
||||||
|
|
||||||
|
def add_module_depend(self, list):
|
||||||
|
self.append_to_internalList(self.depends, list, True)
|
||||||
|
|
||||||
|
def add_optionnal_module_depend(self, module_name, compilation_flags=["", ""], export=False):
|
||||||
|
self.append_and_check(self.depends_optionnal, [module_name, compilation_flags, export], True)
|
||||||
|
|
||||||
|
def add_export_path(self, list):
|
||||||
|
self.append_to_internalList(self.path["export"], list)
|
||||||
|
|
||||||
|
def add_path(self, list):
|
||||||
|
self.append_to_internalList(self.path["local"], list)
|
||||||
|
|
||||||
|
def add_export_flag(self, type, list):
|
||||||
|
self.append_to_internalList2(self.flags["export"], type, list)
|
||||||
|
|
||||||
|
# add the link flag at the module
|
||||||
|
def compile_flags(self, type, list):
|
||||||
|
self.append_to_internalList2(self.flags["local"], type, list)
|
||||||
|
|
||||||
|
def compile_version_XX(self, version, same_as_api=True, gnu=False):
|
||||||
|
cpp_version_list = [1999, 2003, 2011, 2014]
|
||||||
|
if version not in cpp_version_list:
|
||||||
|
debug.error("can not select CPP version : " + str(version) + " not in " + str(cpp_version_list))
|
||||||
|
# select API version:
|
||||||
|
api_version = 1999
|
||||||
|
if same_as_api == True:
|
||||||
|
api_version = version
|
||||||
|
self.flags["local"]["c++-version"] = { "version":version,
|
||||||
|
"gnu":gnu
|
||||||
|
}
|
||||||
|
self.flags["export"]["c++-version"] = api_version
|
||||||
|
if gnu == True and same_as_api == True:
|
||||||
|
debug.warning("Can not propagate the gnu extention of the CPP vesion for API");
|
||||||
|
|
||||||
|
def compile_version_CC(self, version, same_as_api=True, gnu=False):
|
||||||
|
c_version_list = [1989, 1990, 1999, 2011]
|
||||||
|
if version not in c_version_list:
|
||||||
|
debug.error("can not select C version : " + str(version) + " not in " + str(c_version_list))
|
||||||
|
# select API version:
|
||||||
|
api_version = 1999
|
||||||
|
if same_as_api == True:
|
||||||
|
api_version = version
|
||||||
|
self.flags["local"]["c-version"] = { "version":version,
|
||||||
|
"gnu":gnu
|
||||||
|
}
|
||||||
|
self.flags["export"]["c-version"] = api_version
|
||||||
|
if gnu == True and same_as_api == True:
|
||||||
|
debug.warning("Can not propagate the gnu extention of the C vesion for API");
|
||||||
|
|
||||||
|
def add_src_file(self, list):
|
||||||
|
self.append_to_internalList(self.src, list, True)
|
||||||
|
|
||||||
|
def copy_image(self, source, destination='', sizeX=-1, sizeY=-1):
|
||||||
|
self.imageToCopy.append([source, destination, sizeX, sizeY])
|
||||||
|
|
||||||
|
def copy_file(self, source, destination=''):
|
||||||
|
self.files.append([source, destination])
|
||||||
|
|
||||||
|
def copy_folder(self, source, destination=''):
|
||||||
|
self.folders.append([source, destination])
|
||||||
|
|
||||||
|
def print_list(self, description, list):
|
||||||
|
if len(list) > 0:
|
||||||
|
print(' ' + str(description))
|
||||||
|
for elem in list:
|
||||||
|
print(' ' + str(elem))
|
||||||
|
|
||||||
|
def display(self, target):
|
||||||
|
print('-----------------------------------------------')
|
||||||
|
print(' package : "' + self.name + "'")
|
||||||
|
print('-----------------------------------------------')
|
||||||
|
print(' type:"' + str(self.type) + "'")
|
||||||
|
print(' file:"' + str(self.origin_file) + "'")
|
||||||
|
print(' folder:"' + str(self.origin_folder) + "'")
|
||||||
|
|
||||||
|
self.print_list('depends',self.depends)
|
||||||
|
self.print_list('depends_optionnal', self.depends_optionnal)
|
||||||
|
|
||||||
|
for element,value in self.flags["local"]:
|
||||||
|
self.print_list('flags ' + element, value)
|
||||||
|
|
||||||
|
for element,value in self.flags["export"]:
|
||||||
|
self.print_list('flags export ' + element, value)
|
||||||
|
|
||||||
|
self.print_list('src',self.src)
|
||||||
|
self.print_list('files',self.files)
|
||||||
|
self.print_list('folders',self.folders)
|
||||||
|
self.print_list('export path',self.path["export"])
|
||||||
|
self.print_list('local path',self.path["local"])
|
||||||
|
|
||||||
|
def pkg_set(self, variable, value):
|
||||||
|
if "COMPAGNY_TYPE" == variable:
|
||||||
|
# com : Commercial
|
||||||
|
# net : Network??
|
||||||
|
# org : Organisation
|
||||||
|
# gov : Governement
|
||||||
|
# mil : Military
|
||||||
|
# edu : Education
|
||||||
|
# pri : Private
|
||||||
|
# museum : ...
|
||||||
|
if value not in ["com", "net", "org", "gov", "mil", "edu", "pri", "museum"]:
|
||||||
|
debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'")
|
||||||
|
else:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "COMPAGNY_NAME" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
val2 = value.lower()
|
||||||
|
val2 = val2.replace(' ', '')
|
||||||
|
val2 = val2.replace('-', '')
|
||||||
|
val2 = val2.replace('_', '')
|
||||||
|
self.package_prop["COMPAGNY_NAME2"] = val2
|
||||||
|
elif "ICON" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "MAINTAINER" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "SECTION" == variable:
|
||||||
|
# project section : (must be separate by coma
|
||||||
|
# refer to : http://packages.debian.org/sid/
|
||||||
|
# admin cli-mono comm database debian-installer
|
||||||
|
# debug doc editors electronics devel embedded
|
||||||
|
# fonts games gnome gnu-r gnustep graphics
|
||||||
|
# hamradio haskell httpd interpreters java
|
||||||
|
# kde kernel libdevel libs lisp localization
|
||||||
|
# mail math misc net news ocaml oldlibs otherosfs
|
||||||
|
# perl php python ruby science shells sound tex
|
||||||
|
# text utils vcs video virtual web x11 xfce zope ...
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "PRIORITY" == variable:
|
||||||
|
#list = ["required","important","standard","optional","extra"]
|
||||||
|
#if isinstance(value, list):
|
||||||
|
if value not in ["required", "important", "standard", "optional", "extra"]:
|
||||||
|
debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'")
|
||||||
|
else:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "DESCRIPTION" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "VERSION" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "VERSION_CODE" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "NAME" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "ANDROID_MANIFEST" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "ANDROID_JAVA_FILES" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "RIGHT" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "ANDROID_RESOURCES" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "ANDROID_APPL_TYPE" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "ADMOD_ID" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "APPLE_APPLICATION_IOS_ID" == variable:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
elif "ADMOD_POSITION" == variable:
|
||||||
|
if value in ["top", "bottom"]:
|
||||||
|
self.package_prop[variable] = value
|
||||||
|
else:
|
||||||
|
debug.error("not know pkg element : '" + variable + "' with value : '" + value + "' must be [top|bottom]")
|
||||||
|
else:
|
||||||
|
debug.error("not know pkg element : '" + variable + "'")
|
||||||
|
|
||||||
|
def pkg_add(self, variable, value):
|
||||||
|
# TODO : Check values...
|
||||||
|
self.package_prop[variable].append(value)
|
||||||
|
|
||||||
|
def ext_project_add_module(self, target, projectMng, added_module = []):
|
||||||
|
if self.name in added_module:
|
||||||
|
return
|
||||||
|
added_module.append(self.name)
|
||||||
|
debug.verbose("add a module to the project generator :" + self.name)
|
||||||
|
debug.verbose("local path :" + self.origin_folder)
|
||||||
|
projectMng.add_files(self.name, self.origin_folder, self.src)
|
||||||
|
#projectMng.add_data_file(self.origin_folder, self.files)
|
||||||
|
#projectMng.add_data_folder(self.origin_folder, self.folders)
|
||||||
|
"""
|
||||||
|
for depend in self.depends:
|
||||||
|
target.project_add_module(depend, projectMng, added_module)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def create_project(self, target, projectMng):
|
||||||
|
projectMng.set_project_name(self.name)
|
||||||
|
self.ext_project_add_module(target, projectMng)
|
||||||
|
projectMng.generate_project_file()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
moduleList=[]
|
||||||
|
__startModuleName="lutin_"
|
||||||
|
|
||||||
|
def import_path(path):
|
||||||
|
global moduleList
|
||||||
|
matches = []
|
||||||
|
debug.debug('MODULE: Start find sub File : "%s"' %path)
|
||||||
|
for root, dirnames, filenames in os.walk(path):
|
||||||
|
tmpList = fnmatch.filter(filenames, __startModuleName + "*.py")
|
||||||
|
# Import the module :
|
||||||
|
for filename in tmpList:
|
||||||
|
debug.debug('Module: 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', '')
|
||||||
|
moduleName = moduleName.replace(__startModuleName, '')
|
||||||
|
debug.debug("MODULE: Integrate module: '" + moduleName + "' from '" + os.path.join(root, filename) + "'")
|
||||||
|
moduleList.append([moduleName,os.path.join(root, filename)])
|
||||||
|
|
||||||
|
def exist(target, name):
|
||||||
|
global moduleList
|
||||||
|
for mod in moduleList:
|
||||||
|
if mod[0] == name:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def load_module(target, name):
|
||||||
|
global moduleList
|
||||||
|
for mod in moduleList:
|
||||||
|
if mod[0] == name:
|
||||||
|
sys.path.append(os.path.dirname(mod[1]))
|
||||||
|
debug.verbose("import module : '" + __startModuleName + name + "'")
|
||||||
|
theModule = __import__(__startModuleName + name)
|
||||||
|
#try:
|
||||||
|
tmpElement = theModule.create(target)
|
||||||
|
#except:
|
||||||
|
#tmpElement = None
|
||||||
|
#debug.warning(" no function 'create' in the module : " + mod[0] + " from:'" + mod[1] + "'")
|
||||||
|
if (tmpElement == None) :
|
||||||
|
debug.debug("Request load module '" + name + "' not define for this platform")
|
||||||
|
else:
|
||||||
|
target.add_module(tmpElement)
|
||||||
|
|
||||||
|
def list_all_module():
|
||||||
|
global moduleList
|
||||||
|
tmpListName = []
|
||||||
|
for mod in moduleList:
|
||||||
|
tmpListName.append(mod[0])
|
||||||
|
return tmpListName
|
||||||
|
|
||||||
|
def list_all_module_with_desc():
|
||||||
|
global moduleList
|
||||||
|
tmpList = []
|
||||||
|
for mod in moduleList:
|
||||||
|
sys.path.append(os.path.dirname(mod[1]))
|
||||||
|
theModule = __import__("lutin_" + mod[0])
|
||||||
|
try:
|
||||||
|
tmpdesc = theModule.get_desc()
|
||||||
|
tmpList.append([mod[0], tmpdesc])
|
||||||
|
except:
|
||||||
|
debug.warning("has no naeme : " + mod[0])
|
||||||
|
tmpList.append([mod[0], ""])
|
||||||
|
return tmpList
|
||||||
|
|
||||||
|
|
277
lutin/multiprocess.py
Normal file
277
lutin/multiprocess.py
Normal file
@@ -0,0 +1,277 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
if sys.version_info >= (3, 0):
|
||||||
|
import queue
|
||||||
|
else:
|
||||||
|
import Queue as queue
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import shlex
|
||||||
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
import tools
|
||||||
|
from . import env
|
||||||
|
|
||||||
|
queueLock = threading.Lock()
|
||||||
|
workQueue = queue.Queue()
|
||||||
|
currentThreadWorking = 0
|
||||||
|
threads = []
|
||||||
|
# To know the first error arrive in the pool ==> to display all the time the same error file when multiple compilation
|
||||||
|
currentIdExecution = 0
|
||||||
|
errorExecution = {
|
||||||
|
"id":-1,
|
||||||
|
"cmd":"",
|
||||||
|
"return":0,
|
||||||
|
"err":"",
|
||||||
|
"out":"",
|
||||||
|
}
|
||||||
|
|
||||||
|
exitFlag = False # resuest stop of the thread
|
||||||
|
isinit = False # the thread are initialized
|
||||||
|
errorOccured = False # a thread have an error
|
||||||
|
processorAvaillable = 1 # number of CPU core availlable
|
||||||
|
|
||||||
|
def store_command(cmdLine, file):
|
||||||
|
# write cmd line only after to prevent errors ...
|
||||||
|
if file != "" \
|
||||||
|
and file != None:
|
||||||
|
# Create directory:
|
||||||
|
tools.create_directory_of_file(file)
|
||||||
|
# Store the command Line:
|
||||||
|
file2 = open(file, "w")
|
||||||
|
file2.write(cmdLine)
|
||||||
|
file2.flush()
|
||||||
|
file2.close()
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Execute the command and ruturn generate data
|
||||||
|
##
|
||||||
|
def run_command_direct(cmdLine):
|
||||||
|
# prepare command line:
|
||||||
|
args = shlex.split(cmdLine)
|
||||||
|
debug.verbose("cmd = " + str(args))
|
||||||
|
try:
|
||||||
|
# create the subprocess
|
||||||
|
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
debug.error("subprocess.CalledProcessError : " + str(args))
|
||||||
|
# launch the subprocess:
|
||||||
|
output, err = p.communicate()
|
||||||
|
if sys.version_info >= (3, 0):
|
||||||
|
output = output.decode("utf-8")
|
||||||
|
err = err.decode("utf-8")
|
||||||
|
# Check error :
|
||||||
|
if p.returncode == 0:
|
||||||
|
if output == None:
|
||||||
|
return err[:-1];
|
||||||
|
return output[:-1];
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def run_command(cmdLine, storeCmdLine="", buildId=-1, file=""):
|
||||||
|
global errorOccured
|
||||||
|
global exitFlag
|
||||||
|
global currentIdExecution
|
||||||
|
# prepare command line:
|
||||||
|
args = shlex.split(cmdLine)
|
||||||
|
debug.verbose("cmd = " + str(args))
|
||||||
|
try:
|
||||||
|
# create the subprocess
|
||||||
|
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
debug.error("subprocess.CalledProcessError : TODO ...")
|
||||||
|
# launch the subprocess:
|
||||||
|
output, err = p.communicate()
|
||||||
|
if sys.version_info >= (3, 0):
|
||||||
|
output = output.decode("utf-8")
|
||||||
|
err = err.decode("utf-8")
|
||||||
|
# Check error :
|
||||||
|
if p.returncode == 0:
|
||||||
|
debug.debug(env.print_pretty(cmdLine))
|
||||||
|
queueLock.acquire()
|
||||||
|
# TODO : Print the output all the time .... ==> to show warnings ...
|
||||||
|
if buildId >= 0 and (output != "" or err != ""):
|
||||||
|
debug.warning("output in subprocess compiling: '" + file + "'")
|
||||||
|
if output != "":
|
||||||
|
debug.print_compilator(output)
|
||||||
|
if err != "":
|
||||||
|
debug.print_compilator(err)
|
||||||
|
queueLock.release()
|
||||||
|
else:
|
||||||
|
errorOccured = True
|
||||||
|
exitFlag = True
|
||||||
|
# if No ID : Not in a multiprocess mode ==> just stop here
|
||||||
|
if buildId < 0:
|
||||||
|
debug.debug(env.print_pretty(cmdLine), force=True)
|
||||||
|
debug.print_compilator(output)
|
||||||
|
debug.print_compilator(err)
|
||||||
|
if p.returncode == 2:
|
||||||
|
debug.error("can not compile file ... [keyboard interrrupt]")
|
||||||
|
else:
|
||||||
|
debug.error("can not compile file ... ret : " + str(p.returncode))
|
||||||
|
else:
|
||||||
|
# in multiprocess interface
|
||||||
|
queueLock.acquire()
|
||||||
|
# if an other write an error before, check if the current process is started before ==> then is the first error
|
||||||
|
if errorExecution["id"] >= buildId:
|
||||||
|
# nothing to do ...
|
||||||
|
queueLock.release()
|
||||||
|
return;
|
||||||
|
errorExecution["id"] = buildId
|
||||||
|
errorExecution["cmd"] = cmdLine
|
||||||
|
errorExecution["return"] = p.returncode
|
||||||
|
errorExecution["err"] = err,
|
||||||
|
errorExecution["out"] = output,
|
||||||
|
queueLock.release()
|
||||||
|
# not write the command file...
|
||||||
|
return
|
||||||
|
debug.verbose("done 3")
|
||||||
|
# write cmd line only after to prevent errors ...
|
||||||
|
store_command(cmdLine, storeCmdLine)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class myThread(threading.Thread):
|
||||||
|
def __init__(self, threadID, lock, queue):
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
self.threadID = threadID
|
||||||
|
self.name = "Thread " + str(threadID)
|
||||||
|
self.queue = queue
|
||||||
|
self.lock = lock
|
||||||
|
def run(self):
|
||||||
|
debug.verbose("Starting " + self.name)
|
||||||
|
global exitFlag
|
||||||
|
global currentThreadWorking
|
||||||
|
workingSet = False
|
||||||
|
while exitFlag == False:
|
||||||
|
self.lock.acquire()
|
||||||
|
if not self.queue.empty():
|
||||||
|
if workingSet==False:
|
||||||
|
currentThreadWorking += 1
|
||||||
|
workingSet = True
|
||||||
|
data = self.queue.get()
|
||||||
|
self.lock.release()
|
||||||
|
debug.verbose(self.name + " processing '" + data[0] + "'")
|
||||||
|
if data[0]=="cmdLine":
|
||||||
|
comment = data[2]
|
||||||
|
cmdLine = data[1]
|
||||||
|
cmdStoreFile = data[3]
|
||||||
|
debug.print_element( "[" + str(data[4]) + "][" + str(self.threadID) + "] " + comment[0], comment[1], comment[2], comment[3])
|
||||||
|
run_command(cmdLine, cmdStoreFile, buildId=data[4], file=comment[3])
|
||||||
|
else:
|
||||||
|
debug.warning("unknow request command : " + data[0])
|
||||||
|
else:
|
||||||
|
if workingSet==True:
|
||||||
|
currentThreadWorking -= 1
|
||||||
|
workingSet=False
|
||||||
|
# no element to parse, just wait ...
|
||||||
|
self.lock.release()
|
||||||
|
time.sleep(0.2)
|
||||||
|
# kill requested ...
|
||||||
|
debug.verbose("Exiting " + self.name)
|
||||||
|
|
||||||
|
|
||||||
|
def error_occured():
|
||||||
|
global exitFlag
|
||||||
|
exitFlag = True
|
||||||
|
|
||||||
|
def set_core_number(numberOfcore):
|
||||||
|
global processorAvaillable
|
||||||
|
processorAvaillable = numberOfcore
|
||||||
|
debug.debug(" set number of core for multi process compilation : " + str(processorAvaillable))
|
||||||
|
# nothing else to do
|
||||||
|
|
||||||
|
def init():
|
||||||
|
global exitFlag
|
||||||
|
global isinit
|
||||||
|
if isinit==False:
|
||||||
|
isinit=True
|
||||||
|
global threads
|
||||||
|
global queueLock
|
||||||
|
global workQueue
|
||||||
|
# Create all the new threads
|
||||||
|
threadID = 0
|
||||||
|
while threadID < processorAvaillable:
|
||||||
|
thread = myThread(threadID, queueLock, workQueue)
|
||||||
|
thread.start()
|
||||||
|
threads.append(thread)
|
||||||
|
threadID += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def un_init():
|
||||||
|
global exitFlag
|
||||||
|
# Notify threads it's time to exit
|
||||||
|
exitFlag = True
|
||||||
|
if processorAvaillable > 1:
|
||||||
|
# Wait for all threads to complete
|
||||||
|
for tmp in threads:
|
||||||
|
debug.verbose("join thread ...")
|
||||||
|
tmp.join()
|
||||||
|
debug.verbose("Exiting ALL Threads")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def run_in_pool(cmdLine, comment, storeCmdLine=""):
|
||||||
|
global currentIdExecution
|
||||||
|
if processorAvaillable <= 1:
|
||||||
|
debug.print_element(comment[0], comment[1], comment[2], comment[3])
|
||||||
|
run_command(cmdLine, storeCmdLine, file=comment[3])
|
||||||
|
return
|
||||||
|
# multithreaded mode
|
||||||
|
init()
|
||||||
|
# Fill the queue
|
||||||
|
queueLock.acquire()
|
||||||
|
debug.verbose("add : in pool cmdLine")
|
||||||
|
workQueue.put(["cmdLine", cmdLine, comment, storeCmdLine, currentIdExecution])
|
||||||
|
currentIdExecution +=1;
|
||||||
|
queueLock.release()
|
||||||
|
|
||||||
|
|
||||||
|
def pool_synchrosize():
|
||||||
|
global errorOccured
|
||||||
|
global errorExecution
|
||||||
|
if processorAvaillable <= 1:
|
||||||
|
#in this case : nothing to synchronise
|
||||||
|
return
|
||||||
|
|
||||||
|
debug.verbose("wait queue process ended\n")
|
||||||
|
# Wait for queue to empty
|
||||||
|
while not workQueue.empty() \
|
||||||
|
and False==errorOccured:
|
||||||
|
time.sleep(0.2)
|
||||||
|
pass
|
||||||
|
# Wait all thread have ended their current process
|
||||||
|
while currentThreadWorking != 0 \
|
||||||
|
and False==errorOccured:
|
||||||
|
time.sleep(0.2)
|
||||||
|
pass
|
||||||
|
if False==errorOccured:
|
||||||
|
debug.verbose("queue is empty")
|
||||||
|
else:
|
||||||
|
un_init()
|
||||||
|
debug.debug("Thread return with error ... ==> stop all the pool")
|
||||||
|
if errorExecution["id"] == -1:
|
||||||
|
debug.error("Pool error occured ... (No return information on Pool)")
|
||||||
|
return
|
||||||
|
debug.error("Error in an pool element : [" + str(errorExecution["id"]) + "]", crash=False)
|
||||||
|
debug.debug(env.print_pretty(errorExecution["cmd"]), force=True)
|
||||||
|
debug.print_compilator(str(errorExecution["out"][0]))
|
||||||
|
debug.print_compilator(str(errorExecution["err"][0]))
|
||||||
|
if errorExecution["return"] == 2:
|
||||||
|
debug.error("can not compile file ... [keyboard interrrupt]")
|
||||||
|
else:
|
||||||
|
debug.error("can not compile file ... return value : " + str(errorExecution["return"]))
|
||||||
|
|
161
lutin/system.py
Normal file
161
lutin/system.py
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import inspect
|
||||||
|
import fnmatch
|
||||||
|
import datetime
|
||||||
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
from . import module
|
||||||
|
|
||||||
|
class System:
|
||||||
|
def __init__(self):
|
||||||
|
self.valid=False;
|
||||||
|
self.help="";
|
||||||
|
self.include_cc=[]
|
||||||
|
self.export_flags_cc=[]
|
||||||
|
self.export_flags_xx=[]
|
||||||
|
self.export_flags_mm=[]
|
||||||
|
self.export_flags_m=[]
|
||||||
|
self.export_flags_ar=[]
|
||||||
|
self.export_flags_ld=[]
|
||||||
|
self.export_flags_ld_shared=[]
|
||||||
|
self.export_libs_ld=[]
|
||||||
|
self.export_libs_ld_shared=[]
|
||||||
|
|
||||||
|
def append_and_check(self, listout, newElement, order):
|
||||||
|
for element in listout:
|
||||||
|
if element==newElement:
|
||||||
|
return
|
||||||
|
listout.append(newElement)
|
||||||
|
if True==order:
|
||||||
|
listout.sort()
|
||||||
|
|
||||||
|
def append_to_internalList(self, listout, list, order=False):
|
||||||
|
if type(list) == type(str()):
|
||||||
|
self.append_and_check(listout, list, order)
|
||||||
|
else:
|
||||||
|
# mulyiple imput in the list ...
|
||||||
|
for elem in list:
|
||||||
|
self.append_and_check(listout, elem, order)
|
||||||
|
|
||||||
|
def add_export_flag_LD(self, list):
|
||||||
|
self.append_to_internalList(self.export_flags_ld, list)
|
||||||
|
|
||||||
|
def add_export_flag_CC(self, list):
|
||||||
|
self.append_to_internalList(self.export_flags_cc, list)
|
||||||
|
|
||||||
|
def add_export_flag_XX(self, list):
|
||||||
|
self.append_to_internalList(self.export_flags_xx, list)
|
||||||
|
|
||||||
|
def add_export_flag_M(self, list):
|
||||||
|
self.append_to_internalList(self.export_flags_m, list)
|
||||||
|
|
||||||
|
def add_export_flag_MM(self, list):
|
||||||
|
self.append_to_internalList(self.export_flags_mm, list)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def createModuleFromSystem(target, dict):
|
||||||
|
myModule = module.Module(dict["path"], dict["name"], 'PREBUILD')
|
||||||
|
|
||||||
|
myModule.add_export_flag('c', dict["system"].export_flags_cc)
|
||||||
|
myModule.add_export_flag('link', dict["system"].export_flags_ld)
|
||||||
|
myModule.add_export_flag('c++', dict["system"].export_flags_xx)
|
||||||
|
myModule.add_export_flag('m', dict["system"].export_flags_m)
|
||||||
|
myModule.add_export_flag('mm', dict["system"].export_flags_mm)
|
||||||
|
# add the currrent module at the
|
||||||
|
return myModule
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Dictionnaire of Target name
|
||||||
|
# inside table of ["Name of the lib", "path of the lib", boolean loaded, module loaded]
|
||||||
|
systemList={}
|
||||||
|
__startSystemName="lutinSystem_"
|
||||||
|
|
||||||
|
|
||||||
|
def import_path(path):
|
||||||
|
global targetList
|
||||||
|
matches = []
|
||||||
|
debug.debug('Start find sub File : "%s"' %path)
|
||||||
|
for root, dirnames, filenames in os.walk(path):
|
||||||
|
tmpList = fnmatch.filter(filenames, __startSystemName + "*.py")
|
||||||
|
# Import the module :
|
||||||
|
for filename in tmpList:
|
||||||
|
debug.verbose(' Find a file : "%s"' %os.path.join(root, filename))
|
||||||
|
sys.path.append(os.path.dirname(os.path.join(root, filename)) )
|
||||||
|
systemName = filename.replace('.py', '')
|
||||||
|
systemName = systemName.replace(__startSystemName, '')
|
||||||
|
targetType, systemName = systemName.split('_')
|
||||||
|
debug.debug("integrate system: '" + targetType + "':'" + systemName + "' from '" + os.path.join(root, filename) + "'")
|
||||||
|
if targetType in systemList:
|
||||||
|
systemList[targetType].append({"name":systemName,
|
||||||
|
"path":os.path.join(root, filename),
|
||||||
|
"system":None,
|
||||||
|
"loaded":False,
|
||||||
|
"exist":False,
|
||||||
|
"module":None})
|
||||||
|
else:
|
||||||
|
systemList[targetType] = [{"name":systemName,
|
||||||
|
"path":os.path.join(root, filename),
|
||||||
|
"system":None,
|
||||||
|
"loaded":False,
|
||||||
|
"exist":False,
|
||||||
|
"module":None}]
|
||||||
|
|
||||||
|
def display():
|
||||||
|
global systemList
|
||||||
|
for elementName in systemList:
|
||||||
|
debug.info("integrate system: '" + elementName +"'")
|
||||||
|
for data in systemList[elementName]:
|
||||||
|
debug.info(" '" + data["name"] +"' in " + data["path"])
|
||||||
|
|
||||||
|
|
||||||
|
def exist(lib_name, target_name) :
|
||||||
|
global systemList
|
||||||
|
if target_name not in systemList:
|
||||||
|
return False
|
||||||
|
for data in systemList[target_name]:
|
||||||
|
if data["name"] == lib_name:
|
||||||
|
# we find it in the List ==> need to check if it is present in the system :
|
||||||
|
if data["loaded"] == False:
|
||||||
|
debug.verbose("add to path: '" + os.path.dirname(data["path"]) + "'")
|
||||||
|
sys.path.append(os.path.dirname(data["path"]))
|
||||||
|
debug.verbose("import system : '" + data["name"] + "'")
|
||||||
|
theSystem = __import__(__startSystemName + target_name + "_" + data["name"])
|
||||||
|
#create the system module
|
||||||
|
try:
|
||||||
|
data["system"] = theSystem.System()
|
||||||
|
data["exist"] = data["system"].valid
|
||||||
|
except:
|
||||||
|
debug.debug("Not find: '" + data["name"] + "'")
|
||||||
|
return data["exist"]
|
||||||
|
return False
|
||||||
|
|
||||||
|
def load(target, lib_name, target_name):
|
||||||
|
global systemList
|
||||||
|
if target_name not in systemList:
|
||||||
|
debug.error("you must call this function after checking of the system exist() !1!")
|
||||||
|
for data in systemList[target_name]:
|
||||||
|
if data["name"] == lib_name:
|
||||||
|
if data["exist"] == False:
|
||||||
|
debug.error("you must call this function after checking of the system exist() !2!")
|
||||||
|
if data["module"] == None:
|
||||||
|
# create a module from the system interface...
|
||||||
|
data["module"] = createModuleFromSystem(target, data)
|
||||||
|
data["loaded"] = True
|
||||||
|
target.add_module(data["module"])
|
||||||
|
return
|
||||||
|
|
25
lutin/system/lutinSystem_IOs_CoreAudio.py
Normal file
25
lutin/system/lutinSystem_IOs_CoreAudio.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="CoreAudio : Ios interface for audio (all time present, just system interface)"
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_LD("-framework CoreAudio")
|
||||||
|
self.add_export_flag_LD("-framework AudioToolbox")
|
||||||
|
|
||||||
|
|
29
lutin/system/lutinSystem_Linux_alsa.py
Normal file
29
lutin/system/lutinSystem_Linux_alsa.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="ALSA : Advanced Linux Sound Architecture\n Can be install with the package:\n - libasound2-dev"
|
||||||
|
# check if the library exist:
|
||||||
|
if not os.path.isfile("/usr/include/alsa/asoundlib.h") \
|
||||||
|
and not os.path.isfile("/usr/include/dssi/alsa/asoundlib.h"):
|
||||||
|
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||||
|
return;
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_LD("-lasound")
|
||||||
|
|
||||||
|
|
33
lutin/system/lutinSystem_Linux_boost.py
Normal file
33
lutin/system/lutinSystem_Linux_boost.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="BOOST : Boost interface (need when we have not all c++ feature\n Can be install with the package:\n - libboost-all-dev"
|
||||||
|
# check if the library exist:
|
||||||
|
if not os.path.isfile("/usr/include/boost/chrono.hpp"):
|
||||||
|
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||||
|
return;
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_LD([
|
||||||
|
"-lboost_system",
|
||||||
|
"-lboost_thread",
|
||||||
|
"-lboost_chrono"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
28
lutin/system/lutinSystem_Linux_jack.py
Normal file
28
lutin/system/lutinSystem_Linux_jack.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="JACK : Jack Low-Latency Audio Server\n Can be install with the package:\n - libjack-jackd2-dev (new)\n - libjack-dev (old)"
|
||||||
|
# check if the library exist:
|
||||||
|
if not os.path.isfile("/usr/include/jack/jack.h"):
|
||||||
|
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||||
|
return;
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_LD("-ljack")
|
||||||
|
|
||||||
|
|
30
lutin/system/lutinSystem_Linux_oss.py
Normal file
30
lutin/system/lutinSystem_Linux_oss.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="OSS : Linux Open Sound System\n Can be install with the package:\n - ... TODO ..."
|
||||||
|
# check if the library exist:
|
||||||
|
"""
|
||||||
|
if not os.path.isfile("/usr/include/jack/jack.h"):
|
||||||
|
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||||
|
return;
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_CC("-ljack")
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
28
lutin/system/lutinSystem_Linux_pulse.py
Normal file
28
lutin/system/lutinSystem_Linux_pulse.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="PULSE : The Linux PulseAudio\n Can be install with the package:\n - libpulse-dev"
|
||||||
|
# check if the library exist:
|
||||||
|
if not os.path.isfile("/usr/include/pulse/pulseaudio.h"):
|
||||||
|
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||||
|
return;
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_LD(["-lpulse-simple", "-lpulse"])
|
||||||
|
|
||||||
|
|
28
lutin/system/lutinSystem_Linux_z.py
Normal file
28
lutin/system/lutinSystem_Linux_z.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="Z : z library \n Can be install with the package:\n - zlib1g-dev"
|
||||||
|
# check if the library exist:
|
||||||
|
if not os.path.isfile("/usr/include/zlib.h"):
|
||||||
|
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||||
|
return;
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_LD(["-lz"])
|
||||||
|
|
||||||
|
|
24
lutin/system/lutinSystem_MacOs_CoreAudio.py
Normal file
24
lutin/system/lutinSystem_MacOs_CoreAudio.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="CoreAudio : MacOs interface for audio (all time present, just system interface)"
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_LD("-framework CoreAudio")
|
||||||
|
self.add_export_flag_LD("-framework CoreFoundation")
|
||||||
|
|
0
lutin/system/lutinSystem_Windows_asio.py
Normal file
0
lutin/system/lutinSystem_Windows_asio.py
Normal file
31
lutin/system/lutinSystem_Windows_ds.py
Normal file
31
lutin/system/lutinSystem_Windows_ds.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import system
|
||||||
|
from lutin import tools
|
||||||
|
import os
|
||||||
|
|
||||||
|
class System(system.System):
|
||||||
|
def __init__(self):
|
||||||
|
system.System.__init__(self)
|
||||||
|
# create some HELP:
|
||||||
|
self.help="DirectSound : Direct sound API for windows audio interface"
|
||||||
|
# check if the library exist:
|
||||||
|
if not os.path.isfile("/usr/i686-w64-mingw32/include/dsound.h"):
|
||||||
|
# we did not find the library reqiested (just return) (automaticly set at false)
|
||||||
|
return;
|
||||||
|
self.valid = True
|
||||||
|
# todo : create a searcher of the presence of the library:
|
||||||
|
self.add_export_flag_LD(["-ldsound",
|
||||||
|
"-lwinmm",
|
||||||
|
"-lole32"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
460
lutin/target.py
Normal file
460
lutin/target.py
Normal file
@@ -0,0 +1,460 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import inspect
|
||||||
|
import fnmatch
|
||||||
|
import datetime
|
||||||
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
from . import heritage
|
||||||
|
from . import tools
|
||||||
|
from . import module
|
||||||
|
from . import system
|
||||||
|
from . import image
|
||||||
|
from . import multiprocess
|
||||||
|
|
||||||
|
class Target:
|
||||||
|
def __init__(self, name, config, arch):
|
||||||
|
self.config = config
|
||||||
|
|
||||||
|
#processor type selection (auto/arm/ppc/x86)
|
||||||
|
self.selectArch = config["arch"]; # TODO : Remove THIS ...
|
||||||
|
#bus size selection (auto/32/64)
|
||||||
|
self.selectBus = config["bus-size"]; # TODO : Remove THIS ...
|
||||||
|
|
||||||
|
if config["bus-size"] == "auto":
|
||||||
|
debug.error("system error ==> must generate the default 'bus-size' config")
|
||||||
|
if config["arch"] == "auto":
|
||||||
|
debug.error("system error ==> must generate the default 'bus-size' config")
|
||||||
|
|
||||||
|
debug.debug("config=" + str(config))
|
||||||
|
if arch != "":
|
||||||
|
self.arch = "-arch " + arch
|
||||||
|
else:
|
||||||
|
self.arch = ""
|
||||||
|
|
||||||
|
# todo : remove this :
|
||||||
|
self.sumulator = config["simulation"]
|
||||||
|
self.name=name
|
||||||
|
self.endGeneratePackage = config["generate-package"]
|
||||||
|
debug.info("=================================");
|
||||||
|
debug.info("== Target='" + self.name + "' " + config["bus-size"] + " bits for arch '" + config["arch"] + "'");
|
||||||
|
debug.info("=================================");
|
||||||
|
|
||||||
|
self.set_cross_base()
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Target global variables.
|
||||||
|
###############################################################################
|
||||||
|
self.global_include_cc=[]
|
||||||
|
self.global_flags_cc=['-D__TARGET_OS__'+self.name,
|
||||||
|
'-D__TARGET_ARCH__'+self.selectArch,
|
||||||
|
'-D__TARGET_ADDR__'+self.selectBus + 'BITS',
|
||||||
|
'-D_REENTRANT']
|
||||||
|
|
||||||
|
self.global_flags_xx=[]
|
||||||
|
self.global_flags_mm=[]
|
||||||
|
if self.name == "Windows":
|
||||||
|
self.global_flags_xx=['-static-libgcc', '-static-libstdc++']
|
||||||
|
self.global_flags_mm=[]
|
||||||
|
self.global_flags_m=[]
|
||||||
|
self.global_flags_ar=['rcs']
|
||||||
|
self.global_flags_ld=[]
|
||||||
|
self.global_flags_ld_shared=[]
|
||||||
|
self.global_libs_ld=[]
|
||||||
|
self.global_libs_ld_shared=[]
|
||||||
|
|
||||||
|
self.global_sysroot=""
|
||||||
|
|
||||||
|
self.suffix_cmdLine='.cmd'
|
||||||
|
self.suffix_dependence='.d'
|
||||||
|
self.suffix_obj='.o'
|
||||||
|
self.suffix_lib_static='.a'
|
||||||
|
self.suffix_lib_dynamic='.so'
|
||||||
|
self.suffix_binary=''
|
||||||
|
self.suffix_package='.deb'
|
||||||
|
|
||||||
|
self.folder_arch="/" + self.name
|
||||||
|
|
||||||
|
if "debug" == self.config["mode"]:
|
||||||
|
self.global_flags_cc.append("-g")
|
||||||
|
self.global_flags_cc.append("-DDEBUG")
|
||||||
|
self.global_flags_cc.append("-O0")
|
||||||
|
else:
|
||||||
|
self.global_flags_cc.append("-DNDEBUG")
|
||||||
|
self.global_flags_cc.append("-O3")
|
||||||
|
|
||||||
|
## To add code coverate on build result system
|
||||||
|
if self.config["gcov"] == True:
|
||||||
|
self.global_flags_cc.append("-fprofile-arcs")
|
||||||
|
self.global_flags_cc.append("-ftest-coverage")
|
||||||
|
self.global_flags_ld.append("-fprofile-arcs")
|
||||||
|
self.global_flags_ld.append("-ftest-coverage")
|
||||||
|
|
||||||
|
self.update_folder_tree()
|
||||||
|
self.folder_bin="/usr/bin"
|
||||||
|
self.folder_lib="/usr/lib"
|
||||||
|
self.folder_data="/usr/share"
|
||||||
|
self.folder_doc="/usr/share/doc"
|
||||||
|
self.buildDone=[]
|
||||||
|
self.buildTreeDone=[]
|
||||||
|
self.moduleList=[]
|
||||||
|
# output staging files list :
|
||||||
|
self.listFinalFile=[]
|
||||||
|
|
||||||
|
self.sysroot=""
|
||||||
|
|
||||||
|
def update_folder_tree(self):
|
||||||
|
self.folder_out="/out/" + self.name + "_" + self.config["arch"] + "_" + self.config["bus-size"] + "/" + self.config["mode"]
|
||||||
|
self.folder_final="/final/" + self.config["compilator"]
|
||||||
|
self.folder_staging="/staging/" + self.config["compilator"]
|
||||||
|
self.folder_build="/build/" + self.config["compilator"]
|
||||||
|
|
||||||
|
def create_number_from_version_string(self, data):
|
||||||
|
list = data.split(".")
|
||||||
|
if len(list) == 1:
|
||||||
|
list.append("0")
|
||||||
|
if len(list) == 2:
|
||||||
|
list.append("0")
|
||||||
|
if len(list) > 3:
|
||||||
|
list = list[:3]
|
||||||
|
out = 0;
|
||||||
|
offset = 1000**(len(list)-1)
|
||||||
|
for elem in list:
|
||||||
|
out += offset*int(elem)
|
||||||
|
debug.verbose("get : " + str(int(elem)) + " tmp" + str(out))
|
||||||
|
offset /= 1000
|
||||||
|
return out
|
||||||
|
|
||||||
|
def set_cross_base(self, cross=""):
|
||||||
|
self.cross = cross
|
||||||
|
debug.debug("== Target='" + self.cross + "'");
|
||||||
|
self.ar = self.cross + "ar"
|
||||||
|
self.ranlib = self.cross + "ranlib"
|
||||||
|
if self.config["compilator"] == "clang":
|
||||||
|
self.cc = self.cross + "clang"
|
||||||
|
self.xx = self.cross + "clang++"
|
||||||
|
#self.ar=self.cross + "llvm-ar"
|
||||||
|
#self.ranlib="ls"
|
||||||
|
else:
|
||||||
|
self.cc = self.cross + "gcc"
|
||||||
|
self.xx = self.cross + "g++"
|
||||||
|
#self.ar=self.cross + "ar"
|
||||||
|
#self.ranlib=self.cross + "ranlib"
|
||||||
|
|
||||||
|
#get g++ compilation version :
|
||||||
|
ret = multiprocess.run_command_direct(self.xx + " -dumpversion");
|
||||||
|
if ret == False:
|
||||||
|
debug.error("Can not get the g++/clang++ version ...")
|
||||||
|
self.xx_version = self.create_number_from_version_string(ret)
|
||||||
|
debug.verbose(self.config["compilator"] + "++ version=" + str(ret) + " number=" + str(self.xx_version))
|
||||||
|
|
||||||
|
self.ld = self.cross + "ld"
|
||||||
|
self.nm = self.cross + "nm"
|
||||||
|
self.strip = self.cross + "strip"
|
||||||
|
self.dlltool = self.cross + "dlltool"
|
||||||
|
self.update_folder_tree()
|
||||||
|
|
||||||
|
def get_build_mode(self):
|
||||||
|
return self.config["mode"]
|
||||||
|
|
||||||
|
def add_image_staging(self, inputFile, outputFile, sizeX, sizeY, cmdFile=None):
|
||||||
|
for source, dst, x, y, cmdFile2 in self.listFinalFile:
|
||||||
|
if dst == outputFile :
|
||||||
|
debug.verbose("already added : " + outputFile)
|
||||||
|
return
|
||||||
|
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'")
|
||||||
|
self.listFinalFile.append([inputFile,outputFile, sizeX, sizeY, cmdFile])
|
||||||
|
|
||||||
|
def add_file_staging(self, inputFile, outputFile, cmdFile=None):
|
||||||
|
for source, dst, x, y, cmdFile2 in self.listFinalFile:
|
||||||
|
if dst == outputFile :
|
||||||
|
debug.verbose("already added : " + outputFile)
|
||||||
|
return
|
||||||
|
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'");
|
||||||
|
self.listFinalFile.append([inputFile, outputFile, -1, -1, cmdFile])
|
||||||
|
|
||||||
|
def copy_to_staging(self, binaryName):
|
||||||
|
baseFolder = self.get_staging_folder_data(binaryName)
|
||||||
|
for source, dst, x, y, cmdFile in self.listFinalFile:
|
||||||
|
if cmdFile != None \
|
||||||
|
and cmdFile != "":
|
||||||
|
debug.verbose("cmd file " + cmdFile)
|
||||||
|
if x == -1:
|
||||||
|
debug.verbose("must copy file : '" + source + "' ==> '" + dst + "'");
|
||||||
|
tools.copy_file(source, baseFolder+"/"+dst, cmdFile)
|
||||||
|
else:
|
||||||
|
debug.verbose("resize image : '" + source + "' ==> '" + dst + "' size=(" + str(x) + "," + str(y) + ")");
|
||||||
|
image.resize(source, baseFolder+"/"+dst, x, y, cmdFile)
|
||||||
|
|
||||||
|
|
||||||
|
def clean_module_tree(self):
|
||||||
|
self.buildTreeDone = []
|
||||||
|
self.listFinalFile = []
|
||||||
|
|
||||||
|
|
||||||
|
# TODO : Remove this hack ... ==> really bad ... but usefull
|
||||||
|
def set_ewol_folder(self, folder):
|
||||||
|
self.folder_ewol = folder
|
||||||
|
|
||||||
|
|
||||||
|
def file_generate_object(self,binaryName,moduleName,basePath,file):
|
||||||
|
list=[]
|
||||||
|
list.append(basePath + "/" + file)
|
||||||
|
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_obj)
|
||||||
|
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_dependence)
|
||||||
|
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_cmdLine)
|
||||||
|
return list
|
||||||
|
"""
|
||||||
|
return a list of 3 elements :
|
||||||
|
0 : sources files (can be a list)
|
||||||
|
1 : destination file
|
||||||
|
2 : dependence files module (*.d)
|
||||||
|
"""
|
||||||
|
def generate_file(self,binaryName,moduleName,basePath,file,type):
|
||||||
|
list=[]
|
||||||
|
if (type=="bin"):
|
||||||
|
list.append(file)
|
||||||
|
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_bin + "/" + moduleName + self.suffix_binary)
|
||||||
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
||||||
|
list.append(self.get_build_folder(binaryName) + "/" + self.folder_bin + "/" + moduleName + self.suffix_cmdLine)
|
||||||
|
elif (type=="lib-shared"):
|
||||||
|
list.append(file)
|
||||||
|
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_lib + "/" + moduleName + self.suffix_lib_dynamic)
|
||||||
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
||||||
|
list.append(self.get_build_folder(binaryName) + "/" + self.folder_lib + "/" + moduleName + self.suffix_cmdLine)
|
||||||
|
elif (type=="lib-static"):
|
||||||
|
list.append(file)
|
||||||
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_lib_static)
|
||||||
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
||||||
|
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_cmdLine)
|
||||||
|
elif (type=="image"):
|
||||||
|
list.append(self.get_build_folder(binaryName) + "/data/" + file + self.suffix_cmdLine)
|
||||||
|
else:
|
||||||
|
debug.error("unknow type : " + type)
|
||||||
|
return list
|
||||||
|
|
||||||
|
def get_final_folder(self):
|
||||||
|
return tools.get_run_folder() + self.folder_out + self.folder_final
|
||||||
|
|
||||||
|
def get_staging_folder(self, binaryName):
|
||||||
|
return tools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName
|
||||||
|
|
||||||
|
def get_staging_folder_data(self, binaryName):
|
||||||
|
return self.get_staging_folder(binaryName) + self.folder_data + "/" + binaryName
|
||||||
|
|
||||||
|
def get_build_folder(self, moduleName):
|
||||||
|
return tools.get_run_folder() + self.folder_out + self.folder_build + "/" + moduleName
|
||||||
|
|
||||||
|
def get_doc_folder(self, moduleName):
|
||||||
|
return tools.get_run_folder() + self.folder_out + self.folder_doc + "/" + moduleName
|
||||||
|
|
||||||
|
def is_module_build(self, my_module):
|
||||||
|
for mod in self.buildDone:
|
||||||
|
if mod == my_module:
|
||||||
|
return True
|
||||||
|
self.buildDone.append(my_module)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def is_module_buildTree(self, my_module):
|
||||||
|
for mod in self.buildTreeDone:
|
||||||
|
if mod == my_module:
|
||||||
|
return True
|
||||||
|
self.buildTreeDone.append(my_module)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def add_module(self, newModule):
|
||||||
|
debug.debug("Add 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 build_tree(self, name, packagesName):
|
||||||
|
for mod in self.moduleList:
|
||||||
|
if mod.name == name:
|
||||||
|
mod.build_tree(self, packagesName)
|
||||||
|
return
|
||||||
|
debug.error("request to build tree on un-existant module name : '" + name + "'")
|
||||||
|
|
||||||
|
def clean(self, name):
|
||||||
|
for mod in self.moduleList:
|
||||||
|
if mod.name == name:
|
||||||
|
mod.clean(self)
|
||||||
|
return
|
||||||
|
debug.error("request to clean an un-existant module name : '" + name + "'")
|
||||||
|
|
||||||
|
def load_if_needed(self, name, optionnal=False):
|
||||||
|
for elem in self.moduleList:
|
||||||
|
if elem.name == name:
|
||||||
|
return True
|
||||||
|
if optionnal == False:
|
||||||
|
module.load_module(self, name)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
# TODO : Check internal module and system module ...
|
||||||
|
# need to import the module (or the system module ...)
|
||||||
|
exist = system.exist(name, self.name)
|
||||||
|
if exist == True:
|
||||||
|
system.load(self, name, self.name)
|
||||||
|
return True;
|
||||||
|
# try to find in the local Modules:
|
||||||
|
exist = module.exist(self, name)
|
||||||
|
if exist == True:
|
||||||
|
module.load_module(self, name)
|
||||||
|
return True;
|
||||||
|
else:
|
||||||
|
return False;
|
||||||
|
|
||||||
|
def load_all(self):
|
||||||
|
listOfAllTheModule = module.list_all_module()
|
||||||
|
for modName in listOfAllTheModule:
|
||||||
|
self.load_if_needed(modName)
|
||||||
|
|
||||||
|
def project_add_module(self, name, projectMng, addedModule):
|
||||||
|
for mod in self.moduleList:
|
||||||
|
if mod.name == name:
|
||||||
|
mod.ext_project_add_module(self, projectMng, addedModule)
|
||||||
|
return
|
||||||
|
|
||||||
|
def build_optionnal(self, moduleName, packagesName=None):
|
||||||
|
present = self.load_if_needed(moduleName, optionnal=True)
|
||||||
|
if present == False:
|
||||||
|
return [heritage.HeritageList(), False]
|
||||||
|
# clean requested
|
||||||
|
for mod in self.moduleList:
|
||||||
|
if mod.name == moduleName:
|
||||||
|
debug.debug("build module '" + moduleName + "'")
|
||||||
|
return [mod.build(self, None), True]
|
||||||
|
debug.warning("not know module name : '" + moduleName + "' to '" + "build" + "' it")
|
||||||
|
return [heritage.HeritageList(), False]
|
||||||
|
|
||||||
|
def build(self, name, packagesName=None):
|
||||||
|
if name == "dump":
|
||||||
|
debug.info("dump all")
|
||||||
|
self.load_all()
|
||||||
|
for mod in self.moduleList:
|
||||||
|
mod.display(self)
|
||||||
|
return
|
||||||
|
if name == "all":
|
||||||
|
debug.info("build all")
|
||||||
|
self.load_all()
|
||||||
|
for mod in self.moduleList:
|
||||||
|
if self.name=="Android":
|
||||||
|
if mod.type == "PACKAGE":
|
||||||
|
mod.build(self, None)
|
||||||
|
else:
|
||||||
|
if mod.type == "BINARY" \
|
||||||
|
or mod.type == "PACKAGE":
|
||||||
|
mod.build(self, None)
|
||||||
|
elif name == "clean":
|
||||||
|
debug.info("clean all")
|
||||||
|
self.load_all()
|
||||||
|
for mod in self.moduleList:
|
||||||
|
mod.clean(self)
|
||||||
|
else:
|
||||||
|
# get the action an the module ....
|
||||||
|
gettedElement = name.split("?")
|
||||||
|
moduleName = gettedElement[0]
|
||||||
|
if len(gettedElement)>=2:
|
||||||
|
actionName = gettedElement[1]
|
||||||
|
else :
|
||||||
|
actionName = "build"
|
||||||
|
debug.verbose("requested : " + moduleName + "-" + actionName)
|
||||||
|
if actionName == "install":
|
||||||
|
self.build(moduleName + "?build")
|
||||||
|
self.install_package(moduleName)
|
||||||
|
elif actionName == "uninstall":
|
||||||
|
self.un_install_package(moduleName)
|
||||||
|
elif actionName == "log":
|
||||||
|
self.Log(moduleName)
|
||||||
|
else:
|
||||||
|
self.load_if_needed(moduleName)
|
||||||
|
# clean requested
|
||||||
|
for mod in self.moduleList:
|
||||||
|
if mod.name == moduleName:
|
||||||
|
if actionName == "dump":
|
||||||
|
debug.info("dump module '" + moduleName + "'")
|
||||||
|
return mod.display(self)
|
||||||
|
elif actionName == "clean":
|
||||||
|
debug.info("clean module '" + moduleName + "'")
|
||||||
|
return mod.clean(self)
|
||||||
|
elif actionName == "build":
|
||||||
|
debug.debug("build module '" + moduleName + "'")
|
||||||
|
return mod.build(self, None)
|
||||||
|
debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it")
|
||||||
|
|
||||||
|
|
||||||
|
targetList=[]
|
||||||
|
__startTargetName="lutinTarget_"
|
||||||
|
|
||||||
|
|
||||||
|
def import_path(path):
|
||||||
|
global targetList
|
||||||
|
matches = []
|
||||||
|
debug.debug('TARGET: Start find sub File : "%s"' %path)
|
||||||
|
for root, dirnames, filenames in os.walk(path):
|
||||||
|
tmpList = fnmatch.filter(filenames, __startTargetName + "*.py")
|
||||||
|
# Import the module :
|
||||||
|
for filename in tmpList:
|
||||||
|
debug.debug('TARGET: 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)) )
|
||||||
|
targetName = filename.replace('.py', '')
|
||||||
|
targetName = targetName.replace(__startTargetName, '')
|
||||||
|
debug.debug("TARGET: integrate module: '" + targetName + "' from '" + os.path.join(root, filename) + "'")
|
||||||
|
targetList.append([targetName,os.path.join(root, filename)])
|
||||||
|
|
||||||
|
|
||||||
|
def load_target(name, config):
|
||||||
|
global targetList
|
||||||
|
debug.debug("load target: " + name)
|
||||||
|
if len(targetList) == 0:
|
||||||
|
debug.error("No target to compile !!!")
|
||||||
|
debug.debug("list target: " + str(targetList))
|
||||||
|
for mod in targetList:
|
||||||
|
if mod[0] == name:
|
||||||
|
debug.verbose("add to path: '" + os.path.dirname(mod[1]) + "'")
|
||||||
|
sys.path.append(os.path.dirname(mod[1]))
|
||||||
|
debug.verbose("import target : '" + __startTargetName + name + "'")
|
||||||
|
theTarget = __import__(__startTargetName + name)
|
||||||
|
#create the target
|
||||||
|
tmpTarget = theTarget.Target(config)
|
||||||
|
return tmpTarget
|
||||||
|
raise KeyError("No entry for : " + name)
|
||||||
|
|
||||||
|
def list_all_target():
|
||||||
|
global targetList
|
||||||
|
tmpListName = []
|
||||||
|
for mod in targetList:
|
||||||
|
tmpListName.append(mod[0])
|
||||||
|
return tmpListName
|
||||||
|
|
||||||
|
def list_all_target_with_desc():
|
||||||
|
global targetList
|
||||||
|
tmpList = []
|
||||||
|
for mod in targetList:
|
||||||
|
sys.path.append(os.path.dirname(mod[1]))
|
||||||
|
theTarget = __import__(__startTargetName + mod[0])
|
||||||
|
try:
|
||||||
|
tmpdesc = theTarget.get_desc()
|
||||||
|
tmpList.append([mod[0], tmpdesc])
|
||||||
|
except:
|
||||||
|
debug.warning("has no name : " + mod[0])
|
||||||
|
tmpList.append([mod[0], ""])
|
||||||
|
return tmpList
|
@@ -1,16 +1,33 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
import lutinDebug as debug
|
|
||||||
import lutinTarget
|
from lutin import debug
|
||||||
import lutinTools
|
from lutin import target
|
||||||
import lutinHost
|
from lutin import tools
|
||||||
import lutinImage
|
from lutin import image
|
||||||
import lutinMultiprocess
|
from lutin import multiprocess
|
||||||
|
from lutin import host
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class Target(lutinTarget.Target):
|
class Target(target.Target):
|
||||||
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
|
def __init__(self, config):
|
||||||
|
#processor type selection (auto/arm/ppc/x86)
|
||||||
|
if config["arch"] == "auto":
|
||||||
|
config["arch"] = "arm"
|
||||||
|
#bus size selection (auto/32/64)
|
||||||
|
if config["bus-size"] == "auto":
|
||||||
|
config["bus-size"] = "32"
|
||||||
|
|
||||||
|
arch = ""#"ARMv7"
|
||||||
|
target.Target.__init__(self, "Android", config, arch)
|
||||||
|
|
||||||
self.folder_ndk = os.getenv('PROJECT_NDK', "AUTO")
|
self.folder_ndk = os.getenv('PROJECT_NDK', "AUTO")
|
||||||
self.folder_sdk = os.getenv('PROJECT_SDK', "AUTO")
|
self.folder_sdk = os.getenv('PROJECT_SDK', "AUTO")
|
||||||
@@ -21,7 +38,7 @@ class Target(lutinTarget.Target):
|
|||||||
if folder=="android":
|
if folder=="android":
|
||||||
self.folder_ndk = folder + "/ndk"
|
self.folder_ndk = folder + "/ndk"
|
||||||
if self.folder_ndk == "AUTO":
|
if self.folder_ndk == "AUTO":
|
||||||
self.folder_ndk = lutinTools.get_run_folder() + "/../android/ndk"
|
self.folder_ndk = tools.get_run_folder() + "/../android/ndk"
|
||||||
# auto search SDK
|
# auto search SDK
|
||||||
if self.folder_sdk == "AUTO":
|
if self.folder_sdk == "AUTO":
|
||||||
for folder in os.listdir("."):
|
for folder in os.listdir("."):
|
||||||
@@ -29,25 +46,25 @@ class Target(lutinTarget.Target):
|
|||||||
if folder=="android":
|
if folder=="android":
|
||||||
self.folder_sdk = folder + "/sdk"
|
self.folder_sdk = folder + "/sdk"
|
||||||
if self.folder_sdk == "AUTO":
|
if self.folder_sdk == "AUTO":
|
||||||
self.folder_sdk = lutinTools.get_run_folder() + "/../android/sdk"
|
self.folder_sdk = tools.get_run_folder() + "/../android/sdk"
|
||||||
|
|
||||||
if not os.path.isdir(self.folder_ndk):
|
if not os.path.isdir(self.folder_ndk):
|
||||||
debug.error("NDK path not set !!! set env : PROJECT_NDK on the NDK path")
|
debug.error("NDK path not set !!! set env : PROJECT_NDK on the NDK path")
|
||||||
if not os.path.isdir(self.folder_sdk):
|
if not os.path.isdir(self.folder_sdk):
|
||||||
debug.error("SDK path not set !!! set env : PROJECT_SDK on the SDK path")
|
debug.error("SDK path not set !!! set env : PROJECT_SDK on the SDK path")
|
||||||
|
|
||||||
arch = ""#"ARMv7"
|
|
||||||
tmpOsVal = "64"
|
tmpOsVal = "64"
|
||||||
gccVersion = "4.8"
|
gccVersion = "4.9"
|
||||||
if lutinHost.OS64BITS==True:
|
if host.BUS_SIZE==64:
|
||||||
tmpOsVal = "_64"
|
tmpOsVal = "_64"
|
||||||
if typeCompilator == "clang":
|
if self.config["compilator"] == "clang":
|
||||||
cross = self.folder_ndk + "/toolchains/llvm-3.3/prebuilt/linux-x86_64/bin/"
|
self.set_cross_base(self.folder_ndk + "/toolchains/llvm-3.3/prebuilt/linux-x86_64/bin/")
|
||||||
else:
|
else:
|
||||||
baseFolderArm = self.folder_ndk + "/toolchains/arm-linux-androideabi-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
baseFolderArm = self.folder_ndk + "/toolchains/arm-linux-androideabi-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||||
baseFolderMips = self.folder_ndk + "/toolchains/mipsel-linux-android-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
baseFolderMips = self.folder_ndk + "/toolchains/mipsel-linux-android-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||||
baseFolderX86 = self.folder_ndk + "/toolchains/x86-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
baseFolderX86 = self.folder_ndk + "/toolchains/x86-" + gccVersion + "/prebuilt/linux-x86" + tmpOsVal + "/bin/"
|
||||||
cross = baseFolderArm + "arm-linux-androideabi-"
|
self.set_cross_base(baseFolderArm + "arm-linux-androideabi-")
|
||||||
if not os.path.isdir(baseFolderArm):
|
if not os.path.isdir(baseFolderArm):
|
||||||
debug.error("Gcc Arm path does not exist !!!")
|
debug.error("Gcc Arm path does not exist !!!")
|
||||||
if not os.path.isdir(baseFolderMips):
|
if not os.path.isdir(baseFolderMips):
|
||||||
@@ -55,7 +72,6 @@ class Target(lutinTarget.Target):
|
|||||||
if not os.path.isdir(baseFolderX86):
|
if not os.path.isdir(baseFolderX86):
|
||||||
debug.info("Gcc x86 path does not exist !!!")
|
debug.info("Gcc x86 path does not exist !!!")
|
||||||
|
|
||||||
lutinTarget.Target.__init__(self, "Android", typeCompilator, debugMode, generatePackage, arch, cross, sumulator)
|
|
||||||
arch = "ARMv7"
|
arch = "ARMv7"
|
||||||
# for gcc :
|
# for gcc :
|
||||||
|
|
||||||
@@ -78,7 +94,7 @@ class Target(lutinTarget.Target):
|
|||||||
self.global_include_cc.append("-I" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-x86/usr/include/")
|
self.global_include_cc.append("-I" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-x86/usr/include/")
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
if typeCompilator == "clang":
|
if self.config["compilator"] == "clang":
|
||||||
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/include/")
|
self.global_include_cc.append("-I" + self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/include/")
|
||||||
if arch == "ARMv5":
|
if arch == "ARMv5":
|
||||||
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/armeabi/"
|
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/armeabi/"
|
||||||
@@ -182,7 +198,7 @@ class Target(lutinTarget.Target):
|
|||||||
debug.info("Generate package '" + pkgName + "'")
|
debug.info("Generate package '" + pkgName + "'")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
pkgNameApplicationName = pkgName
|
pkgNameApplicationName = pkgName
|
||||||
if "debug"==self.buildMode:
|
if self.config["mode"] == "debug":
|
||||||
pkgNameApplicationName += "debug"
|
pkgNameApplicationName += "debug"
|
||||||
# FINAL_FOLDER_JAVA_PROJECT
|
# FINAL_FOLDER_JAVA_PROJECT
|
||||||
self.folder_javaProject= self.get_staging_folder(pkgName) \
|
self.folder_javaProject= self.get_staging_folder(pkgName) \
|
||||||
@@ -202,7 +218,7 @@ class Target(lutinTarget.Target):
|
|||||||
|
|
||||||
debug.print_element("pkg", "absractionFile", "<==", "dynamic file")
|
debug.print_element("pkg", "absractionFile", "<==", "dynamic file")
|
||||||
# Create folder :
|
# Create folder :
|
||||||
lutinTools.create_directory_of_file(self.file_finalAbstraction)
|
tools.create_directory_of_file(self.file_finalAbstraction)
|
||||||
# Create file :
|
# Create file :
|
||||||
tmpFile = open(self.file_finalAbstraction, 'w')
|
tmpFile = open(self.file_finalAbstraction, 'w')
|
||||||
if pkgProperties["ANDROID_APPL_TYPE"]=="APPL":
|
if pkgProperties["ANDROID_APPL_TYPE"]=="APPL":
|
||||||
@@ -314,10 +330,10 @@ class Target(lutinTarget.Target):
|
|||||||
tmpFile.flush()
|
tmpFile.flush()
|
||||||
tmpFile.close()
|
tmpFile.close()
|
||||||
|
|
||||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/drawable/icon.png");
|
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/drawable/icon.png");
|
||||||
if "ICON" in pkgProperties.keys() \
|
if "ICON" in pkgProperties.keys() \
|
||||||
and pkgProperties["ICON"] != "":
|
and pkgProperties["ICON"] != "":
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/res/drawable/icon.png", 256, 256)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/res/drawable/icon.png", 256, 256)
|
||||||
else:
|
else:
|
||||||
# to be sure that we have all time a resource ...
|
# to be sure that we have all time a resource ...
|
||||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/drawable/plop.txt", 'w')
|
tmpFile = open(self.get_staging_folder(pkgName) + "/res/drawable/plop.txt", 'w')
|
||||||
@@ -327,7 +343,7 @@ class Target(lutinTarget.Target):
|
|||||||
|
|
||||||
if pkgProperties["ANDROID_MANIFEST"]!="":
|
if pkgProperties["ANDROID_MANIFEST"]!="":
|
||||||
debug.print_element("pkg", "AndroidManifest.xml", "<==", pkgProperties["ANDROID_MANIFEST"])
|
debug.print_element("pkg", "AndroidManifest.xml", "<==", pkgProperties["ANDROID_MANIFEST"])
|
||||||
lutinTools.copy_file(pkgProperties["ANDROID_MANIFEST"], self.get_staging_folder(pkgName) + "/AndroidManifest.xml", force=True)
|
tools.copy_file(pkgProperties["ANDROID_MANIFEST"], self.get_staging_folder(pkgName) + "/AndroidManifest.xml", force=True)
|
||||||
else:
|
else:
|
||||||
if "VERSION_CODE" not in pkgProperties:
|
if "VERSION_CODE" not in pkgProperties:
|
||||||
pkgProperties["VERSION_CODE"] = "1"
|
pkgProperties["VERSION_CODE"] = "1"
|
||||||
@@ -346,7 +362,7 @@ class Target(lutinTarget.Target):
|
|||||||
tmpFile.write( ' <application android:label="' + pkgNameApplicationName + '" \n')
|
tmpFile.write( ' <application android:label="' + pkgNameApplicationName + '" \n')
|
||||||
if "ICON" in pkgProperties.keys():
|
if "ICON" in pkgProperties.keys():
|
||||||
tmpFile.write( ' android:icon="@drawable/icon" \n')
|
tmpFile.write( ' android:icon="@drawable/icon" \n')
|
||||||
if "debug"==self.buildMode:
|
if self.config["mode"] == "debug":
|
||||||
tmpFile.write( ' android:debuggable="true" \n')
|
tmpFile.write( ' android:debuggable="true" \n')
|
||||||
tmpFile.write( ' >\n')
|
tmpFile.write( ' >\n')
|
||||||
if "ADMOD_ID" in pkgProperties:
|
if "ADMOD_ID" in pkgProperties:
|
||||||
@@ -355,7 +371,7 @@ class Target(lutinTarget.Target):
|
|||||||
|
|
||||||
tmpFile.write( ' <activity android:name=".' + pkgNameApplicationName + '" \n')
|
tmpFile.write( ' <activity android:name=".' + pkgNameApplicationName + '" \n')
|
||||||
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
|
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
|
||||||
if "debug"==self.buildMode:
|
if self.config["mode"] == "debug":
|
||||||
tmpFile.write("-debug")
|
tmpFile.write("-debug")
|
||||||
tmpFile.write( '"\n')
|
tmpFile.write( '"\n')
|
||||||
if "ICON" in pkgProperties.keys():
|
if "ICON" in pkgProperties.keys():
|
||||||
@@ -380,7 +396,7 @@ class Target(lutinTarget.Target):
|
|||||||
tmpFile.write( ' >\n')
|
tmpFile.write( ' >\n')
|
||||||
tmpFile.write( ' <service android:name=".' + pkgNameApplicationName + '" \n')
|
tmpFile.write( ' <service android:name=".' + pkgNameApplicationName + '" \n')
|
||||||
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
|
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
|
||||||
if "debug"==self.buildMode:
|
if self.config["mode"] == "debug":
|
||||||
tmpFile.write("-debug")
|
tmpFile.write("-debug")
|
||||||
tmpFile.write( '"\n')
|
tmpFile.write( '"\n')
|
||||||
if "ICON" in pkgProperties.keys():
|
if "ICON" in pkgProperties.keys():
|
||||||
@@ -453,7 +469,7 @@ class Target(lutinTarget.Target):
|
|||||||
if pkgProperties["ANDROID_APPL_TYPE"]!="APPL":
|
if pkgProperties["ANDROID_APPL_TYPE"]!="APPL":
|
||||||
#create the Wallpaper sub files : (main element for the application
|
#create the Wallpaper sub files : (main element for the application
|
||||||
debug.print_element("pkg", pkgNameApplicationName + "_resource.xml", "<==", "package configurations")
|
debug.print_element("pkg", pkgNameApplicationName + "_resource.xml", "<==", "package configurations")
|
||||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_resource.xml")
|
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_resource.xml")
|
||||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_resource.xml", 'w')
|
tmpFile = open(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_resource.xml", 'w')
|
||||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||||
tmpFile.write( "<wallpaper xmlns:android=\"http://schemas.android.com/apk/res/android\"\n")
|
tmpFile.write( "<wallpaper xmlns:android=\"http://schemas.android.com/apk/res/android\"\n")
|
||||||
@@ -466,7 +482,7 @@ class Target(lutinTarget.Target):
|
|||||||
tmpFile.close()
|
tmpFile.close()
|
||||||
# create wallpaper setting if needed (class and config file)
|
# create wallpaper setting if needed (class and config file)
|
||||||
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
if len(pkgProperties["ANDROID_WALLPAPER_PROPERTIES"])!=0:
|
||||||
lutinTools.create_directory_of_file(self.folder_javaProject + pkgNameApplicationName + "Settings.java")
|
tools.create_directory_of_file(self.folder_javaProject + pkgNameApplicationName + "Settings.java")
|
||||||
debug.print_element("pkg", self.folder_javaProject + pkgNameApplicationName + "Settings.java", "<==", "package configurations")
|
debug.print_element("pkg", self.folder_javaProject + pkgNameApplicationName + "Settings.java", "<==", "package configurations")
|
||||||
tmpFile = open(self.folder_javaProject + pkgNameApplicationName + "Settings.java", 'w');
|
tmpFile = open(self.folder_javaProject + pkgNameApplicationName + "Settings.java", 'w');
|
||||||
tmpFile.write( "package " + compleatePackageName + ";\n")
|
tmpFile.write( "package " + compleatePackageName + ";\n")
|
||||||
@@ -498,7 +514,7 @@ class Target(lutinTarget.Target):
|
|||||||
tmpFile.close()
|
tmpFile.close()
|
||||||
|
|
||||||
debug.print_element("pkg", self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml", "<==", "package configurations")
|
debug.print_element("pkg", self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml", "<==", "package configurations")
|
||||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml")
|
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml")
|
||||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml", 'w');
|
tmpFile = open(self.get_staging_folder(pkgName) + "/res/xml/" + pkgNameApplicationName + "_settings.xml", 'w');
|
||||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||||
tmpFile.write( "<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\"\n")
|
tmpFile.write( "<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\"\n")
|
||||||
@@ -529,7 +545,7 @@ class Target(lutinTarget.Target):
|
|||||||
for WALL_type, WALL_key, WALL_title, WALL_summary, WALL_other in pkgProperties["ANDROID_WALLPAPER_PROPERTIES"]:
|
for WALL_type, WALL_key, WALL_title, WALL_summary, WALL_other in pkgProperties["ANDROID_WALLPAPER_PROPERTIES"]:
|
||||||
if WALL_type == "list":
|
if WALL_type == "list":
|
||||||
debug.print_element("pkg", self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml", "<==", "package configurations")
|
debug.print_element("pkg", self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml", "<==", "package configurations")
|
||||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml")
|
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml")
|
||||||
tmpFile = open(self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml", 'w');
|
tmpFile = open(self.get_staging_folder(pkgName) + "/res/values/" + WALL_key + ".xml", 'w');
|
||||||
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
tmpFile.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||||
tmpFile.write( "<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n")
|
tmpFile.write( "<resources xmlns:xliff=\"urn:oasis:names:tc:xliff:document:1.2\">\n")
|
||||||
@@ -555,14 +571,20 @@ class Target(lutinTarget.Target):
|
|||||||
for res_source, res_dest in pkgProperties["ANDROID_RESOURCES"]:
|
for res_source, res_dest in pkgProperties["ANDROID_RESOURCES"]:
|
||||||
if res_source == "":
|
if res_source == "":
|
||||||
continue
|
continue
|
||||||
lutinTools.copy_file(res_source , self.get_staging_folder(pkgName) + "/res/" + res_dest + "/" + os.path.basename(res_source), force=True)
|
tools.copy_file(res_source , self.get_staging_folder(pkgName) + "/res/" + res_dest + "/" + os.path.basename(res_source), force=True)
|
||||||
|
|
||||||
|
|
||||||
# Doc :
|
# Doc :
|
||||||
# http://asantoso.wordpress.com/2009/09/15/how-to-build-android-application-package-apk-from-the-command-line-using-the-sdk-tools-continuously-integrated-using-cruisecontrol/
|
# http://asantoso.wordpress.com/2009/09/15/how-to-build-android-application-package-apk-from-the-command-line-using-the-sdk-tools-continuously-integrated-using-cruisecontrol/
|
||||||
debug.print_element("pkg", "R.java", "<==", "Resources files")
|
debug.print_element("pkg", "R.java", "<==", "Resources files")
|
||||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/src/noFile")
|
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/src/noFile")
|
||||||
androidToolPath = self.folder_sdk + "/build-tools/19.0.3/"
|
androidToolPath = self.folder_sdk + "/build-tools/"
|
||||||
|
# find android tool version
|
||||||
|
dirnames = tools.get_list_sub_folder(androidToolPath)
|
||||||
|
if len(dirnames) != 1:
|
||||||
|
debug.error("an error occured when getting the tools for android")
|
||||||
|
androidToolPath += dirnames[0] + "/"
|
||||||
|
|
||||||
adModResouceFolder = ""
|
adModResouceFolder = ""
|
||||||
if "ADMOD_ID" in pkgProperties:
|
if "ADMOD_ID" in pkgProperties:
|
||||||
adModResouceFolder = " -S " + self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/res/ "
|
adModResouceFolder = " -S " + self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/res/ "
|
||||||
@@ -573,11 +595,11 @@ class Target(lutinTarget.Target):
|
|||||||
+ "-S " + self.get_staging_folder(pkgName) + "/res/ " \
|
+ "-S " + self.get_staging_folder(pkgName) + "/res/ " \
|
||||||
+ adModResouceFolder \
|
+ adModResouceFolder \
|
||||||
+ "-J " + self.get_staging_folder(pkgName) + "/src/ "
|
+ "-J " + self.get_staging_folder(pkgName) + "/src/ "
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
#aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library}
|
#aapt package -f -M ${manifest.file} -F ${packaged.resource.file} -I ${path.to.android-jar.library}
|
||||||
# -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}]
|
# -S ${android-resource-directory} [-m -J ${folder.to.output.the.R.java}]
|
||||||
|
|
||||||
lutinTools.create_directory_of_file(self.get_staging_folder(pkgName) + "/build/classes/noFile")
|
tools.create_directory_of_file(self.get_staging_folder(pkgName) + "/build/classes/noFile")
|
||||||
debug.print_element("pkg", "*.class", "<==", "*.java")
|
debug.print_element("pkg", "*.class", "<==", "*.java")
|
||||||
# more information with : -Xlint
|
# more information with : -Xlint
|
||||||
# + self.file_finalAbstraction + " "\ # this generate ex: out/Android/debug/staging/tethys/src/com/edouarddupin/tethys/edn.java
|
# + self.file_finalAbstraction + " "\ # this generate ex: out/Android/debug/staging/tethys/src/com/edouarddupin/tethys/edn.java
|
||||||
@@ -614,7 +636,7 @@ class Target(lutinTarget.Target):
|
|||||||
+ filesString \
|
+ filesString \
|
||||||
+ self.file_finalAbstraction + " " \
|
+ self.file_finalAbstraction + " " \
|
||||||
+ self.get_staging_folder(pkgName) + "/src/R.java "
|
+ self.get_staging_folder(pkgName) + "/src/R.java "
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
debug.print_element("pkg", ".dex", "<==", "*.class")
|
debug.print_element("pkg", ".dex", "<==", "*.class")
|
||||||
cmdLine = androidToolPath + "dx " \
|
cmdLine = androidToolPath + "dx " \
|
||||||
@@ -625,7 +647,7 @@ class Target(lutinTarget.Target):
|
|||||||
if "ADMOD_ID" in pkgProperties:
|
if "ADMOD_ID" in pkgProperties:
|
||||||
cmdLine += self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar "
|
cmdLine += self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar "
|
||||||
|
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
debug.print_element("pkg", ".apk", "<==", ".dex, assets, .so, res")
|
debug.print_element("pkg", ".apk", "<==", ".dex, assets, .so, res")
|
||||||
#builderDebug="-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y "
|
#builderDebug="-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y "
|
||||||
@@ -641,29 +663,26 @@ class Target(lutinTarget.Target):
|
|||||||
+ " -z " + self.get_staging_folder(pkgName) + "/resources.res " \
|
+ " -z " + self.get_staging_folder(pkgName) + "/resources.res " \
|
||||||
+ " -f " + self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + ".dex " \
|
+ " -f " + self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + ".dex " \
|
||||||
+ " -rf " + self.get_staging_folder(pkgName) + "/data "
|
+ " -rf " + self.get_staging_folder(pkgName) + "/data "
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
# doc :
|
# doc :
|
||||||
# http://developer.android.com/tools/publishing/app-signing.html
|
# http://developer.android.com/tools/publishing/app-signing.html
|
||||||
# Create a key for signing your application:
|
# Create a key for signing your application:
|
||||||
# keytool -genkeypair -v -keystore AndroidKey.jks -storepass Pass__AndroidDebugKey -alias alias__AndroidDebugKey -keypass PassKey__AndroidDebugKey -keyalg RSA -validity 36500
|
# keytool -genkeypair -v -keystore AndroidKey.jks -storepass Pass__AndroidDebugKey -alias alias__AndroidDebugKey -keypass PassKey__AndroidDebugKey -keyalg RSA -validity 36500
|
||||||
if "debug"==self.buildMode:
|
if self.config["mode"] == "debug":
|
||||||
tmpFile = open("tmpPass.boo", 'w')
|
|
||||||
tmpFile.write("Pass__AndroidDebugKey\n")
|
|
||||||
tmpFile.write("PassKey__AndroidDebugKey\n")
|
|
||||||
tmpFile.flush()
|
|
||||||
tmpFile.close()
|
|
||||||
debug.print_element("pkg", ".apk(signed debug)", "<==", ".apk (not signed)")
|
debug.print_element("pkg", ".apk(signed debug)", "<==", ".apk (not signed)")
|
||||||
# verbose mode :
|
# verbose mode :
|
||||||
#debugOption = "-verbose -certs "
|
#debugOption = "-verbose -certs "
|
||||||
debugOption = ""
|
debugOption = ""
|
||||||
cmdLine = "jarsigner " \
|
cmdLine = "jarsigner " \
|
||||||
+ debugOption \
|
+ debugOption \
|
||||||
+ "-keystore " + lutinTools.get_current_path(__file__) + "/AndroidDebugKey.jks " \
|
+ "-keystore " + tools.get_current_path(__file__) + "/AndroidDebugKey.jks " \
|
||||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||||
|
+ " -storepass Pass__AndroidDebugKey " \
|
||||||
|
+ " -keypass PassKey__AndroidDebugKey " \
|
||||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
||||||
+ " alias__AndroidDebugKey < tmpPass.boo"
|
+ " alias__AndroidDebugKey"
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
tmpFile = open("tmpPass.boo", 'w')
|
tmpFile = open("tmpPass.boo", 'w')
|
||||||
tmpFile.write("\n")
|
tmpFile.write("\n")
|
||||||
tmpFile.flush()
|
tmpFile.flush()
|
||||||
@@ -676,23 +695,23 @@ class Target(lutinTarget.Target):
|
|||||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
||||||
+ " " + pkgNameApplicationName
|
+ " " + pkgNameApplicationName
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
cmdLine = "jarsigner " \
|
cmdLine = "jarsigner " \
|
||||||
+ " -verify -verbose -certs " \
|
+ " -verify -verbose -certs " \
|
||||||
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
+ " -sigalg SHA1withRSA -digestalg SHA1 " \
|
||||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk "
|
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk "
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
debug.print_element("pkg", ".apk(aligned)", "<==", ".apk (not aligned)")
|
debug.print_element("pkg", ".apk(aligned)", "<==", ".apk (not aligned)")
|
||||||
lutinTools.remove_file(self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk")
|
tools.remove_file(self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk")
|
||||||
# verbose mode : -v
|
# verbose mode : -v
|
||||||
cmdLine = self.folder_sdk + "/tools/zipalign 4 " \
|
cmdLine = androidToolPath + "zipalign 4 " \
|
||||||
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
+ self.get_staging_folder(pkgName) + "/build/" + pkgNameApplicationName + "-unalligned.apk " \
|
||||||
+ self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk "
|
+ self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk "
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
# copy file in the final stage :
|
# copy file in the final stage :
|
||||||
lutinTools.copy_file(self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk",
|
tools.copy_file(self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk",
|
||||||
self.get_final_folder() + "/" + pkgNameApplicationName + ".apk",
|
self.get_final_folder() + "/" + pkgNameApplicationName + ".apk",
|
||||||
force=True)
|
force=True)
|
||||||
|
|
||||||
@@ -701,27 +720,28 @@ class Target(lutinTarget.Target):
|
|||||||
debug.info("Install package '" + pkgName + "'")
|
debug.info("Install package '" + pkgName + "'")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
pkgNameApplicationName = pkgName
|
pkgNameApplicationName = pkgName
|
||||||
if "debug"==self.buildMode:
|
if self.config["mode"] == "debug":
|
||||||
pkgNameApplicationName += "debug"
|
pkgNameApplicationName += "debug"
|
||||||
cmdLine = self.folder_sdk + "/platform-tools/adb install -r " \
|
cmdLine = self.folder_sdk + "/platform-tools/adb install -r " \
|
||||||
+ self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk "
|
+ self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk "
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
def un_install_package(self, pkgName):
|
def un_install_package(self, pkgName):
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
debug.info("Un-Install package '" + pkgName + "'")
|
debug.info("Un-Install package '" + pkgName + "'")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
pkgNameApplicationName = pkgName
|
pkgNameApplicationName = pkgName
|
||||||
if "debug"==self.buildMode:
|
if self.config["mode"] == "debug":
|
||||||
pkgNameApplicationName += "debug"
|
pkgNameApplicationName += "debug"
|
||||||
cmdLine = self.folder_sdk + "/platform-tools/adb uninstall " + pkgNameApplicationName
|
cmdLine = self.folder_sdk + "/platform-tools/adb uninstall " + pkgNameApplicationName
|
||||||
RlutinMultiprocess.unCommand(cmdLine)
|
Rmultiprocess.unCommand(cmdLine)
|
||||||
|
|
||||||
def Log(self, pkgName):
|
def Log(self, pkgName):
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
debug.info("logcat of android board")
|
debug.info("logcat of android board")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.info("cmd: " + self.folder_sdk + "/platform-tools/adb shell logcat ")
|
||||||
cmdLine = self.folder_sdk + "/platform-tools/adb shell logcat "
|
cmdLine = self.folder_sdk + "/platform-tools/adb shell logcat "
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
|
|
@@ -1,30 +1,47 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutinDebug as debug
|
##
|
||||||
import lutinTarget
|
## @author Edouard DUPIN
|
||||||
import lutinTools
|
##
|
||||||
import lutinImage
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import target
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import image
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import lutinExtProjectGeneratorXCode
|
from lutin import multiprocess
|
||||||
import lutinMultiprocess
|
from lutin import host
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
|
||||||
class Target(lutinTarget.Target):
|
class Target(target.Target):
|
||||||
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
|
def __init__(self, config):
|
||||||
if typeCompilator == "gcc":
|
if config["compilator"] == "gcc":
|
||||||
debug.info("compile only with clang for IOs");
|
debug.info("compile only with clang for IOs");
|
||||||
typeCompilator = "clang"
|
config["compilator"] = "clang"
|
||||||
|
#processor type selection (auto/arm/ppc/x86)
|
||||||
|
if config["arch"] == "auto":
|
||||||
|
config["arch"] = "arm"
|
||||||
|
#bus size selection (auto/32/64)
|
||||||
|
if config["bus-size"] == "auto":
|
||||||
|
config["bus-size"] = "64"
|
||||||
|
|
||||||
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
|
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
|
||||||
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
|
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
|
||||||
if sumulator == True:
|
if config["simulation"] == True:
|
||||||
arch = "i386"
|
arch = "i386"
|
||||||
cross = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
|
|
||||||
else:
|
else:
|
||||||
arch="arm64" # for ipad air
|
arch="arm64" # for ipad air
|
||||||
#arch="armv7" # for Iphone 4
|
#arch="armv7" # for Iphone 4
|
||||||
cross = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
|
target.Target.__init__(self, "IOs", config, arch)
|
||||||
lutinTarget.Target.__init__(self, "IOs", typeCompilator, debugMode, generatePackage, arch, cross, sumulator)
|
if self.config["simulation"] == True:
|
||||||
|
self.set_cross_base("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/")
|
||||||
|
else:
|
||||||
|
self.set_cross_base("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/")
|
||||||
|
|
||||||
# remove unneeded ranlib ...
|
# remove unneeded ranlib ...
|
||||||
self.ranlib=""
|
self.ranlib=""
|
||||||
@@ -37,13 +54,13 @@ class Target(lutinTarget.Target):
|
|||||||
self.suffix_binary=''
|
self.suffix_binary=''
|
||||||
self.suffix_package=''
|
self.suffix_package=''
|
||||||
if self.sumulator == True:
|
if self.sumulator == True:
|
||||||
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk"
|
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk"
|
||||||
self.global_flags_ld.append("-mios-simulator-version-min=7.0")
|
self.global_flags_ld.append("-mios-simulator-version-min=8.0")
|
||||||
self.global_flags_cc.append("-mios-simulator-version-min=7.0")
|
self.global_flags_cc.append("-mios-simulator-version-min=8.0")
|
||||||
else:
|
else:
|
||||||
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk"
|
self.sysroot = "-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk"
|
||||||
self.global_flags_ld.append("-miphoneos-version-min=7.0")
|
self.global_flags_ld.append("-miphoneos-version-min=8.0")
|
||||||
self.global_flags_cc.append("-miphoneos-version-min=7.0")
|
self.global_flags_cc.append("-miphoneos-version-min=8.0")
|
||||||
|
|
||||||
self.global_flags_ld.append([
|
self.global_flags_ld.append([
|
||||||
"-Xlinker",
|
"-Xlinker",
|
||||||
@@ -58,11 +75,8 @@ class Target(lutinTarget.Target):
|
|||||||
self.global_flags_m.append("-fobjc-arc")
|
self.global_flags_m.append("-fobjc-arc")
|
||||||
#self.global_flags_m.append("-fmodules")
|
#self.global_flags_m.append("-fmodules")
|
||||||
|
|
||||||
#add a project generator:
|
|
||||||
self.externProjectManager = lutinExtProjectGeneratorXCode.ExtProjectGeneratorXCode()
|
|
||||||
|
|
||||||
def get_staging_folder(self, binaryName):
|
def get_staging_folder(self, binaryName):
|
||||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName + ".app/"
|
return tools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName + ".app/"
|
||||||
|
|
||||||
def get_staging_folder_data(self, binaryName):
|
def get_staging_folder_data(self, binaryName):
|
||||||
return self.get_staging_folder(binaryName) + self.folder_data + "/"
|
return self.get_staging_folder(binaryName) + self.folder_data + "/"
|
||||||
@@ -78,23 +92,23 @@ class Target(lutinTarget.Target):
|
|||||||
# TODO : Do not regenerate if source resource is not availlable
|
# TODO : Do not regenerate if source resource is not availlable
|
||||||
# TODO : Add a colored background ...
|
# TODO : Add a colored background ...
|
||||||
debug.print_element("pkg", "iTunesArtwork.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "iTunesArtwork.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/iTunesArtwork.png", 512, 512)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/iTunesArtwork.png", 512, 512)
|
||||||
debug.print_element("pkg", "iTunesArtwork@2x.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "iTunesArtwork@2x.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/iTunesArtwork@2x.png", 1024, 1024)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/iTunesArtwork@2x.png", 1024, 1024)
|
||||||
debug.print_element("pkg", "Icon-60@2x.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "Icon-60@2x.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-60@2x.png", 120, 120)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-60@2x.png", 120, 120)
|
||||||
debug.print_element("pkg", "Icon-76.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "Icon-76.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-76.png", 76, 76)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-76.png", 76, 76)
|
||||||
debug.print_element("pkg", "Icon-76@2x.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "Icon-76@2x.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-76@2x.png", 152, 152)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-76@2x.png", 152, 152)
|
||||||
debug.print_element("pkg", "Icon-Small-40.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "Icon-Small-40.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small-40.png", 40, 40)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small-40.png", 40, 40)
|
||||||
debug.print_element("pkg", "Icon-Small-40@2x.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "Icon-Small-40@2x.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small-40@2x.png", 80, 80)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small-40@2x.png", 80, 80)
|
||||||
debug.print_element("pkg", "Icon-Small.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "Icon-Small.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small.png", 29, 29)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small.png", 29, 29)
|
||||||
debug.print_element("pkg", "Icon-Small@2x.png", "<==", pkgProperties["ICON"])
|
debug.print_element("pkg", "Icon-Small@2x.png", "<==", pkgProperties["ICON"])
|
||||||
lutinImage.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small@2x.png", 58, 58)
|
image.resize(pkgProperties["ICON"], self.get_staging_folder(pkgName) + "/Icon-Small@2x.png", 58, 58)
|
||||||
|
|
||||||
debug.print_element("pkg", "PkgInfo", "<==", "APPL????")
|
debug.print_element("pkg", "PkgInfo", "<==", "APPL????")
|
||||||
infoFile = self.get_staging_folder(pkgName) + "/PkgInfo"
|
infoFile = self.get_staging_folder(pkgName) + "/PkgInfo"
|
||||||
@@ -213,7 +227,7 @@ class Target(lutinTarget.Target):
|
|||||||
else:
|
else:
|
||||||
cmdLine += " -platform iphoneos "
|
cmdLine += " -platform iphoneos "
|
||||||
cmdLine += " -o " + self.get_staging_folder(pkgName) + "/" + "Info.plist"
|
cmdLine += " -o " + self.get_staging_folder(pkgName) + "/" + "Info.plist"
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -315,16 +329,16 @@ class Target(lutinTarget.Target):
|
|||||||
# application signing :
|
# application signing :
|
||||||
debug.print_element("pkg(signed)", "pkg", "<==", "Signing application")
|
debug.print_element("pkg(signed)", "pkg", "<==", "Signing application")
|
||||||
iosDevelopperKeyFile = ".iosKey.txt"
|
iosDevelopperKeyFile = ".iosKey.txt"
|
||||||
if lutinTools.file_size(iosDevelopperKeyFile) < 10:
|
if tools.file_size(iosDevelopperKeyFile) < 10:
|
||||||
debug.error("To sign an application we need to have a signing key in the file '" + iosDevelopperKeyFile + "' \n it is represented like: 'iPhone Developer: Francis DUGENOUX (YRRQE5KGTH)'\n you can obtain it with : 'certtool y | grep \"Developer\"'")
|
debug.error("To sign an application we need to have a signing key in the file '" + iosDevelopperKeyFile + "' \n it is represented like: 'iPhone Developer: Francis DUGENOUX (YRRQE5KGTH)'\n you can obtain it with : 'certtool y | grep \"Developer\"'")
|
||||||
signatureKey = lutinTools.file_read_data(iosDevelopperKeyFile)
|
signatureKey = tools.file_read_data(iosDevelopperKeyFile)
|
||||||
signatureKey = re.sub('\n', '', signatureKey)
|
signatureKey = re.sub('\n', '', signatureKey)
|
||||||
cmdLine = 'codesign --force --sign '
|
cmdLine = 'codesign --force --sign '
|
||||||
# to get this key ; certtool y | grep "Developer"
|
# to get this key ; certtool y | grep "Developer"
|
||||||
cmdLine += ' "' + signatureKey + '" '
|
cmdLine += ' "' + signatureKey + '" '
|
||||||
cmdLine += ' --entitlements ' + self.get_build_folder(pkgName) + '/worddown.xcent'
|
cmdLine += ' --entitlements ' + self.get_build_folder(pkgName) + '/worddown.xcent'
|
||||||
cmdLine += ' ' + self.get_staging_folder(pkgName)
|
cmdLine += ' ' + self.get_staging_folder(pkgName)
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
# --force --sign "iPhone Developer: Edouard DUPIN (SDFGSDFGSDFG)"
|
# --force --sign "iPhone Developer: Edouard DUPIN (SDFGSDFGSDFG)"
|
||||||
# --resource-rules=/Users/edouarddupin/Library/Developer/Xcode/DerivedData/worddown-cmuvjchgtiteexdiacyqoexsyadg/Build/Products/Debug-iphoneos/worddown.app/ResourceRules.plist
|
# --resource-rules=/Users/edouarddupin/Library/Developer/Xcode/DerivedData/worddown-cmuvjchgtiteexdiacyqoexsyadg/Build/Products/Debug-iphoneos/worddown.app/ResourceRules.plist
|
||||||
@@ -343,18 +357,18 @@ class Target(lutinTarget.Target):
|
|||||||
debug.info("Install package '" + pkgName + "'")
|
debug.info("Install package '" + pkgName + "'")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
if self.sumulator == False:
|
if self.sumulator == False:
|
||||||
if lutinTools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
if tools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||||
debug.print_element("tool", "ios-deploy", "<==", "external sources")
|
debug.print_element("tool", "ios-deploy", "<==", "external sources")
|
||||||
cmdLine = 'cd ewol/ios-deploy ; make ; cd ../.. '
|
cmdLine = 'cd ewol/ios-deploy ; make ; cd ../.. '
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
if lutinTools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
if tools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||||
debug.error("Can not create ios-deploy external software ...")
|
debug.error("Can not create ios-deploy external software ...")
|
||||||
debug.print_element("deploy", "iphone/ipad", "<==", "aplication")
|
debug.print_element("deploy", "iphone/ipad", "<==", "aplication")
|
||||||
cmdLine = './ewol/ios-deploy/ios-deploy --bundle ' + self.get_staging_folder(pkgName)
|
cmdLine = './ewol/ios-deploy/ios-deploy --bundle ' + self.get_staging_folder(pkgName)
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
else:
|
else:
|
||||||
simulatorIdFile = ".iosSimutatorId_" + pkgName + ".txt"
|
simulatorIdFile = ".iosSimutatorId_" + pkgName + ".txt"
|
||||||
if lutinTools.file_size(simulatorIdFile) < 10:
|
if tools.file_size(simulatorIdFile) < 10:
|
||||||
#create the file:
|
#create the file:
|
||||||
tmpFile = open(simulatorIdFile, 'w')
|
tmpFile = open(simulatorIdFile, 'w')
|
||||||
tmpFile.write(self.createRandomNumber(8))
|
tmpFile.write(self.createRandomNumber(8))
|
||||||
@@ -368,17 +382,17 @@ class Target(lutinTarget.Target):
|
|||||||
tmpFile.write(self.createRandomNumber(12))
|
tmpFile.write(self.createRandomNumber(12))
|
||||||
tmpFile.flush()
|
tmpFile.flush()
|
||||||
tmpFile.close()
|
tmpFile.close()
|
||||||
simulatorId = lutinTools.file_read_data(simulatorIdFile)
|
simulatorId = tools.file_read_data(simulatorIdFile)
|
||||||
home = os.path.expanduser("~")
|
home = os.path.expanduser("~")
|
||||||
destinationFolderBase = home + "/Library/Application\\ Support/iPhone\\ Simulator/7.1/Applications/" + simulatorId
|
destinationFolderBase = home + "/Library/Application\\ Support/iPhone\\ Simulator/7.1/Applications/" + simulatorId
|
||||||
destinationFolder = home + "/Library/Application Support/iPhone Simulator/7.1/Applications/" + simulatorId + "/" + pkgName + ".app"
|
destinationFolder = home + "/Library/Application Support/iPhone Simulator/7.1/Applications/" + simulatorId + "/" + pkgName + ".app"
|
||||||
destinationFolder2 = home + "/Library/Application\\ Support/iPhone\\ Simulator/7.1/Applications/" + simulatorId + "/" + pkgName + ".app"
|
destinationFolder2 = home + "/Library/Application\\ Support/iPhone\\ Simulator/7.1/Applications/" + simulatorId + "/" + pkgName + ".app"
|
||||||
debug.info("install in simulator : " + destinationFolder)
|
debug.info("install in simulator : " + destinationFolder)
|
||||||
lutinTools.create_directory_of_file(destinationFolder + "/plop.txt")
|
tools.create_directory_of_file(destinationFolder + "/plop.txt")
|
||||||
cmdLine = "cp -rf " + self.get_staging_folder(pkgName) + " " + destinationFolder2
|
cmdLine = "cp -rf " + self.get_staging_folder(pkgName) + " " + destinationFolder2
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
cmdLine = "touch " + destinationFolderBase
|
cmdLine = "touch " + destinationFolderBase
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||||
|
|
||||||
@@ -390,7 +404,7 @@ class Target(lutinTarget.Target):
|
|||||||
debug.warning("not implemented")
|
debug.warning("not implemented")
|
||||||
else:
|
else:
|
||||||
simulatorIdFile = ".iosSimutatorId_" + pkgName + ".txt"
|
simulatorIdFile = ".iosSimutatorId_" + pkgName + ".txt"
|
||||||
if lutinTools.file_size(simulatorIdFile) < 10:
|
if tools.file_size(simulatorIdFile) < 10:
|
||||||
debug.warning("Can not get simulation O_ID : " + simulatorIdFile)
|
debug.warning("Can not get simulation O_ID : " + simulatorIdFile)
|
||||||
|
|
||||||
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||||
@@ -400,18 +414,18 @@ class Target(lutinTarget.Target):
|
|||||||
debug.info("log of iOs board")
|
debug.info("log of iOs board")
|
||||||
debug.debug("------------------------------------------------------------------------")
|
debug.debug("------------------------------------------------------------------------")
|
||||||
if self.sumulator == False:
|
if self.sumulator == False:
|
||||||
if lutinTools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
if tools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||||
debug.print_element("tool", "ios-deploy", "<==", "external sources")
|
debug.print_element("tool", "ios-deploy", "<==", "external sources")
|
||||||
cmdLine = 'cd ewol/ios-deploy ; make ; cd ../.. '
|
cmdLine = 'cd ewol/ios-deploy ; make ; cd ../.. '
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
if lutinTools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
if tools.file_size("ewol/ios-deploy/ios-deploy") == 0:
|
||||||
debug.error("Can not create ios-deploy external software ...")
|
debug.error("Can not create ios-deploy external software ...")
|
||||||
debug.print_element("deploy", "iphone/ipad", "<==", "aplication")
|
debug.print_element("deploy", "iphone/ipad", "<==", "aplication")
|
||||||
cmdLine = './ewol/ios-deploy/ios-deploy --debug --bundle ' + self.get_staging_folder(pkgName)
|
cmdLine = './ewol/ios-deploy/ios-deploy --debug --bundle ' + self.get_staging_folder(pkgName)
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
else:
|
else:
|
||||||
cmdLine = "tail -f ~/Library/Logs/iOS\ Simulator/7.1/system.log"
|
cmdLine = "tail -f ~/Library/Logs/iOS\ Simulator/7.1/system.log"
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
multiprocess.run_command(cmdLine)
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -1,15 +1,37 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutinDebug as debug
|
##
|
||||||
import lutinTarget
|
## @author Edouard DUPIN
|
||||||
import lutinTools as tools
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import target
|
||||||
|
from lutin import tools
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import re
|
import re
|
||||||
import lutinMultiprocess
|
from lutin import host
|
||||||
|
|
||||||
class Target(lutinTarget.Target):
|
class Target(target.Target):
|
||||||
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
|
def __init__(self, config):
|
||||||
lutinTarget.Target.__init__(self, "Linux", typeCompilator, debugMode, generatePackage, "", "")
|
#processor type selection (auto/arm/ppc/x86)
|
||||||
|
if config["arch"] == "auto":
|
||||||
|
config["arch"] = "x86"
|
||||||
|
#bus size selection (auto/32/64)
|
||||||
|
if config["bus-size"] == "auto":
|
||||||
|
config["bus-size"] = str(host.BUS_SIZE)
|
||||||
|
target.Target.__init__(self, "Linux", config, "")
|
||||||
|
if self.config["bus-size"] == "64":
|
||||||
|
# 64 bits
|
||||||
|
if host.BUS_SIZE != 64:
|
||||||
|
self.global_flags_cc.append("-m64")
|
||||||
|
else:
|
||||||
|
# 32 bits
|
||||||
|
if host.BUS_SIZE != 32:
|
||||||
|
self.global_flags_cc.append("-m32")
|
||||||
|
|
||||||
def generate_list_separate_coma(self, list):
|
def generate_list_separate_coma(self, list):
|
||||||
result = ""
|
result = ""
|
@@ -1,17 +1,30 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import lutinDebug as debug
|
##
|
||||||
import lutinTarget
|
## @author Edouard DUPIN
|
||||||
import lutinTools
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import target
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import host
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
|
|
||||||
class Target(lutinTarget.Target):
|
class Target(target.Target):
|
||||||
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
|
def __init__(self, config):
|
||||||
cross = ""
|
#processor type selection (auto/arm/ppc/x86)
|
||||||
|
if config["arch"] == "auto":
|
||||||
|
config["arch"] = "x86"
|
||||||
|
#bus size selection (auto/32/64)
|
||||||
|
if config["bus-size"] == "auto":
|
||||||
|
config["bus-size"] = str(host.BUS_SIZE)
|
||||||
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
|
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
|
||||||
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
|
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
|
||||||
lutinTarget.Target.__init__(self, "MacOs", typeCompilator, debugMode, generatePackage, "", cross)
|
target.Target.__init__(self, "MacOs", config, "")
|
||||||
|
|
||||||
self.folder_bin="/MacOS"
|
self.folder_bin="/MacOS"
|
||||||
self.folder_lib="/lib"
|
self.folder_lib="/lib"
|
||||||
@@ -25,7 +38,7 @@ class Target(lutinTarget.Target):
|
|||||||
|
|
||||||
|
|
||||||
def get_staging_folder(self, binaryName):
|
def get_staging_folder(self, binaryName):
|
||||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName + ".app/Contents/"
|
return tools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName + ".app/Contents/"
|
||||||
|
|
||||||
def get_staging_folder_data(self, binaryName):
|
def get_staging_folder_data(self, binaryName):
|
||||||
return self.get_staging_folder(binaryName) + self.folder_data + "/"
|
return self.get_staging_folder(binaryName) + self.folder_data + "/"
|
||||||
@@ -37,7 +50,7 @@ class Target(lutinTarget.Target):
|
|||||||
|
|
||||||
if "ICON" in pkgProperties.keys() \
|
if "ICON" in pkgProperties.keys() \
|
||||||
and pkgProperties["ICON"] != "":
|
and pkgProperties["ICON"] != "":
|
||||||
lutinTools.copy_file(pkgProperties["ICON"], self.get_staging_folder_data(pkgName) + "/icon.icns", True)
|
tools.copy_file(pkgProperties["ICON"], self.get_staging_folder_data(pkgName) + "/icon.icns", force=True)
|
||||||
|
|
||||||
# http://www.sandroid.org/imcross/#Deployment
|
# http://www.sandroid.org/imcross/#Deployment
|
||||||
infoFile=self.get_staging_folder(pkgName) + "/Info.plist"
|
infoFile=self.get_staging_folder(pkgName) + "/Info.plist"
|
133
lutin/target/lutinTarget_Windows.py
Normal file
133
lutin/target/lutinTarget_Windows.py
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from lutin import debug
|
||||||
|
from lutin import target
|
||||||
|
from lutin import tools
|
||||||
|
from lutin import host
|
||||||
|
import os
|
||||||
|
import stat
|
||||||
|
import sys
|
||||||
|
from lutin import zip
|
||||||
|
|
||||||
|
class Target(target.Target):
|
||||||
|
def __init__(self, config):
|
||||||
|
if config["compilator"] != "gcc":
|
||||||
|
debug.error("Windows does not support '" + config["compilator"] + "' compilator ... availlable : [gcc]")
|
||||||
|
config["compilator"] = "gcc"
|
||||||
|
|
||||||
|
#processor type selection (auto/arm/ppc/x86)
|
||||||
|
if config["arch"] == "auto":
|
||||||
|
config["arch"] = "x86"
|
||||||
|
#bus size selection (auto/32/64)
|
||||||
|
if config["bus-size"] == "auto":
|
||||||
|
config["bus-size"] = str(host.BUS_SIZE)
|
||||||
|
|
||||||
|
target.Target.__init__(self, "Windows", config, "")
|
||||||
|
|
||||||
|
# on windows board the basic path is not correct
|
||||||
|
# TODO : get external PATH for the minGW path
|
||||||
|
# TODO : Set the cyngwin path ...
|
||||||
|
if host.OS == "Windows":
|
||||||
|
self.set_cross_base("c:\\MinGW\\bin\\")
|
||||||
|
sys.path.append("c:\\MinGW\\bin" )
|
||||||
|
os.environ['PATH'] += ";c:\\MinGW\\bin\\"
|
||||||
|
else:
|
||||||
|
if self.config["bus-size"] == "64":
|
||||||
|
# 64 bits
|
||||||
|
self.set_cross_base("x86_64-w64-mingw32-")
|
||||||
|
else:
|
||||||
|
# 32 bits
|
||||||
|
self.set_cross_base("i686-w64-mingw32-")
|
||||||
|
# force static link to prenvent many errors ...
|
||||||
|
self.global_flags_ld.append(["-static-libgcc",
|
||||||
|
"-static-libstdc++",
|
||||||
|
"-static"])
|
||||||
|
|
||||||
|
self.folder_bin=""
|
||||||
|
self.folder_lib="/lib"
|
||||||
|
self.folder_data="/data"
|
||||||
|
self.folder_doc="/doc"
|
||||||
|
|
||||||
|
self.suffix_lib_static='.a'
|
||||||
|
self.suffix_lib_dynamic='.dll'
|
||||||
|
self.suffix_binary='.exe'
|
||||||
|
self.suffix_package=''
|
||||||
|
|
||||||
|
|
||||||
|
def get_staging_folder_data(self, binaryName):
|
||||||
|
return self.get_staging_folder(binaryName) + self.folder_data
|
||||||
|
|
||||||
|
def make_package(self, pkgName, pkgProperties, basePkgPath):
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.info("Generate package '" + pkgName + "'")
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.print_element("zip", "data.zip", "<==", "data/*")
|
||||||
|
zipPath = self.get_staging_folder(pkgName) + "/data.zip"
|
||||||
|
zip.create_zip(self.get_staging_folder_data(pkgName), zipPath)
|
||||||
|
|
||||||
|
binPath = self.get_staging_folder(pkgName) + "/" + self.folder_bin + "/" + pkgName + self.suffix_binary
|
||||||
|
binSize = tools.file_size(binPath)
|
||||||
|
debug.info("binarysize : " + str(binSize/1024) + " ko ==> " + str(binSize) + " octets")
|
||||||
|
|
||||||
|
#now we create a simple bundle binary ==> all file is stored in one file ...
|
||||||
|
self.get_staging_folder(pkgName)
|
||||||
|
finalBin = self.get_final_folder() + "/" + pkgName + self.suffix_binary
|
||||||
|
tools.create_directory_of_file(finalBin);
|
||||||
|
debug.print_element("pkg", finalBin, "<==", pkgName + self.suffix_binary)
|
||||||
|
#open output file
|
||||||
|
tmpFile = open(finalBin, 'wb')
|
||||||
|
# read all executable binary
|
||||||
|
dataExecutable = tools.file_read_data(binPath, binary=True)
|
||||||
|
# wrte binary to the output
|
||||||
|
tmpFile.write(dataExecutable)
|
||||||
|
#align data in the 32 Bytes position (prevent zip align error)
|
||||||
|
residualToAllign = 32 + 32 - (len(dataExecutable) - int(len(dataExecutable)/32)*32)
|
||||||
|
for iii in range(0,residualToAllign):
|
||||||
|
tmpFile.write(b'\0');
|
||||||
|
positionOfZip = len(dataExecutable) + residualToAllign;
|
||||||
|
# write a control TAG
|
||||||
|
tmpFile.write(b'***START DATA***');
|
||||||
|
# write all the zip file
|
||||||
|
debug.print_element("pkg", finalBin, "<==", "data.zip")
|
||||||
|
dataData = tools.file_read_data(zipPath, binary=True)
|
||||||
|
tmpFile.write(dataData)
|
||||||
|
#align data in the 32 Bytes position (to be fun"
|
||||||
|
tmpLen = len(dataData) + positionOfZip
|
||||||
|
residualToAllign = 32 + 32 - (tmpLen - int(tmpLen/32)*32)
|
||||||
|
for iii in range(0,residualToAllign):
|
||||||
|
tmpFile.write(b'\0');
|
||||||
|
# write a control TAG
|
||||||
|
tmpFile.write(b'*** END DATA ***');
|
||||||
|
# reserved AREA (can be use later for extra value ...)
|
||||||
|
for iii in range(0,8):
|
||||||
|
tmpFile.write(b'\0');
|
||||||
|
# write the position of the zip file (TAG position)
|
||||||
|
h = '{0:016x}'.format(positionOfZip)
|
||||||
|
s = ('0'*(len(h) % 2) + h).decode('hex')
|
||||||
|
tmpFile.write(s)
|
||||||
|
# package is done
|
||||||
|
tmpFile.flush()
|
||||||
|
tmpFile.close()
|
||||||
|
debug.verbose("zip position=" + str(positionOfZip) + " = 0x" + h)
|
||||||
|
|
||||||
|
def install_package(self, pkgName):
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.info("Install package '" + pkgName + "'")
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.warning(" ==> TODO")
|
||||||
|
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||||
|
|
||||||
|
def un_install_package(self, pkgName):
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.info("Un-Install package '" + pkgName + "'")
|
||||||
|
debug.debug("------------------------------------------------------------------------")
|
||||||
|
debug.warning(" ==> TODO")
|
||||||
|
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
||||||
|
|
@@ -1,12 +1,20 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import errno
|
import errno
|
||||||
import lutinDebug as debug
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import lutinMultiprocess
|
# Local import
|
||||||
import lutinDepend as dependency
|
from . import debug
|
||||||
|
from . import depend
|
||||||
|
import multiprocess
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -27,6 +35,11 @@ def create_directory_of_file(file):
|
|||||||
except:
|
except:
|
||||||
os.makedirs(folder)
|
os.makedirs(folder)
|
||||||
|
|
||||||
|
def get_list_sub_folder(path):
|
||||||
|
# TODO : os.listdir(path)
|
||||||
|
for dirname, dirnames, filenames in os.walk(path):
|
||||||
|
return dirnames
|
||||||
|
return []
|
||||||
|
|
||||||
def remove_folder_and_sub_folder(path):
|
def remove_folder_and_sub_folder(path):
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
@@ -43,9 +56,12 @@ def file_size(path):
|
|||||||
statinfo = os.stat(path)
|
statinfo = os.stat(path)
|
||||||
return statinfo.st_size
|
return statinfo.st_size
|
||||||
|
|
||||||
def file_read_data(path):
|
def file_read_data(path, binary=False):
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
return ""
|
return ""
|
||||||
|
if binary == True:
|
||||||
|
file = open(path, "rb")
|
||||||
|
else:
|
||||||
file = open(path, "r")
|
file = open(path, "r")
|
||||||
data_file = file.read()
|
data_file = file.read()
|
||||||
file.close()
|
file.close()
|
||||||
@@ -85,37 +101,46 @@ def copy_file(src, dst, cmd_file=None, force=False):
|
|||||||
debug.error("Request a copy a file that does not existed : '" + src + "'")
|
debug.error("Request a copy a file that does not existed : '" + src + "'")
|
||||||
cmd_line = "copy \"" + src + "\" \"" + dst + "\""
|
cmd_line = "copy \"" + src + "\" \"" + dst + "\""
|
||||||
if force == False \
|
if force == False \
|
||||||
and dependency.need_re_build(dst, src, file_cmd=cmd_file , cmdLine=cmd_line) == False:
|
and depend.need_re_build(dst, src, file_cmd=cmd_file , cmdLine=cmd_line) == False:
|
||||||
return
|
return
|
||||||
debug.print_element("copy file", src, "==>", dst)
|
debug.print_element("copy file", src, "==>", dst)
|
||||||
create_directory_of_file(dst)
|
create_directory_of_file(dst)
|
||||||
shutil.copyfile(src, dst)
|
shutil.copyfile(src, dst)
|
||||||
lutinMultiprocess.store_command(cmd_line, cmd_file)
|
multiprocess.store_command(cmd_line, cmd_file)
|
||||||
|
|
||||||
|
|
||||||
def copy_anything(src, dst):
|
def copy_anything(src, dst):
|
||||||
tmpPath = os.path.dirname(os.path.realpath(src))
|
tmpPath = os.path.dirname(os.path.realpath(src))
|
||||||
tmpRule = os.path.basename(src)
|
tmpRule = os.path.basename(src)
|
||||||
for root, dirnames, filenames in os.walk(tmpPath):
|
for root, dirnames, filenames in os.walk(tmpPath):
|
||||||
|
debug.verbose(" root='" + str(root) + "' dir='" + str(dirnames) + "' filenames=" + str(filenames))
|
||||||
tmpList = filenames
|
tmpList = filenames
|
||||||
if len(tmpRule)>0:
|
if len(tmpRule)>0:
|
||||||
tmpList = fnmatch.filter(filenames, tmpRule)
|
tmpList = fnmatch.filter(filenames, tmpRule)
|
||||||
# Import the module :
|
# Import the module :
|
||||||
for cycleFile in tmpList:
|
for cycleFile in tmpList:
|
||||||
#for cycleFile in filenames:
|
#for cycleFile in filenames:
|
||||||
#debug.info("Might copy : '" + tmpPath+cycleFile + "' ==> '" + dst + "'")
|
debug.verbose("Might copy : '" + tmpPath+cycleFile + "' ==> '" + dst + "'")
|
||||||
copy_file(tmpPath+"/"+cycleFile,dst+"/"+cycleFile)
|
copy_file(tmpPath+"/"+cycleFile, dst+"/"+cycleFile)
|
||||||
|
|
||||||
|
|
||||||
def copy_anything_target(target, src, dst):
|
def copy_anything_target(target, src, dst):
|
||||||
tmpPath = os.path.dirname(os.path.realpath(src))
|
tmpPath = os.path.dirname(os.path.realpath(src))
|
||||||
tmpRule = os.path.basename(src)
|
tmpRule = os.path.basename(src)
|
||||||
for root, dirnames, filenames in os.walk(tmpPath):
|
for root, dirnames, filenames in os.walk(tmpPath):
|
||||||
|
debug.verbose(" root='" + str(root) + "' dir='" + str(dirnames) + "' filenames=" + str(filenames))
|
||||||
tmpList = filenames
|
tmpList = filenames
|
||||||
if len(tmpRule)>0:
|
if len(tmpRule)>0:
|
||||||
tmpList = fnmatch.filter(filenames, tmpRule)
|
tmpList = fnmatch.filter(filenames, tmpRule)
|
||||||
# Import the module :
|
# Import the module :
|
||||||
for cycleFile in tmpList:
|
for cycleFile in tmpList:
|
||||||
#for cycleFile in filenames:
|
#for cycleFile in filenames:
|
||||||
#debug.info("Might copy : '" + tmpPath+cycleFile + "' ==> '" + dst + "'")
|
newDst = dst
|
||||||
target.add_file_staging(tmpPath+"/"+cycleFile,dst+"/"+cycleFile)
|
if len(newDst) != 0 and newDst[-1] != "/":
|
||||||
|
newDst += "/"
|
||||||
|
if root[len(src)-1:] != "":
|
||||||
|
newDst += root[len(src)-1:]
|
||||||
|
if len(newDst) != 0 and newDst[-1] != "/":
|
||||||
|
newDst += "/"
|
||||||
|
debug.verbose("Might copy : '" + root+"/"+cycleFile + "' ==> '" + newDst+cycleFile + "'" )
|
||||||
|
target.add_file_staging(root+"/"+cycleFile, newDst+cycleFile)
|
30
lutin/zip.py
Normal file
30
lutin/zip.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license APACHE v2.0 (see license file)
|
||||||
|
##
|
||||||
|
import platform
|
||||||
|
import os
|
||||||
|
import zipfile
|
||||||
|
# Local import
|
||||||
|
from . import debug
|
||||||
|
from . import tools
|
||||||
|
|
||||||
|
|
||||||
|
def create_zip(path, outputFile):
|
||||||
|
debug.debug("Create Zip : '" + outputFile + "'")
|
||||||
|
debug.debug(" from '" + path + "'")
|
||||||
|
basePathlen = len(path)
|
||||||
|
zf = zipfile.ZipFile(outputFile, mode='w')
|
||||||
|
for root, dirnames, filenames in os.walk(path):
|
||||||
|
# List all files :
|
||||||
|
for filename in filenames:
|
||||||
|
file = os.path.join(root, filename)
|
||||||
|
debug.verbose(" ADD zip = " + str(file))
|
||||||
|
zf.write(file, file[basePathlen:])
|
||||||
|
zf.close()
|
||||||
|
|
||||||
|
|
@@ -1,98 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import os
|
|
||||||
import thread
|
|
||||||
import lutinMultiprocess
|
|
||||||
import threading
|
|
||||||
|
|
||||||
debugLevel=3
|
|
||||||
debugColor=False
|
|
||||||
|
|
||||||
color_default= ""
|
|
||||||
color_red = ""
|
|
||||||
color_green = ""
|
|
||||||
color_yellow = ""
|
|
||||||
color_blue = ""
|
|
||||||
color_purple = ""
|
|
||||||
color_cyan = ""
|
|
||||||
|
|
||||||
|
|
||||||
debugLock = threading.Lock()
|
|
||||||
|
|
||||||
def set_level(id):
|
|
||||||
global debugLevel
|
|
||||||
debugLevel = id
|
|
||||||
#print "SetDebug level at " + str(debugLevel)
|
|
||||||
|
|
||||||
def enable_color():
|
|
||||||
global debugColor
|
|
||||||
debugColor = True
|
|
||||||
global color_default
|
|
||||||
color_default= "\033[00m"
|
|
||||||
global color_red
|
|
||||||
color_red = "\033[31m"
|
|
||||||
global color_green
|
|
||||||
color_green = "\033[32m"
|
|
||||||
global color_yellow
|
|
||||||
color_yellow = "\033[33m"
|
|
||||||
global color_blue
|
|
||||||
color_blue = "\033[34m"
|
|
||||||
global color_purple
|
|
||||||
color_purple = "\033[35m"
|
|
||||||
global color_cyan
|
|
||||||
color_cyan = "\033[36m"
|
|
||||||
|
|
||||||
def verbose(input):
|
|
||||||
global debugLock
|
|
||||||
global debugLevel
|
|
||||||
if debugLevel >= 5:
|
|
||||||
debugLock.acquire()
|
|
||||||
print(color_blue + input + color_default)
|
|
||||||
debugLock.release()
|
|
||||||
|
|
||||||
def debug(input):
|
|
||||||
global debugLock
|
|
||||||
global debugLevel
|
|
||||||
if debugLevel >= 4:
|
|
||||||
debugLock.acquire()
|
|
||||||
print(color_green + input + color_default)
|
|
||||||
debugLock.release()
|
|
||||||
|
|
||||||
def info(input):
|
|
||||||
global debugLock
|
|
||||||
global debugLevel
|
|
||||||
if debugLevel >= 3:
|
|
||||||
debugLock.acquire()
|
|
||||||
print(input + color_default)
|
|
||||||
debugLock.release()
|
|
||||||
|
|
||||||
def warning(input):
|
|
||||||
global debugLock
|
|
||||||
global debugLevel
|
|
||||||
if debugLevel >= 2:
|
|
||||||
debugLock.acquire()
|
|
||||||
print(color_purple + "[WARNING] " + input + color_default)
|
|
||||||
debugLock.release()
|
|
||||||
|
|
||||||
def error(input, threadID=-1):
|
|
||||||
global debugLock
|
|
||||||
global debugLevel
|
|
||||||
if debugLevel >= 1:
|
|
||||||
debugLock.acquire()
|
|
||||||
print(color_red + "[ERROR] " + input + color_default)
|
|
||||||
debugLock.release()
|
|
||||||
lutinMultiprocess.error_occured()
|
|
||||||
if threadID != -1:
|
|
||||||
thread.interrupt_main()
|
|
||||||
exit(-1)
|
|
||||||
#os_exit(-1)
|
|
||||||
#raise "error happend"
|
|
||||||
|
|
||||||
def print_element(type, lib, dir, name):
|
|
||||||
global debugLock
|
|
||||||
global debugLevel
|
|
||||||
if debugLevel >= 3:
|
|
||||||
debugLock.acquire()
|
|
||||||
print(color_cyan + type + color_default + " : " + color_yellow + lib + color_default + " " + dir + " " + color_blue + name + color_default)
|
|
||||||
debugLock.release()
|
|
||||||
|
|
||||||
|
|
@@ -1,14 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import lutinDebug as debug
|
|
||||||
import datetime
|
|
||||||
import lutinTools
|
|
||||||
import lutinModule
|
|
||||||
|
|
||||||
class ExtProjectGenerator:
|
|
||||||
def __init__(self, extType):
|
|
||||||
self.extType = extType
|
|
||||||
self.name = "emptyName"
|
|
||||||
#This is a distionnaty of all groups :
|
|
||||||
self.groups = {}
|
|
||||||
|
|
||||||
|
|
@@ -1,693 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import lutinDebug as debug
|
|
||||||
import datetime
|
|
||||||
import lutinTools as tools
|
|
||||||
import os
|
|
||||||
import fnmatch
|
|
||||||
import lutinExtProjectGenerator
|
|
||||||
from collections import defaultdict
|
|
||||||
|
|
||||||
|
|
||||||
# id example : FFBA2F79187F44AE0034CC66
|
|
||||||
genericID = 100000
|
|
||||||
|
|
||||||
def convert_name_in_base_id(name,fill=True):
|
|
||||||
out = "FF"
|
|
||||||
for element in name.lower():
|
|
||||||
if element == "a": out += "01"
|
|
||||||
elif element == "b": out += "02"
|
|
||||||
elif element == "c": out += "03"
|
|
||||||
elif element == "d": out += "04"
|
|
||||||
elif element == "e": out += "05"
|
|
||||||
elif element == "f": out += "06"
|
|
||||||
elif element == "g": out += "07"
|
|
||||||
elif element == "h": out += "08"
|
|
||||||
elif element == "i": out += "09"
|
|
||||||
elif element == "j": out += "10"
|
|
||||||
elif element == "k": out += "11"
|
|
||||||
elif element == "l": out += "12"
|
|
||||||
elif element == "m": out += "13"
|
|
||||||
elif element == "n": out += "14"
|
|
||||||
elif element == "o": out += "15"
|
|
||||||
elif element == "p": out += "16"
|
|
||||||
elif element == "q": out += "17"
|
|
||||||
elif element == "r": out += "18"
|
|
||||||
elif element == "s": out += "19"
|
|
||||||
elif element == "t": out += "20"
|
|
||||||
elif element == "u": out += "21"
|
|
||||||
elif element == "v": out += "22"
|
|
||||||
elif element == "w": out += "23"
|
|
||||||
elif element == "x": out += "24"
|
|
||||||
elif element == "y": out += "25"
|
|
||||||
elif element == "z": out += "27"
|
|
||||||
else: out += "FF"
|
|
||||||
if len(out) >= 18:
|
|
||||||
return out
|
|
||||||
if fill == True:
|
|
||||||
for iii in range(0,256):
|
|
||||||
out += "A"
|
|
||||||
if len(out) >= 18:
|
|
||||||
return out
|
|
||||||
return out
|
|
||||||
|
|
||||||
|
|
||||||
dictId = {}
|
|
||||||
|
|
||||||
def convert_folder_in_base_id(name, package):
|
|
||||||
global dictId
|
|
||||||
debug.verbose(" generate Id for : " + package + ":" + name);
|
|
||||||
if package not in dictId.keys():
|
|
||||||
dictId[package] = {"lastID": 100000, "sub":{}}
|
|
||||||
if name not in dictId[package]["sub"].keys():
|
|
||||||
generatedID = convert_name_in_base_id(package) + str(dictId[package]["lastID"])
|
|
||||||
dictId[package]["lastID"] = dictId[package]["lastID"] + 1
|
|
||||||
dictId[package]["sub"][name] = {"id":generatedID}
|
|
||||||
return dictId[package]["sub"][name]["id"]
|
|
||||||
|
|
||||||
FILE_MARKER = '<files>'
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief generate a tree from the specific file
|
|
||||||
##
|
|
||||||
def attach(branch, trunk):
|
|
||||||
parts = branch.split('/', 1)
|
|
||||||
if len(parts) == 1: # branch is a file
|
|
||||||
trunk[FILE_MARKER].append(parts[0])
|
|
||||||
else:
|
|
||||||
node, others = parts
|
|
||||||
if node not in trunk:
|
|
||||||
trunk[node] = defaultdict(dict, ((FILE_MARKER, []),))
|
|
||||||
attach(others, trunk[node])
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief display a specific path tree field
|
|
||||||
##
|
|
||||||
def prettify(d, indent=0):
|
|
||||||
for key, value in d.iteritems():
|
|
||||||
if key == FILE_MARKER:
|
|
||||||
if value:
|
|
||||||
debug.debug(' ' * indent + str(value))
|
|
||||||
else:
|
|
||||||
debug.debug(' ' * indent + str(key))
|
|
||||||
if isinstance(value, dict):
|
|
||||||
prettify(value, indent+1)
|
|
||||||
else:
|
|
||||||
debug.debug(' ' * (indent+1) + str(value))
|
|
||||||
|
|
||||||
|
|
||||||
def generate_tree(treedata, package, tree = []):
|
|
||||||
data = ""
|
|
||||||
tmpPath = "?tree?"
|
|
||||||
if len(tree) != 0:
|
|
||||||
tmpPath = ""
|
|
||||||
for elem in tree:
|
|
||||||
if tmpPath != "":
|
|
||||||
tmpPath += '/'
|
|
||||||
tmpPath += elem
|
|
||||||
if len(tree) == 0:
|
|
||||||
data +=' ' + convert_folder_in_base_id(tmpPath, package) + ' /* ' + package + ' */ = {\n'
|
|
||||||
else:
|
|
||||||
data +=' ' + convert_folder_in_base_id(tmpPath, package) + ' /* ' + tree[-1] + ' */ = {\n'
|
|
||||||
data +=' isa = PBXGroup;\n'
|
|
||||||
data +=' children = (\n'
|
|
||||||
"""
|
|
||||||
data +=' FFBA2F8B187F44AE0034CC66 /* AppDelegate.h */,\n'
|
|
||||||
data +=' FFBA2F8C187F44AE0034CC66 /* AppDelegate.m */,\n'
|
|
||||||
data +=' FFBA2F8E187F44AE0034CC66 /* Main_iPhone.storyboard */,\n'
|
|
||||||
data +=' FFBA2F91187F44AE0034CC66 /* Main_iPad.storyboard */,\n'
|
|
||||||
data +=' FFBA2F94187F44AE0034CC66 /* Shader.fsh */,\n'
|
|
||||||
data +=' FFBA2F96187F44AE0034CC66 /* Shader.vsh */,\n'
|
|
||||||
data +=' FFBA2F98187F44AE0034CC66 /* ViewController.h */,\n'
|
|
||||||
data +=' FFBA2F99187F44AE0034CC66 /* ViewController.m */,\n'
|
|
||||||
data +=' FFBA2F9B187F44AE0034CC66 /* Images.xcassets */,\n'
|
|
||||||
data +=' FFBA2F83187F44AE0034CC66 /* Supporting Files */,\n'
|
|
||||||
"""
|
|
||||||
for key, value in treedata.iteritems():
|
|
||||||
if key == FILE_MARKER:
|
|
||||||
for file in value:
|
|
||||||
data +=' ' + convert_folder_in_base_id(tmpPath + '/' + file, package) + ' /* ' + file + ' */,\n'
|
|
||||||
else:
|
|
||||||
# TODO : Check if folder is empty ...
|
|
||||||
data +=' ' + convert_folder_in_base_id(tmpPath + '/' + key, package) + ' /* ' + key + ' */,\n'
|
|
||||||
"""
|
|
||||||
debug.debug(' ' * indent + str(key))
|
|
||||||
if isinstance(value, dict):
|
|
||||||
prettify(value, indent+1)
|
|
||||||
else:
|
|
||||||
debug.debug(' ' * (indent+1) + str(value))
|
|
||||||
"""
|
|
||||||
data +=' );\n'
|
|
||||||
if len(tree) == 0:
|
|
||||||
data +=' path = ' + package + ';\n'
|
|
||||||
else:
|
|
||||||
data +=' path = ' + tree[-1] + ';\n'
|
|
||||||
data +=' sourceTree = "<group>";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
# generate all subFolder :
|
|
||||||
for key, value in treedata.iteritems():
|
|
||||||
if key == FILE_MARKER:
|
|
||||||
continue
|
|
||||||
tree.append(key)
|
|
||||||
data += generate_tree(value, package, tree)
|
|
||||||
tree.pop()
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
XCodeTypeElements = {
|
|
||||||
'a': ('archive.ar', 'PBXFrameworksBuildPhase', ''),
|
|
||||||
'xcodeproj': ('wrapper.pb-project', None, '""'),
|
|
||||||
'app': ('wrapper.application', None, ''),
|
|
||||||
'framework': ('wrapper.framework', 'PBXFrameworksBuildPhase', 'SDKROOT'),
|
|
||||||
'dylib': ('compiled.mach-o.dylib', 'PBXFrameworksBuildPhase', '"<group>"'),
|
|
||||||
'h': ('sourcecode.c.h', None, '"<group>"'),
|
|
||||||
'H': ('sourcecode.c.h', None, '"<group>"'),
|
|
||||||
'hpp': ('sourcecode.c.h', None, '"<group>"'),
|
|
||||||
'hxx': ('sourcecode.c.h', None, '"<group>"'),
|
|
||||||
'S': ('sourcecode.asm', 'PBXSourcesBuildPhase', '"<group>"'),
|
|
||||||
's': ('sourcecode.asm', 'PBXSourcesBuildPhase', '"<group>"'),
|
|
||||||
'c': ('sourcecode.c.c', 'PBXSourcesBuildPhase', '"<group>"'),
|
|
||||||
'cpp': ('sourcecode.cpp.cpp', 'PBXSourcesBuildPhase', '"<group>"'),
|
|
||||||
'cxx': ('sourcecode.cpp.cpp', 'PBXSourcesBuildPhase', '"<group>"'),
|
|
||||||
'm': ('sourcecode.c.objc', 'PBXSourcesBuildPhase', '"<group>"'),
|
|
||||||
'j': ('sourcecode.c.objc', 'PBXSourcesBuildPhase', '"<group>"'),
|
|
||||||
'mm': ('sourcecode.cpp.objcpp', 'PBXSourcesBuildPhase', '"<group>"'),
|
|
||||||
'icns': ('image.icns', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'nib': ('wrapper.nib', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'plist': ('text.plist.xml', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'json': ('text.json', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'rtf': ('text.rtf', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'png': ('image.png', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'tiff': ('image.tiff', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'txt': ('text', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'fsh': ('sourcecode.glsl', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'frag': ('sourcecode.glsl', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'vsh': ('sourcecode.glsl', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'vert': ('sourcecode.glsl', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'svg': ('image.png', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'xml': ('sourcecode.xml', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'prog': ('text.xml', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'ttf': ('text', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'conf': ('text', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'emf': ('text', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'xib': ('file.xib', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'strings': ('text.plist.strings', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'bundle': ('wrapper.plug-in', 'PBXResourcesBuildPhase', '"<group>"'),
|
|
||||||
'storyboard':('file.storyboard', 'PBXResourcesBuildPhase', '"<group>"')
|
|
||||||
}
|
|
||||||
|
|
||||||
class ExtProjectGeneratorXCode(lutinExtProjectGenerator.ExtProjectGenerator):
|
|
||||||
def __init__(self):
|
|
||||||
lutinExtProjectGenerator.ExtProjectGenerator.__init__(self, "XCode")
|
|
||||||
self.baseId = "FFFFFFFFFFFFFFFFFF"
|
|
||||||
|
|
||||||
# set default framwork:
|
|
||||||
self.add_files("Frameworks",
|
|
||||||
"System/Library/Frameworks",
|
|
||||||
[ "Foundation.framework",
|
|
||||||
"CoreGraphics.framework",
|
|
||||||
"UIKit.framework",
|
|
||||||
"GLKit.framework",
|
|
||||||
"OpenGLES.framework",
|
|
||||||
"XCTest.framework" ]);
|
|
||||||
|
|
||||||
def set_project_name(self, name):
|
|
||||||
self.name = name
|
|
||||||
self.baseId = convert_name_in_base_id(name)
|
|
||||||
|
|
||||||
def add_files(self, group, basePath, srcList):
|
|
||||||
if group not in self.groups.keys() :
|
|
||||||
self.groups[group] = {
|
|
||||||
"list-files" : [],
|
|
||||||
"extra-flags" : []
|
|
||||||
}
|
|
||||||
for element in srcList:
|
|
||||||
debug.info("plop : " + str(element))
|
|
||||||
debug.info("plop : " + str(basePath))
|
|
||||||
path = basePath + "/" + element
|
|
||||||
pos = path.rfind('/')
|
|
||||||
simpleName = path
|
|
||||||
if pos >= 0:
|
|
||||||
simpleName = path[pos+1:]
|
|
||||||
pos = simpleName.rfind('.')
|
|
||||||
extention = "";
|
|
||||||
if pos >= 0:
|
|
||||||
extention = simpleName[pos+1:]
|
|
||||||
|
|
||||||
self.groups[group]["list-files"].append({
|
|
||||||
"path" : path,
|
|
||||||
"name" : simpleName,
|
|
||||||
"extention":extention,
|
|
||||||
"declare-name":element})
|
|
||||||
|
|
||||||
def add_data_file(self, basePath, srcList):
|
|
||||||
realBasePath = os.path.realpath(basePath)
|
|
||||||
if realBasePath[-1] == "/":
|
|
||||||
realBasePath = realBasePath[:-1]
|
|
||||||
debug.debug("add data file : " + str(srcList))
|
|
||||||
for realName,destName in srcList:
|
|
||||||
tools.copy_file(realBasePath+'/'+realName, 'out/iOs/' + self.name + '/data/' + destName, force=True)
|
|
||||||
self.add_files("data", 'out/iOs/' + self.name + 'xcodeprj/data', [destName])
|
|
||||||
|
|
||||||
def add_data_folder(self, basePath, srcList):
|
|
||||||
realBasePath = basePath
|
|
||||||
if realBasePath[-1] == "/":
|
|
||||||
realBasePath = realBasePath[:-1]
|
|
||||||
debug.debug("add data folder : " + str(srcList))
|
|
||||||
for inputPath,outputPath in srcList:
|
|
||||||
tmpPath = os.path.dirname(os.path.realpath(realBasePath + '/' + inputPath))
|
|
||||||
tmpRule = os.path.basename(inputPath)
|
|
||||||
debug.warning(" add folder : '" + tmpPath + "' rule : '" + tmpRule + "'")
|
|
||||||
for root, dirnames, filenames in os.walk(tmpPath):
|
|
||||||
tmpList = filenames
|
|
||||||
if len(tmpRule)>0:
|
|
||||||
tmpList = fnmatch.filter(filenames, tmpRule)
|
|
||||||
# Import the module :
|
|
||||||
for cycleFile in tmpList:
|
|
||||||
#for cycleFile in filenames:
|
|
||||||
self.add_data_file(tmpPath, [[cycleFile, outputPath+cycleFile]])
|
|
||||||
|
|
||||||
def generate_project_file(self):
|
|
||||||
|
|
||||||
|
|
||||||
#debug.error(" list : " + str(self.groups))
|
|
||||||
|
|
||||||
data ='// !$*UTF8*$!\n'
|
|
||||||
data +='{\n'
|
|
||||||
data +=' archiveVersion = 1;\n'
|
|
||||||
data +=' classes = {\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' objectVersion = 46;\n'
|
|
||||||
data +=' objects = {\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXBuildFile section */\n'
|
|
||||||
for group in self.groups:
|
|
||||||
element = self.groups[group]
|
|
||||||
for files in element["list-files"]:
|
|
||||||
debug.debug(" PBXBuildFile ?? " + str(files))
|
|
||||||
if files["extention"] in XCodeTypeElements.keys():
|
|
||||||
if XCodeTypeElements[files["extention"]][1] == "PBXSourcesBuildPhase" \
|
|
||||||
or XCodeTypeElements[files["extention"]][1] == "PBXFrameworksBuildPhase"\
|
|
||||||
or XCodeTypeElements[files["extention"]][1] == "PBXSourcesBuildPhase"\
|
|
||||||
or XCodeTypeElements[files["extention"]][1] == "PBXVariantGroup":
|
|
||||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group)
|
|
||||||
data +=' /* ' + files["name"] + ' in ' + group + ' */ = {'
|
|
||||||
data +=' isa = PBXBuildFile;'
|
|
||||||
data +=' fileRef = ' + convert_folder_in_base_id(files["declare-name"], group) + ';'
|
|
||||||
data +=' };\n'
|
|
||||||
data +='/* End PBXBuildFile section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXContainerItemProxy section */\n'
|
|
||||||
|
|
||||||
# I did not understand this section ...
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXContainerItemProxy?", self.name) + ' /* PBXContainerItemProxy */ = {\n'
|
|
||||||
data +=' isa = PBXContainerItemProxy;\n'
|
|
||||||
data +=' containerPortal = ' + convert_folder_in_base_id("?PBXProject?", self.name) + ' /* Project object */;\n'
|
|
||||||
data +=' proxyType = 1;\n'
|
|
||||||
data +=' remoteGlobalIDString = ' + convert_folder_in_base_id("?PBXNativeTarget?sectio", self.name) + ';\n'
|
|
||||||
data +=' remoteInfo = ' + self.name + ';\n'
|
|
||||||
data +=' };\n'
|
|
||||||
|
|
||||||
data +='/* End PBXContainerItemProxy section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXFileReference section */\n'
|
|
||||||
|
|
||||||
data +=' ' + convert_folder_in_base_id("?app?", self.name) + ' /* ' + self.name + '.app */ = {\n'
|
|
||||||
data +=' isa = PBXFileReference;\n'
|
|
||||||
data +=' explicitFileType = wrapper.application;\n'
|
|
||||||
data +=' includeInIndex = 0;\n'
|
|
||||||
data +=' path = ' + self.name + '.app;\n'
|
|
||||||
data +=' sourceTree = BUILT_PRODUCTS_DIR;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
for group in self.groups:
|
|
||||||
element = self.groups[group]
|
|
||||||
for files in element["list-files"]:
|
|
||||||
debug.debug(" PBXBuildFile ?? " + str(files))
|
|
||||||
data +=' /* ' + files["name"] + ' */\n'
|
|
||||||
if files["extention"] in XCodeTypeElements.keys():
|
|
||||||
data +=' ' + convert_folder_in_base_id(files["declare-name"], group) + ' = {'
|
|
||||||
data +=' isa = PBXBuildFile;'
|
|
||||||
data +=' lastKnownFileType = ' + XCodeTypeElements[files["extention"]][0] + ';'
|
|
||||||
data +=' path = ' + files["path"] + ';'
|
|
||||||
data +=' name = ' + files["name"] + ';'
|
|
||||||
data +=' sourceTree = ' + XCodeTypeElements[files["extention"]][2] + '; };\n'
|
|
||||||
else:
|
|
||||||
data +=' ' + convert_folder_in_base_id(files["declare-name"], group) + ' = {'
|
|
||||||
data +=' isa = PBXBuildFile;'
|
|
||||||
#data +=' lastKnownFileType = ' + XCodeTypeElements[files["extention"]][0] + ';'
|
|
||||||
data +=' path = ' + files["path"] + ';'
|
|
||||||
data +=' name = ' + files["name"] + ';'
|
|
||||||
data +=' sourceTree = "<group>"; };\n'
|
|
||||||
|
|
||||||
data +='/* End PBXFileReference section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXFrameworksBuildPhase section */\n'
|
|
||||||
|
|
||||||
data +=' ' + convert_folder_in_base_id("?Frameworks?", self.name) + ' /* Frameworks */ = {\n'
|
|
||||||
data +=' isa = PBXFrameworksBuildPhase;\n'
|
|
||||||
data +=' buildActionMask = 2147483647;\n'
|
|
||||||
data +=' files = (\n'
|
|
||||||
for group in self.groups:
|
|
||||||
element = self.groups[group]
|
|
||||||
for files in element["list-files"]:
|
|
||||||
if files["extention"] not in XCodeTypeElements.keys():
|
|
||||||
continue
|
|
||||||
if XCodeTypeElements[files["extention"]][1] == "PBXFrameworksBuildPhase":
|
|
||||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group)
|
|
||||||
data +=' /* ' + files["name"] + ' in ' + group + '*/,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' runOnlyForDeploymentPostprocessing = 0;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
|
|
||||||
data +='/* End PBXFrameworksBuildPhase section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXGroup section */\n'
|
|
||||||
|
|
||||||
data +=' ' + convert_folder_in_base_id("?mainTreeGroup?", self.name) + ' = {\n'
|
|
||||||
data +=' isa = PBXGroup;\n'
|
|
||||||
data +=' children = (\n'
|
|
||||||
for group in self.groups:
|
|
||||||
data +=' ' + convert_folder_in_base_id("?tree?", group) + ' /* ' + group + ' */,\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?tree?", "Products") + ' /* Products */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' sourceTree = "<group>";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?tree?", "Products") + ' /* Products */ = {\n'
|
|
||||||
data +=' isa = PBXGroup;\n'
|
|
||||||
data +=' children = (\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?app?", self.name) + ' /* ' + self.name + '.app */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' name = Products;\n'
|
|
||||||
data +=' sourceTree = "<group>";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
# treeview :
|
|
||||||
for group in self.groups:
|
|
||||||
element = self.groups[group]
|
|
||||||
main_dict = defaultdict(dict, ((FILE_MARKER, []),))
|
|
||||||
for line in element["list-files"]:
|
|
||||||
attach(line["declare-name"], main_dict)
|
|
||||||
#prettify(main_dict);
|
|
||||||
data += generate_tree(main_dict, group)
|
|
||||||
|
|
||||||
data +='/* End PBXGroup section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXNativeTarget section */\n'
|
|
||||||
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?sectio", self.name) + ' /* edn */ = {\n'
|
|
||||||
data +=' isa = PBXNativeTarget;\n'
|
|
||||||
data +=' buildConfigurationList = ' + convert_folder_in_base_id("?PBXNativeTarget?", self.name) + ' /* Build configuration list for PBXNativeTarget "edn" */;\n'
|
|
||||||
data +=' buildPhases = (\n'
|
|
||||||
data +=' FFBA2F71187F44AE0034CC66 /* Sources */,\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?Frameworks?", self.name) + ' /* Frameworks */,\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?Resources?", self.name) + ' /* Resources */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' buildRules = (\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' dependencies = (\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' name = edn;\n'
|
|
||||||
data +=' productName = edn;\n'
|
|
||||||
data +=' productReference = ' + convert_folder_in_base_id("?app?", self.name) + ' /* ' + self.name + '.app */;\n'
|
|
||||||
data +=' productType = "com.apple.product-type.application";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
|
|
||||||
data +='/* End PBXNativeTarget section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXProject section */\n'
|
|
||||||
|
|
||||||
data +=' ' + convert_folder_in_base_id("?Project-object?", self.name) + ' /* Project object */ = {\n'
|
|
||||||
data +=' isa = PBXProject;\n'
|
|
||||||
data +=' attributes = {\n'
|
|
||||||
data +=' LastUpgradeCheck = 0500;\n'
|
|
||||||
data +=' ORGANIZATIONNAME = "Edouard DUPIN";\n'
|
|
||||||
data +=' TargetAttributes = {\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?Project-object?targetAttribute", self.name) + ' = {\n'
|
|
||||||
data +=' TestTargetID = ' + convert_folder_in_base_id("?PBXNativeTarget?sectio", self.name) + ';\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' buildConfigurationList = ' + convert_folder_in_base_id("?PBXProject?", self.name) + ' /* Build configuration list for PBXProject "edn" */;\n'
|
|
||||||
data +=' compatibilityVersion = "Xcode 3.2";\n'
|
|
||||||
data +=' developmentRegion = English;\n'
|
|
||||||
data +=' hasScannedForEncodings = 0;\n'
|
|
||||||
data +=' knownRegions = (\n'
|
|
||||||
data +=' en,\n'
|
|
||||||
data +=' Base,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' mainGroup = ' + convert_folder_in_base_id("?mainTreeGroup?", self.name) + ';\n'
|
|
||||||
data +=' productRefGroup = ' + convert_folder_in_base_id("?tree?", "Products") + ' /* Products */;\n'
|
|
||||||
data +=' projectDirPath = "";\n'
|
|
||||||
data +=' projectRoot = "";\n'
|
|
||||||
data +=' targets = (\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?sectio", self.name) + ' /* edn */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +='/* End PBXProject section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXResourcesBuildPhase section */\n'
|
|
||||||
|
|
||||||
data +=' ' + convert_folder_in_base_id("?Resources?", self.name) + ' /* Resources */ = {\n'
|
|
||||||
data +=' isa = PBXResourcesBuildPhase;\n'
|
|
||||||
data +=' buildActionMask = 2147483647;\n'
|
|
||||||
data +=' files = (\n'
|
|
||||||
# list of all resources to copy
|
|
||||||
for group in self.groups:
|
|
||||||
element = self.groups[group]
|
|
||||||
for files in element["list-files"]:
|
|
||||||
if files["extention"] in XCodeTypeElements.keys():
|
|
||||||
if XCodeTypeElements[files["extention"]][1] == "PBXResourcesBuildPhase":
|
|
||||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group) + ' = {'
|
|
||||||
data +=' /* ' + files["name"] + ' in ' + group + ' */'
|
|
||||||
data +=' ,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' runOnlyForDeploymentPostprocessing = 0;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
|
|
||||||
data +='/* End PBXResourcesBuildPhase section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXSourcesBuildPhase section */\n'
|
|
||||||
|
|
||||||
data +=' FFBA2F71187F44AE0034CC66 /* Sources */ = {\n'
|
|
||||||
data +=' isa = PBXSourcesBuildPhase;\n'
|
|
||||||
data +=' buildActionMask = 2147483647;\n'
|
|
||||||
data +=' files = (\n'
|
|
||||||
# list of all file to compile ...
|
|
||||||
# TODO : review this ==> generate to many files ...
|
|
||||||
for group in self.groups:
|
|
||||||
element = self.groups[group]
|
|
||||||
for files in element["list-files"]:
|
|
||||||
if files["extention"] not in XCodeTypeElements.keys():
|
|
||||||
continue
|
|
||||||
if XCodeTypeElements[files["extention"]][1] == "PBXSourcesBuildPhase":
|
|
||||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group)
|
|
||||||
data +=' /* ' + group + " : " + files["name"] + ' */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' runOnlyForDeploymentPostprocessing = 0;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
|
|
||||||
data +='/* End PBXSourcesBuildPhase section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXTargetDependency section */\n'
|
|
||||||
# nothing ...
|
|
||||||
data +='/* End PBXTargetDependency section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin PBXVariantGroup section */\n'
|
|
||||||
# not really needed, because it is for internal system data position ==> maybe change it if necessary ...
|
|
||||||
"""
|
|
||||||
for group in self.groups:
|
|
||||||
element = self.groups[group]
|
|
||||||
for files in element["list-files"]:
|
|
||||||
if files["extention"] not in XCodeTypeElements.keys():
|
|
||||||
continue
|
|
||||||
if XCodeTypeElements[files["extention"]][1] == "PBXSourcesBuildPhase":
|
|
||||||
data +=' ' + convert_folder_in_base_id(files["declare-name"] + '_PBXBuildFile', group)
|
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
data +=' FFBA2F85187F44AE0034CC66 /* InfoPlist.strings */ = {\n'
|
|
||||||
data +=' isa = PBXVariantGroup;\n'
|
|
||||||
data +=' children = (\n'
|
|
||||||
data +=' FFBA2F86187F44AE0034CC66 /* en */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' name = InfoPlist.strings;\n'
|
|
||||||
data +=' sourceTree = "<group>";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' FFBA2F8E187F44AE0034CC66 /* Main_iPhone.storyboard */ = {\n'
|
|
||||||
data +=' isa = PBXVariantGroup;\n'
|
|
||||||
data +=' children = (\n'
|
|
||||||
data +=' FFBA2F8F187F44AE0034CC66 /* Base */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' name = Main_iPhone.storyboard;\n'
|
|
||||||
data +=' sourceTree = "<group>";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' FFBA2F91187F44AE0034CC66 /* Main_iPad.storyboard */ = {\n'
|
|
||||||
data +=' isa = PBXVariantGroup;\n'
|
|
||||||
data +=' children = (\n'
|
|
||||||
data +=' FFBA2F92187F44AE0034CC66 /* Base */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' name = Main_iPad.storyboard;\n'
|
|
||||||
data +=' sourceTree = "<group>";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' FFBA2FAB187F44AF0034CC66 /* InfoPlist.strings */ = {\n'
|
|
||||||
data +=' isa = PBXVariantGroup;\n'
|
|
||||||
data +=' children = (\n'
|
|
||||||
data +=' FFBA2FAC187F44AF0034CC66 /* en */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' name = InfoPlist.strings;\n'
|
|
||||||
data +=' sourceTree = "<group>";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
"""
|
|
||||||
data +='/* End PBXVariantGroup section */\n'
|
|
||||||
data +='\n'
|
|
||||||
data +='/* Begin XCBuildConfiguration section */\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXProject?Debug", self.name) + ' /* Debug */ = {\n'
|
|
||||||
data +=' isa = XCBuildConfiguration;\n'
|
|
||||||
data +=' buildSettings = {\n'
|
|
||||||
data +=' ALWAYS_SEARCH_USER_PATHS = NO;\n'
|
|
||||||
data +=' ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";\n'
|
|
||||||
data +=' CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";\n'
|
|
||||||
data +=' CLANG_CXX_LIBRARY = "libc++";\n'
|
|
||||||
data +=' CLANG_ENABLE_MODULES = YES;\n'
|
|
||||||
data +=' CLANG_ENABLE_OBJC_ARC = YES;\n'
|
|
||||||
data +=' CLANG_WARN_BOOL_CONVERSION = YES;\n'
|
|
||||||
data +=' CLANG_WARN_CONSTANT_CONVERSION = YES;\n'
|
|
||||||
data +=' CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n'
|
|
||||||
data +=' CLANG_WARN_EMPTY_BODY = YES;\n'
|
|
||||||
data +=' CLANG_WARN_ENUM_CONVERSION = YES;\n'
|
|
||||||
data +=' CLANG_WARN_INT_CONVERSION = YES;\n'
|
|
||||||
data +=' CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n'
|
|
||||||
data +=' CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n'
|
|
||||||
data +=' "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";\n'
|
|
||||||
data +=' COPY_PHASE_STRIP = NO;\n'
|
|
||||||
data +=' GCC_C_LANGUAGE_STANDARD = gnu99;\n'
|
|
||||||
data +=' GCC_DYNAMIC_NO_PIC = NO;\n'
|
|
||||||
data +=' GCC_OPTIMIZATION_LEVEL = 0;\n'
|
|
||||||
data +=' GCC_PREPROCESSOR_DEFINITIONS = (\n'
|
|
||||||
data +=' "DEBUG=1",\n'
|
|
||||||
data +=' "$(inherited)",\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' GCC_SYMBOLS_PRIVATE_EXTERN = NO;\n'
|
|
||||||
data +=' GCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n'
|
|
||||||
data +=' GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n'
|
|
||||||
data +=' GCC_WARN_UNDECLARED_SELECTOR = YES;\n'
|
|
||||||
data +=' GCC_WARN_UNINITIALIZED_AUTOS = YES;\n'
|
|
||||||
data +=' GCC_WARN_UNUSED_FUNCTION = YES;\n'
|
|
||||||
data +=' GCC_WARN_UNUSED_VARIABLE = YES;\n'
|
|
||||||
data +=' IPHONEOS_DEPLOYMENT_TARGET = 7.0;\n'
|
|
||||||
data +=' ONLY_ACTIVE_ARCH = YES;\n'
|
|
||||||
data +=' SDKROOT = iphoneos;\n'
|
|
||||||
data +=' TARGETED_DEVICE_FAMILY = "1,2";\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' name = Debug;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXProject?Release", self.name) + ' /* Release */ = {\n'
|
|
||||||
data +=' isa = XCBuildConfiguration;\n'
|
|
||||||
data +=' buildSettings = {\n'
|
|
||||||
data +=' ALWAYS_SEARCH_USER_PATHS = NO;\n'
|
|
||||||
data +=' ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";\n'
|
|
||||||
data +=' CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";\n'
|
|
||||||
data +=' CLANG_CXX_LIBRARY = "libc++";\n'
|
|
||||||
data +=' CLANG_ENABLE_MODULES = YES;\n'
|
|
||||||
data +=' CLANG_ENABLE_OBJC_ARC = YES;\n'
|
|
||||||
data +=' CLANG_WARN_BOOL_CONVERSION = YES;\n'
|
|
||||||
data +=' CLANG_WARN_CONSTANT_CONVERSION = YES;\n'
|
|
||||||
data +=' CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n'
|
|
||||||
data +=' CLANG_WARN_EMPTY_BODY = YES;\n'
|
|
||||||
data +=' CLANG_WARN_ENUM_CONVERSION = YES;\n'
|
|
||||||
data +=' CLANG_WARN_INT_CONVERSION = YES;\n'
|
|
||||||
data +=' CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n'
|
|
||||||
data +=' CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n'
|
|
||||||
data +=' "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";\n'
|
|
||||||
data +=' COPY_PHASE_STRIP = YES;\n'
|
|
||||||
data +=' ENABLE_NS_ASSERTIONS = NO;\n'
|
|
||||||
data +=' GCC_C_LANGUAGE_STANDARD = gnu99;\n'
|
|
||||||
data +=' GCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n'
|
|
||||||
data +=' GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n'
|
|
||||||
data +=' GCC_WARN_UNDECLARED_SELECTOR = YES;\n'
|
|
||||||
data +=' GCC_WARN_UNINITIALIZED_AUTOS = YES;\n'
|
|
||||||
data +=' GCC_WARN_UNUSED_FUNCTION = YES;\n'
|
|
||||||
data +=' GCC_WARN_UNUSED_VARIABLE = YES;\n'
|
|
||||||
data +=' IPHONEOS_DEPLOYMENT_TARGET = 7.0;\n'
|
|
||||||
data +=' SDKROOT = iphoneos;\n'
|
|
||||||
data +=' TARGETED_DEVICE_FAMILY = "1,2";\n'
|
|
||||||
data +=' VALIDATE_PRODUCT = YES;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' name = Release;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?Debug", self.name) + ' /* Debug */ = {\n'
|
|
||||||
data +=' isa = XCBuildConfiguration;\n'
|
|
||||||
data +=' buildSettings = {\n'
|
|
||||||
data +=' ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n'
|
|
||||||
data +=' ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;\n'
|
|
||||||
data +=' GCC_PRECOMPILE_PREFIX_HEADER = YES;\n'
|
|
||||||
data +=' GCC_PREFIX_HEADER = "edn/edn-Prefix.pch";\n'
|
|
||||||
data +=' INFOPLIST_FILE = "edn/edn-Info.plist";\n'
|
|
||||||
data +=' PRODUCT_NAME = "$(TARGET_NAME)";\n'
|
|
||||||
data +=' WRAPPER_EXTENSION = app;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' name = Debug;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?Release", self.name) + ' /* Release */ = {\n'
|
|
||||||
data +=' isa = XCBuildConfiguration;\n'
|
|
||||||
data +=' buildSettings = {\n'
|
|
||||||
data +=' ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n'
|
|
||||||
data +=' ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;\n'
|
|
||||||
data +=' GCC_PRECOMPILE_PREFIX_HEADER = YES;\n'
|
|
||||||
data +=' GCC_PREFIX_HEADER = "edn/edn-Prefix.pch";\n'
|
|
||||||
data +=' INFOPLIST_FILE = "edn/edn-Info.plist";\n'
|
|
||||||
data +=' PRODUCT_NAME = "$(TARGET_NAME)";\n'
|
|
||||||
data +=' WRAPPER_EXTENSION = app;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' name = Release;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
|
|
||||||
data += '/* End XCBuildConfiguration section */\n'
|
|
||||||
data += '\n'
|
|
||||||
data += '/* Begin XCConfigurationList section */\n'
|
|
||||||
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXProject?", self.name) + ' /* Build configuration list for PBXProject "' + self.name + '" */ = {\n'
|
|
||||||
data +=' isa = XCConfigurationList;\n'
|
|
||||||
data +=' buildConfigurations = (\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXProject?Debug", self.name) + ' /* Debug */,\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXProject?Release", self.name) + ' /* Release */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' defaultConfigurationIsVisible = 0;\n'
|
|
||||||
data +=' defaultConfigurationName = Release;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?", self.name) + ' /* Build configuration list for PBXNativeTarget "PBXNativeTarget" */ = {\n'
|
|
||||||
data +=' isa = XCConfigurationList;\n'
|
|
||||||
data +=' buildConfigurations = (\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?Debug", self.name) + ' /* Debug */,\n'
|
|
||||||
data +=' ' + convert_folder_in_base_id("?PBXNativeTarget?Release", self.name) + ' /* Release */,\n'
|
|
||||||
data +=' );\n'
|
|
||||||
data +=' defaultConfigurationIsVisible = 0;\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +='/* End XCConfigurationList section */\n'
|
|
||||||
data +=' };\n'
|
|
||||||
data +=' rootObject = ' + convert_folder_in_base_id("?PBXProject?", self.name) + ' /* Project object */;\n'
|
|
||||||
data +='}\n'
|
|
||||||
|
|
||||||
#debug.info(data)
|
|
||||||
|
|
||||||
outName = 'out/iOs/' + self.name + '.xcodeproj/project.pbxproj'
|
|
||||||
tools.create_directory_of_file(outName)
|
|
||||||
tools.file_write_data(outName, data)
|
|
||||||
# TODO : Generate all dependency files ...
|
|
||||||
"""
|
|
||||||
# this is a file generated by xcode for his internal properties ...
|
|
||||||
# create workspace file:
|
|
||||||
data = '<?xml version="1.0" encoding="UTF-8"?>\n'
|
|
||||||
data += '<Workspace\n'
|
|
||||||
data += ' version = "1.0">\n'
|
|
||||||
data += ' <FileRef\n'
|
|
||||||
data += ' location = "self:' + self.name + '.xcodeproj">\n'
|
|
||||||
data += ' </FileRef>\n'
|
|
||||||
data += '</Workspace>\n'
|
|
||||||
|
|
||||||
outName = 'out/iOs/' + self.name + '.xcodeproj/project.xcworkspace/contents.xcworkspacedata'
|
|
||||||
tools.create_directory_of_file(outName)
|
|
||||||
tools.file_write_data(outName, data)
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
|
|
20
lutinHost.py
20
lutinHost.py
@@ -1,20 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
import lutinDebug as debug
|
|
||||||
|
|
||||||
# print os.name # ==> 'posix'
|
|
||||||
if platform.system() == "Linux":
|
|
||||||
OS = "Linux"
|
|
||||||
elif platform.system() == "Windows":
|
|
||||||
OS = "Windows"
|
|
||||||
elif platform.system() == "Darwin":
|
|
||||||
OS = "MacOs"
|
|
||||||
else:
|
|
||||||
debug.error("Unknow the Host OS ... '" + platform.system() + "'")
|
|
||||||
|
|
||||||
debug.debug(" host.OS = " + OS)
|
|
||||||
|
|
||||||
|
|
||||||
OS64BITS = sys.maxsize > 2**32
|
|
||||||
OS32BITS = OS64BITS==False
|
|
810
lutinModule.py
810
lutinModule.py
@@ -1,810 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import inspect
|
|
||||||
import fnmatch
|
|
||||||
import lutinModule as module
|
|
||||||
import lutinHost as host
|
|
||||||
import lutinTools
|
|
||||||
import lutinDebug as debug
|
|
||||||
import lutinHeritage as heritage
|
|
||||||
import lutinDepend as dependency
|
|
||||||
import lutinMultiprocess
|
|
||||||
import lutinEnv
|
|
||||||
|
|
||||||
class Module:
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Module class represent all system needed for a specific
|
|
||||||
## module like
|
|
||||||
## - type (bin/lib ...)
|
|
||||||
## - dependency
|
|
||||||
## - flags
|
|
||||||
## - files
|
|
||||||
## - ...
|
|
||||||
##
|
|
||||||
def __init__(self, file, moduleName, moduleType):
|
|
||||||
## Remove all variable to prevent error of multiple deffinition of the module ...
|
|
||||||
self.originFile=''
|
|
||||||
self.originFolder=''
|
|
||||||
# type of the module:
|
|
||||||
self.type='LIBRARY'
|
|
||||||
# Name of the module
|
|
||||||
self.name=moduleName
|
|
||||||
# Dependency list:
|
|
||||||
self.depends = []
|
|
||||||
# Documentation list:
|
|
||||||
self.documentation = None
|
|
||||||
# export PATH
|
|
||||||
self.export_path = []
|
|
||||||
self.local_path = []
|
|
||||||
self.export_flags_ld = []
|
|
||||||
self.export_flags_cc = []
|
|
||||||
self.export_flags_xx = []
|
|
||||||
self.export_flags_m = []
|
|
||||||
self.export_flags_mm = []
|
|
||||||
# list of all flags:
|
|
||||||
self.flags_ld = []
|
|
||||||
self.flags_cc = []
|
|
||||||
self.flags_xx = []
|
|
||||||
self.flags_m = []
|
|
||||||
self.flags_mm = []
|
|
||||||
self.flags_s = []
|
|
||||||
self.flags_ar = []
|
|
||||||
# sources list:
|
|
||||||
self.src = []
|
|
||||||
# copy files and folders:
|
|
||||||
self.imageToCopy = []
|
|
||||||
self.files = []
|
|
||||||
self.folders = []
|
|
||||||
self.isbuild = False
|
|
||||||
## end of basic INIT ...
|
|
||||||
if moduleType == 'BINARY' \
|
|
||||||
or moduleType == 'LIBRARY' \
|
|
||||||
or moduleType == 'PACKAGE' \
|
|
||||||
or moduleType == 'PREBUILD':
|
|
||||||
self.type=moduleType
|
|
||||||
else :
|
|
||||||
debug.error('for module "%s"' %moduleName)
|
|
||||||
debug.error(' ==> error : "%s" ' %moduleType)
|
|
||||||
raise 'Input value error'
|
|
||||||
self.originFile = file;
|
|
||||||
self.originFolder = lutinTools.get_current_path(self.originFile)
|
|
||||||
self.localHeritage = heritage.heritage(self)
|
|
||||||
|
|
||||||
self.packageProp = { "COMPAGNY_TYPE" : set(""),
|
|
||||||
"COMPAGNY_NAME" : set(""),
|
|
||||||
"COMPAGNY_NAME2" : set(""),
|
|
||||||
"MAINTAINER" : set([]),
|
|
||||||
#"ICON" : set(""),
|
|
||||||
"SECTION" : set([]),
|
|
||||||
"PRIORITY" : set(""),
|
|
||||||
"DESCRIPTION" : set(""),
|
|
||||||
"VERSION" : set("0.0.0"),
|
|
||||||
"VERSION_CODE" : "",
|
|
||||||
"NAME" : set("no-name"), # name of the application
|
|
||||||
"ANDROID_MANIFEST" : "", # By default generate the manifest
|
|
||||||
"ANDROID_JAVA_FILES" : ["DEFAULT"], # when user want to create his own services and activities
|
|
||||||
"ANDROID_RESOURCES" : [],
|
|
||||||
"ANDROID_APPL_TYPE" : "APPL", # the other mode is "WALLPAPER" ... and later "WIDGET"
|
|
||||||
"ANDROID_WALLPAPER_PROPERTIES" : [], # To create properties of the wallpaper (no use of EWOL display)
|
|
||||||
"RIGHT" : [],
|
|
||||||
"ADMOD_POSITION" : "top"
|
|
||||||
}
|
|
||||||
self.subHeritageList = None
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief add Some copilation flags for this module (and only this one)
|
|
||||||
##
|
|
||||||
def add_extra_compile_flags(self):
|
|
||||||
self.compile_flags_CC([
|
|
||||||
"-Wall",
|
|
||||||
"-Wsign-compare",
|
|
||||||
"-Wreturn-type",
|
|
||||||
"-Wint-to-pointer-cast",
|
|
||||||
"-Wno-write-strings",
|
|
||||||
"-Woverloaded-virtual",
|
|
||||||
"-Wnon-virtual-dtor",
|
|
||||||
"-Wno-unused-variable"]);
|
|
||||||
#only for gcc : "-Wunused-variable", "-Wunused-but-set-variable",
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief remove all unneeded warning on compilation ==> for extern libs ...
|
|
||||||
##
|
|
||||||
def remove_compile_warning(self):
|
|
||||||
self.compile_flags_CC([
|
|
||||||
"-Wno-int-to-pointer-cast"
|
|
||||||
]);
|
|
||||||
self.compile_flags_XX([
|
|
||||||
"-Wno-c++11-narrowing"
|
|
||||||
])
|
|
||||||
# only for gcc :"-Wno-unused-but-set-variable"
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for running gcc to compile a m++ file.
|
|
||||||
##
|
|
||||||
def compile_mm_to_o(self, file, binary, target, depancy):
|
|
||||||
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary,self.name,self.originFolder,file)
|
|
||||||
# create the command line befor requesting start:
|
|
||||||
cmdLine=lutinTools.list_to_str([
|
|
||||||
target.xx,
|
|
||||||
"-o", file_dst,
|
|
||||||
target.arch,
|
|
||||||
target.sysroot,
|
|
||||||
target.global_include_cc,
|
|
||||||
lutinTools.add_prefix("-I",self.export_path),
|
|
||||||
lutinTools.add_prefix("-I",self.local_path),
|
|
||||||
lutinTools.add_prefix("-I",depancy.path),
|
|
||||||
target.global_flags_cc,
|
|
||||||
target.global_flags_mm,
|
|
||||||
depancy.flags_cc,
|
|
||||||
depancy.flags_mm,
|
|
||||||
self.flags_mm,
|
|
||||||
self.flags_cc,
|
|
||||||
self.export_flags_mm,
|
|
||||||
self.export_flags_cc,
|
|
||||||
"-c -MMD -MP",
|
|
||||||
"-x objective-c++",
|
|
||||||
file_src])
|
|
||||||
# check the dependency for this file :
|
|
||||||
if False==dependency.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
|
||||||
return file_dst
|
|
||||||
lutinTools.create_directory_of_file(file_dst)
|
|
||||||
comment = ["m++", self.name, "<==", file]
|
|
||||||
#process element
|
|
||||||
lutinMultiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
|
||||||
return file_dst
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for running gcc to compile a m file.
|
|
||||||
##
|
|
||||||
def compile_m_to_o(self, file, binary, target, depancy):
|
|
||||||
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary,self.name,self.originFolder,file)
|
|
||||||
# create the command line befor requesting start:
|
|
||||||
cmdLine=lutinTools.list_to_str([
|
|
||||||
target.cc,
|
|
||||||
"-o", file_dst ,
|
|
||||||
target.arch,
|
|
||||||
target.sysroot,
|
|
||||||
target.global_include_cc,
|
|
||||||
lutinTools.add_prefix("-I",self.export_path),
|
|
||||||
lutinTools.add_prefix("-I",self.local_path),
|
|
||||||
lutinTools.add_prefix("-I",depancy.path),
|
|
||||||
target.global_flags_cc,
|
|
||||||
target.global_flags_m,
|
|
||||||
depancy.flags_cc,
|
|
||||||
depancy.flags_m,
|
|
||||||
self.flags_m,
|
|
||||||
self.flags_cc,
|
|
||||||
self.export_flags_m,
|
|
||||||
self.export_flags_cc,
|
|
||||||
"-c -MMD -MP",
|
|
||||||
"-x objective-c",
|
|
||||||
file_src])
|
|
||||||
# check the dependency for this file :
|
|
||||||
if False==dependency.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
|
||||||
return file_dst
|
|
||||||
lutinTools.create_directory_of_file(file_dst)
|
|
||||||
comment = ["m", self.name, "<==", file]
|
|
||||||
#process element
|
|
||||||
lutinMultiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
|
||||||
return file_dst
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for running gcc to compile a C++ file.
|
|
||||||
##
|
|
||||||
def compile_xx_to_o(self, file, binary, target, depancy):
|
|
||||||
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary,self.name,self.originFolder,file)
|
|
||||||
# create the command line befor requesting start:
|
|
||||||
cmdLine=lutinTools.list_to_str([
|
|
||||||
target.xx,
|
|
||||||
"-o", file_dst,
|
|
||||||
target.arch,
|
|
||||||
target.sysroot,
|
|
||||||
target.global_include_cc,
|
|
||||||
lutinTools.add_prefix("-I",self.export_path),
|
|
||||||
lutinTools.add_prefix("-I",self.local_path),
|
|
||||||
lutinTools.add_prefix("-I",depancy.path),
|
|
||||||
target.global_flags_cc,
|
|
||||||
target.global_flags_xx,
|
|
||||||
depancy.flags_cc,
|
|
||||||
depancy.flags_xx,
|
|
||||||
self.flags_xx,
|
|
||||||
self.flags_cc,
|
|
||||||
self.export_flags_xx,
|
|
||||||
self.export_flags_cc,
|
|
||||||
" -c -MMD -MP",
|
|
||||||
file_src])
|
|
||||||
# check the dependency for this file :
|
|
||||||
if False==dependency.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
|
||||||
return file_dst
|
|
||||||
lutinTools.create_directory_of_file(file_dst)
|
|
||||||
comment = ["c++", self.name, "<==", file]
|
|
||||||
#process element
|
|
||||||
lutinMultiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
|
||||||
return file_dst
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for running gcc to compile a C file.
|
|
||||||
##
|
|
||||||
def compile_cc_to_o(self, file, binary, target, depancy):
|
|
||||||
file_src, file_dst, file_depend, file_cmd = target.file_generate_object(binary,self.name,self.originFolder,file)
|
|
||||||
# create the command line befor requesting start:
|
|
||||||
cmdLine=lutinTools.list_to_str([
|
|
||||||
target.cc,
|
|
||||||
"-o", file_dst,
|
|
||||||
target.arch,
|
|
||||||
target.sysroot,
|
|
||||||
target.global_include_cc,
|
|
||||||
lutinTools.add_prefix("-I",self.export_path),
|
|
||||||
lutinTools.add_prefix("-I",self.local_path),
|
|
||||||
lutinTools.add_prefix("-I",depancy.path),
|
|
||||||
target.global_flags_cc,
|
|
||||||
depancy.flags_cc,
|
|
||||||
self.flags_cc,
|
|
||||||
self.export_flags_cc,
|
|
||||||
" -c -MMD -MP",
|
|
||||||
file_src])
|
|
||||||
|
|
||||||
# check the dependency for this file :
|
|
||||||
if False==dependency.need_re_build(file_dst, file_src, file_depend, file_cmd, cmdLine):
|
|
||||||
return file_dst
|
|
||||||
lutinTools.create_directory_of_file(file_dst)
|
|
||||||
comment = ["c", self.name, "<==", file]
|
|
||||||
# process element
|
|
||||||
lutinMultiprocess.run_in_pool(cmdLine, comment, file_cmd)
|
|
||||||
return file_dst
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for running ar.
|
|
||||||
##
|
|
||||||
def link_to_a(self, file, binary, target, depancy):
|
|
||||||
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, self.name,self.originFolder,file,"lib-static")
|
|
||||||
#$(Q)$(TARGET_AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $(PRIVATE_ALL_OBJECTS)
|
|
||||||
cmdLine=lutinTools.list_to_str([
|
|
||||||
target.ar,
|
|
||||||
target.global_flags_ar,
|
|
||||||
self.flags_ar,
|
|
||||||
file_dst,
|
|
||||||
file_src])#,
|
|
||||||
#depancy.src])
|
|
||||||
|
|
||||||
# check the dependency for this file :
|
|
||||||
if False==dependency.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) \
|
|
||||||
and False==dependency.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine):
|
|
||||||
return file_dst
|
|
||||||
lutinTools.create_directory_of_file(file_dst)
|
|
||||||
debug.print_element("StaticLib", self.name, "==>", file_dst)
|
|
||||||
# explicitly remove the destination to prevent error ...
|
|
||||||
if os.path.exists(file_dst) and os.path.isfile(file_dst):
|
|
||||||
os.remove(file_dst)
|
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
|
||||||
#$(Q)$(TARGET_RANLIB) $@
|
|
||||||
if target.ranlib != "":
|
|
||||||
cmdLineRanLib=lutinTools.list_to_str([
|
|
||||||
target.ranlib,
|
|
||||||
file_dst ])
|
|
||||||
lutinMultiprocess.run_command(cmdLineRanLib)
|
|
||||||
# write cmd line only after to prevent errors ...
|
|
||||||
lutinMultiprocess.store_command(cmdLine, file_cmd)
|
|
||||||
return file_dst
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for running gcc to link a shared library.
|
|
||||||
##
|
|
||||||
def link_to_so(self, file, binary, target, depancy, libName=""):
|
|
||||||
if libName=="":
|
|
||||||
libName = self.name
|
|
||||||
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, libName,self.originFolder,file,"lib-shared")
|
|
||||||
#create command Line
|
|
||||||
cmdLine=lutinTools.list_to_str([
|
|
||||||
target.xx,
|
|
||||||
"-o", file_dst,
|
|
||||||
target.global_sysroot,
|
|
||||||
target.arch,
|
|
||||||
"-shared",
|
|
||||||
file_src,
|
|
||||||
depancy.src,
|
|
||||||
self.flags_ld,
|
|
||||||
depancy.flags_ld,
|
|
||||||
target.global_flags_ld])
|
|
||||||
|
|
||||||
# check the dependency for this file :
|
|
||||||
if dependency.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) == False \
|
|
||||||
and dependency.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine) == False:
|
|
||||||
return tmpList[1]
|
|
||||||
lutinTools.create_directory_of_file(file_dst)
|
|
||||||
debug.print_element("SharedLib", libName, "==>", file_dst)
|
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
|
||||||
if "release"==target.buildMode \
|
|
||||||
or lutinEnv.get_force_strip_mode()==True:
|
|
||||||
# get the file size of the non strip file
|
|
||||||
originSize = lutinTools.file_size(file_dst);
|
|
||||||
debug.print_element("SharedLib(strip)", libName, "", "")
|
|
||||||
cmdLineStrip=lutinTools.list_to_str([
|
|
||||||
target.strip,
|
|
||||||
file_dst])
|
|
||||||
lutinMultiprocess.run_command(cmdLineStrip)
|
|
||||||
# get the stip size of the binary
|
|
||||||
stripSize = lutinTools.file_size(file_dst)
|
|
||||||
debug.debug("file reduce size : " + str(originSize/1024) + "ko ==> " + str(stripSize/1024) + "ko")
|
|
||||||
# write cmd line only after to prevent errors ...
|
|
||||||
lutinMultiprocess.store_command(cmdLine, file_cmd)
|
|
||||||
#debug.print_element("SharedLib", self.name, "==>", tmpList[1])
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for running gcc to link an executable.
|
|
||||||
##
|
|
||||||
def link_to_bin(self, file, binary, target, depancy):
|
|
||||||
file_src, file_dst, file_depend, file_cmd = target.generate_file(binary, self.name,self.originFolder,file,"bin")
|
|
||||||
#create comdLine :
|
|
||||||
cmdLine=lutinTools.list_to_str([
|
|
||||||
target.xx,
|
|
||||||
target.arch,
|
|
||||||
target.sysroot,
|
|
||||||
target.global_sysroot,
|
|
||||||
"-o", file_dst,
|
|
||||||
file_src,
|
|
||||||
depancy.src,
|
|
||||||
self.flags_ld,
|
|
||||||
depancy.flags_ld,
|
|
||||||
target.global_flags_ld])
|
|
||||||
# check the dependency for this file :
|
|
||||||
if False==dependency.need_re_package(file_dst, file_src, True, file_cmd, cmdLine) \
|
|
||||||
and False==dependency.need_re_package(file_dst, depancy.src, False, file_cmd, cmdLine):
|
|
||||||
return file_dst
|
|
||||||
lutinTools.create_directory_of_file(file_dst)
|
|
||||||
debug.print_element("Executable", self.name, "==>", file_dst)
|
|
||||||
|
|
||||||
lutinMultiprocess.run_command(cmdLine)
|
|
||||||
if "release"==target.buildMode \
|
|
||||||
or lutinEnv.get_force_strip_mode()==True:
|
|
||||||
# get the file size of the non strip file
|
|
||||||
originSize = lutinTools.file_size(file_dst);
|
|
||||||
debug.print_element("Executable(strip)", self.name, "", "")
|
|
||||||
cmdLineStrip=lutinTools.list_to_str([
|
|
||||||
target.strip,
|
|
||||||
file_dst])
|
|
||||||
lutinMultiprocess.run_command(cmdLineStrip)
|
|
||||||
# get the stip size of the binary
|
|
||||||
stripSize = lutinTools.file_size(file_dst)
|
|
||||||
debug.debug("file reduce size : " + str(originSize/1024) + "ko ==> " + str(stripSize/1024) + "ko")
|
|
||||||
# write cmd line only after to prevent errors ...
|
|
||||||
lutinMultiprocess.store_command(cmdLine, file_cmd)
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for copying files
|
|
||||||
##
|
|
||||||
def image_to_staging(self, binaryName, target):
|
|
||||||
for source, destination, sizeX, sizeY in self.imageToCopy:
|
|
||||||
extension = source[source.rfind('.'):]
|
|
||||||
if extension != ".png" \
|
|
||||||
and extension != ".jpg" \
|
|
||||||
and sizeX > 0:
|
|
||||||
debug.error("Can not manage image other than .png and jpg to resize : " + source);
|
|
||||||
displaySource = source
|
|
||||||
source = self.originFolder + "/" + source
|
|
||||||
if destination == "":
|
|
||||||
destination = source[source.rfind('/')+1:]
|
|
||||||
debug.verbose("Regenerate Destination : '" + destination + "'")
|
|
||||||
file_cmd = target.generate_file(binaryName, self.name, self.originFolder, destination, "image")[0]
|
|
||||||
if sizeX > 0:
|
|
||||||
debug.verbose("Image file : " + displaySource + " ==> " + destination + " resize=(" + str(sizeX) + "," + str(sizeY) + ")")
|
|
||||||
fileName, fileExtension = os.path.splitext(self.originFolder+"/" + source)
|
|
||||||
target.add_image_staging(source, destination, sizeX, sizeY, file_cmd)
|
|
||||||
else:
|
|
||||||
debug.verbose("Might copy file : " + displaySource + " ==> " + destination)
|
|
||||||
target.add_file_staging(source, destination, file_cmd)
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for copying files
|
|
||||||
##
|
|
||||||
def files_to_staging(self, binaryName, target):
|
|
||||||
for source, destination in self.files:
|
|
||||||
displaySource = source
|
|
||||||
source = self.originFolder + "/" + source
|
|
||||||
if destination == "":
|
|
||||||
destination = source[source.rfind('/')+1:]
|
|
||||||
debug.verbose("Regenerate Destination : '" + destination + "'")
|
|
||||||
file_cmd = target.generate_file(binaryName, self.name, self.originFolder, destination, "image")[0]
|
|
||||||
# TODO : when destination is missing ...
|
|
||||||
debug.verbose("Might copy file : " + displaySource + " ==> " + destination)
|
|
||||||
target.add_file_staging(source, destination, file_cmd)
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Commands for copying files
|
|
||||||
##
|
|
||||||
def folders_to_staging(self, binaryName, target):
|
|
||||||
for source, destination in self.folders:
|
|
||||||
debug.verbose("Might copy folder : " + source + "==>" + destination)
|
|
||||||
lutinTools.copy_anything_target(target, self.originFolder + "/" + source, destination)
|
|
||||||
|
|
||||||
# call here to build the module
|
|
||||||
def build(self, target, packageName):
|
|
||||||
# ckeck if not previously build
|
|
||||||
if target.is_module_build(self.name)==True:
|
|
||||||
if self.subHeritageList == None:
|
|
||||||
self.localHeritage = heritage.heritage(self)
|
|
||||||
return self.subHeritageList
|
|
||||||
# create the packege heritage
|
|
||||||
self.localHeritage = heritage.heritage(self)
|
|
||||||
|
|
||||||
if packageName==None \
|
|
||||||
and ( self.type=="BINARY" \
|
|
||||||
or self.type=="PACKAGE" ) :
|
|
||||||
# this is the endpoint binary ...
|
|
||||||
packageName = self.name
|
|
||||||
else :
|
|
||||||
# TODO : Set it better ...
|
|
||||||
None
|
|
||||||
|
|
||||||
# build dependency befor
|
|
||||||
listSubFileNeededTobuild = []
|
|
||||||
self.subHeritageList = heritage.HeritageList()
|
|
||||||
for dep in self.depends:
|
|
||||||
inheritList = target.build(dep, packageName)
|
|
||||||
# add at the heritage list :
|
|
||||||
self.subHeritageList.add_heritage_list(inheritList)
|
|
||||||
|
|
||||||
# build local sources
|
|
||||||
for file in self.src:
|
|
||||||
#debug.info(" " + self.name + " <== " + file);
|
|
||||||
fileExt = file.split(".")[-1]
|
|
||||||
if fileExt == "c" \
|
|
||||||
or fileExt == "C":
|
|
||||||
resFile = self.compile_cc_to_o(file, packageName, target, self.subHeritageList)
|
|
||||||
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, packageName, target, self.subHeritageList)
|
|
||||||
listSubFileNeededTobuild.append(resFile)
|
|
||||||
elif fileExt == "mm" \
|
|
||||||
or fileExt == "MM":
|
|
||||||
resFile = self.compile_mm_to_o(file, packageName, target, self.subHeritageList)
|
|
||||||
listSubFileNeededTobuild.append(resFile)
|
|
||||||
elif fileExt == "m" \
|
|
||||||
or fileExt == "M":
|
|
||||||
resFile = self.compile_m_to_o(file, packageName, target, self.subHeritageList)
|
|
||||||
listSubFileNeededTobuild.append(resFile)
|
|
||||||
else:
|
|
||||||
debug.verbose(" TODO : gcc " + self.originFolder + "/" + file)
|
|
||||||
# when multiprocess availlable, we need to synchronize here ...
|
|
||||||
lutinMultiprocess.pool_synchrosize()
|
|
||||||
|
|
||||||
# generate end point:
|
|
||||||
if self.type=='PREBUILD':
|
|
||||||
# nothing to add ==> just dependence
|
|
||||||
None
|
|
||||||
elif self.type=='LIBRARY':
|
|
||||||
resFile = self.link_to_a(listSubFileNeededTobuild, packageName, target, self.subHeritageList)
|
|
||||||
self.localHeritage.add_sources(resFile)
|
|
||||||
elif self.type=='BINARY':
|
|
||||||
resFile = self.link_to_bin(listSubFileNeededTobuild, packageName, target, self.subHeritageList)
|
|
||||||
# generate tree for this special binary
|
|
||||||
target.clean_module_tree()
|
|
||||||
self.build_tree(target, self.name)
|
|
||||||
target.copy_to_staging(self.name)
|
|
||||||
elif self.type=="PACKAGE":
|
|
||||||
if target.name=="Android":
|
|
||||||
# special case for android wrapper :
|
|
||||||
resFile = self.link_to_so(listSubFileNeededTobuild, packageName, target, self.subHeritageList, "libewol")
|
|
||||||
else:
|
|
||||||
resFile = self.link_to_bin(listSubFileNeededTobuild, packageName, target, self.subHeritageList)
|
|
||||||
target.clean_module_tree()
|
|
||||||
# generate tree for this special binary
|
|
||||||
self.build_tree(target, self.name)
|
|
||||||
target.copy_to_staging(self.name)
|
|
||||||
if target.endGeneratePackage==True:
|
|
||||||
# generate the package with his properties ...
|
|
||||||
target.make_package(self.name, self.packageProp, self.originFolder + "/..")
|
|
||||||
else:
|
|
||||||
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
|
||||||
|
|
||||||
self.subHeritageList.add_heritage(self.localHeritage)
|
|
||||||
# return local dependency ...
|
|
||||||
return self.subHeritageList
|
|
||||||
|
|
||||||
# call here to build the module
|
|
||||||
def build_tree(self, target, packageName):
|
|
||||||
# ckeck if not previously build
|
|
||||||
if target.is_module_buildTree(self.name)==True:
|
|
||||||
return
|
|
||||||
debug.verbose("build tree of " + self.name)
|
|
||||||
# add all the elements (first added only one keep ==> permit to everload sublib element)
|
|
||||||
self.image_to_staging(packageName, target)
|
|
||||||
self.files_to_staging(packageName, target)
|
|
||||||
self.folders_to_staging(packageName, target)
|
|
||||||
#build tree of all submodules
|
|
||||||
for dep in self.depends:
|
|
||||||
inherit = target.build_tree(dep, packageName)
|
|
||||||
|
|
||||||
|
|
||||||
# call here to clean the module
|
|
||||||
def clean(self, target):
|
|
||||||
if self.type=='PREBUILD':
|
|
||||||
# nothing to add ==> just dependence
|
|
||||||
None
|
|
||||||
elif self.type=='LIBRARY':
|
|
||||||
# remove folder of the lib ... for this targer
|
|
||||||
folderbuild = target.get_build_folder(self.name)
|
|
||||||
debug.info("remove folder : '" + folderbuild + "'")
|
|
||||||
lutinTools.remove_folder_and_sub_folder(folderbuild)
|
|
||||||
elif self.type=='BINARY' \
|
|
||||||
or self.type=='PACKAGE':
|
|
||||||
# remove folder of the lib ... for this targer
|
|
||||||
folderbuild = target.get_build_folder(self.name)
|
|
||||||
debug.info("remove folder : '" + folderbuild + "'")
|
|
||||||
lutinTools.remove_folder_and_sub_folder(folderbuild)
|
|
||||||
folderStaging = target.get_staging_folder(self.name)
|
|
||||||
debug.info("remove folder : '" + folderStaging + "'")
|
|
||||||
lutinTools.remove_folder_and_sub_folder(folderStaging)
|
|
||||||
else:
|
|
||||||
debug.error("Dit not know the element type ... (impossible case) type=" + self.type)
|
|
||||||
|
|
||||||
def append_and_check(self, listout, newElement, order):
|
|
||||||
for element in listout:
|
|
||||||
if element==newElement:
|
|
||||||
return
|
|
||||||
listout.append(newElement)
|
|
||||||
if True==order:
|
|
||||||
listout.sort()
|
|
||||||
|
|
||||||
def append_to_internalList(self, listout, list, order=False):
|
|
||||||
if type(list) == type(str()):
|
|
||||||
self.append_and_check(listout, list, order)
|
|
||||||
else:
|
|
||||||
# mulyiple imput in the list ...
|
|
||||||
for elem in list:
|
|
||||||
self.append_and_check(listout, elem, order)
|
|
||||||
|
|
||||||
def add_module_depend(self, list):
|
|
||||||
self.append_to_internalList(self.depends, list, True)
|
|
||||||
|
|
||||||
def add_export_path(self, list):
|
|
||||||
self.append_to_internalList(self.export_path, list)
|
|
||||||
|
|
||||||
def add_path(self, list):
|
|
||||||
self.append_to_internalList(self.local_path, list)
|
|
||||||
|
|
||||||
def add_export_flag_LD(self, list):
|
|
||||||
self.append_to_internalList(self.export_flags_ld, list)
|
|
||||||
|
|
||||||
def add_export_flag_CC(self, list):
|
|
||||||
self.append_to_internalList(self.export_flags_cc, list)
|
|
||||||
|
|
||||||
def add_export_flag_XX(self, list):
|
|
||||||
self.append_to_internalList(self.export_flags_xx, list)
|
|
||||||
|
|
||||||
def add_export_flag_M(self, list):
|
|
||||||
self.append_to_internalList(self.export_flags_m, list)
|
|
||||||
|
|
||||||
def add_export_flag_MM(self, list):
|
|
||||||
self.append_to_internalList(self.export_flags_mm, list)
|
|
||||||
|
|
||||||
# add the link flag at the module
|
|
||||||
def compile_flags_LD(self, list):
|
|
||||||
self.append_to_internalList(self.flags_ld, list)
|
|
||||||
|
|
||||||
def compile_flags_CC(self, list):
|
|
||||||
self.append_to_internalList(self.flags_cc, list)
|
|
||||||
|
|
||||||
def compile_flags_XX(self, list):
|
|
||||||
self.append_to_internalList(self.flags_xx, list)
|
|
||||||
|
|
||||||
def compile_flags_M(self, list):
|
|
||||||
self.append_to_internalList(self.flags_m, list)
|
|
||||||
|
|
||||||
def compile_flags_MM(self, list):
|
|
||||||
self.append_to_internalList(self.flags_mm, list)
|
|
||||||
|
|
||||||
def compile_flags_S(self, list):
|
|
||||||
self.append_to_internalList(self.flags_s, list)
|
|
||||||
|
|
||||||
def add_src_file(self, list):
|
|
||||||
self.append_to_internalList(self.src, list, True)
|
|
||||||
|
|
||||||
def copy_image(self, source, destination='', sizeX=-1, sizeY=-1):
|
|
||||||
self.imageToCopy.append([source, destination, sizeX, sizeY])
|
|
||||||
|
|
||||||
def copy_file(self, source, destination=''):
|
|
||||||
self.files.append([source, destination])
|
|
||||||
|
|
||||||
def copy_folder(self, source, destination=''):
|
|
||||||
self.folders.append([source, destination])
|
|
||||||
|
|
||||||
def print_list(self, description, list):
|
|
||||||
if len(list) > 0:
|
|
||||||
print ' %s' %description
|
|
||||||
for elem in list:
|
|
||||||
print ' %s' %elem
|
|
||||||
|
|
||||||
def display(self, target):
|
|
||||||
print '-----------------------------------------------'
|
|
||||||
print ' package : "%s"' %self.name
|
|
||||||
print '-----------------------------------------------'
|
|
||||||
print ' type:"%s"' %self.type
|
|
||||||
print ' file:"%s"' %self.originFile
|
|
||||||
print ' folder:"%s"' %self.originFolder
|
|
||||||
self.print_list('depends',self.depends)
|
|
||||||
self.print_list('flags_ld',self.flags_ld)
|
|
||||||
self.print_list('flags_cc',self.flags_cc)
|
|
||||||
self.print_list('flags_xx',self.flags_xx)
|
|
||||||
self.print_list('flags_m',self.flags_m)
|
|
||||||
self.print_list('flags_mm',self.flags_mm)
|
|
||||||
self.print_list('flags_s',self.flags_s)
|
|
||||||
self.print_list('src',self.src)
|
|
||||||
self.print_list('files',self.files)
|
|
||||||
self.print_list('folders',self.folders)
|
|
||||||
self.print_list('export_path',self.export_path)
|
|
||||||
self.print_list('export_flags_ld',self.export_flags_ld)
|
|
||||||
self.print_list('export_flags_cc',self.export_flags_cc)
|
|
||||||
self.print_list('export_flags_xx',self.export_flags_xx)
|
|
||||||
self.print_list('export_flags_m',self.export_flags_m)
|
|
||||||
self.print_list('export_flags_mm',self.export_flags_mm)
|
|
||||||
self.print_list('local_path',self.local_path)
|
|
||||||
|
|
||||||
def pkg_set(self, variable, value):
|
|
||||||
if "COMPAGNY_TYPE" == variable:
|
|
||||||
# com : Commercial
|
|
||||||
# net : Network??
|
|
||||||
# org : Organisation
|
|
||||||
# gov : Governement
|
|
||||||
# mil : Military
|
|
||||||
# edu : Education
|
|
||||||
# pri : Private
|
|
||||||
# museum : ...
|
|
||||||
if value not in ["com", "net", "org", "gov", "mil", "edu", "pri", "museum"]:
|
|
||||||
debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'")
|
|
||||||
else:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "COMPAGNY_NAME" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
val2 = value.lower()
|
|
||||||
val2 = val2.replace(' ', '')
|
|
||||||
val2 = val2.replace('-', '')
|
|
||||||
val2 = val2.replace('_', '')
|
|
||||||
self.packageProp["COMPAGNY_NAME2"] = val2
|
|
||||||
elif "ICON" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "MAINTAINER" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "SECTION" == variable:
|
|
||||||
# project section : (must be separate by coma
|
|
||||||
# refer to : http://packages.debian.org/sid/
|
|
||||||
# admin cli-mono comm database debian-installer
|
|
||||||
# debug doc editors electronics devel embedded
|
|
||||||
# fonts games gnome gnu-r gnustep graphics
|
|
||||||
# hamradio haskell httpd interpreters java
|
|
||||||
# kde kernel libdevel libs lisp localization
|
|
||||||
# mail math misc net news ocaml oldlibs otherosfs
|
|
||||||
# perl php python ruby science shells sound tex
|
|
||||||
# text utils vcs video virtual web x11 xfce zope ...
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "PRIORITY" == variable:
|
|
||||||
#list = ["required","important","standard","optional","extra"]
|
|
||||||
#if isinstance(value, list):
|
|
||||||
if value not in ["required", "important", "standard", "optional", "extra"]:
|
|
||||||
debug.error("can not set the value for this Input : '" + variable + "' : '" + value + "'")
|
|
||||||
else:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "DESCRIPTION" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "VERSION" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "VERSION_CODE" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "NAME" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "ANDROID_MANIFEST" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "ANDROID_JAVA_FILES" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "RIGHT" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "ANDROID_RESOURCES" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "ANDROID_APPL_TYPE" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "ADMOD_ID" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "APPLE_APPLICATION_IOS_ID" == variable:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
elif "ADMOD_POSITION" == variable:
|
|
||||||
if value in ["top", "bottom"]:
|
|
||||||
self.packageProp[variable] = value
|
|
||||||
else:
|
|
||||||
debug.error("not know pkg element : '" + variable + "' with value : '" + value + "' must be [top|bottom]")
|
|
||||||
else:
|
|
||||||
debug.error("not know pkg element : '" + variable + "'")
|
|
||||||
|
|
||||||
def pkg_add(self, variable, value):
|
|
||||||
# TODO : Check values...
|
|
||||||
self.packageProp[variable].append(value)
|
|
||||||
|
|
||||||
def ext_project_add_module(self, target, projectMng, addedModule = []):
|
|
||||||
if self.name in addedModule:
|
|
||||||
return
|
|
||||||
addedModule.append(self.name)
|
|
||||||
debug.verbose("add a module to the project generator :" + self.name)
|
|
||||||
debug.verbose("local path :" + self.originFolder)
|
|
||||||
projectMng.add_files(self.name, self.originFolder, self.src)
|
|
||||||
#projectMng.add_data_file(self.originFolder, self.files)
|
|
||||||
#projectMng.add_data_folder(self.originFolder, self.folders)
|
|
||||||
"""
|
|
||||||
for depend in self.depends:
|
|
||||||
target.project_add_module(depend, projectMng, addedModule)
|
|
||||||
"""
|
|
||||||
|
|
||||||
def create_project(self, target, projectMng):
|
|
||||||
projectMng.set_project_name(self.name)
|
|
||||||
self.ext_project_add_module(target, projectMng)
|
|
||||||
projectMng.generate_project_file()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
moduleList=[]
|
|
||||||
__startModuleName="lutin_"
|
|
||||||
|
|
||||||
def import_path(path):
|
|
||||||
global moduleList
|
|
||||||
matches = []
|
|
||||||
debug.debug('Start find sub File : "%s"' %path)
|
|
||||||
for root, dirnames, filenames in os.walk(path):
|
|
||||||
tmpList = fnmatch.filter(filenames, __startModuleName + "*.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', '')
|
|
||||||
moduleName = moduleName.replace(__startModuleName, '')
|
|
||||||
debug.debug("integrate module: '" + moduleName + "' from '" + os.path.join(root, filename) + "'")
|
|
||||||
moduleList.append([moduleName,os.path.join(root, filename)])
|
|
||||||
|
|
||||||
def load_module(target, name):
|
|
||||||
global moduleList
|
|
||||||
for mod in moduleList:
|
|
||||||
if mod[0] == name:
|
|
||||||
sys.path.append(os.path.dirname(mod[1]))
|
|
||||||
debug.verbose("import module : '" + __startModuleName + name + "'")
|
|
||||||
theModule = __import__(__startModuleName + name)
|
|
||||||
#try:
|
|
||||||
tmpElement = theModule.create(target)
|
|
||||||
#except:
|
|
||||||
#tmpElement = None
|
|
||||||
#debug.warning(" no function 'create' in the module : " + mod[0] + " from:'" + mod[1] + "'")
|
|
||||||
if (tmpElement == None) :
|
|
||||||
debug.debug("Request load module '" + name + "' not define for this platform")
|
|
||||||
else:
|
|
||||||
target.add_module(tmpElement)
|
|
||||||
|
|
||||||
def list_all_module():
|
|
||||||
global moduleList
|
|
||||||
tmpListName = []
|
|
||||||
for mod in moduleList:
|
|
||||||
tmpListName.append(mod[0])
|
|
||||||
return tmpListName
|
|
||||||
|
|
||||||
def list_all_module_with_desc():
|
|
||||||
global moduleList
|
|
||||||
tmpList = []
|
|
||||||
for mod in moduleList:
|
|
||||||
sys.path.append(os.path.dirname(mod[1]))
|
|
||||||
theModule = __import__("lutin_" + mod[0])
|
|
||||||
try:
|
|
||||||
tmpdesc = theModule.get_desc()
|
|
||||||
tmpList.append([mod[0], tmpdesc])
|
|
||||||
except:
|
|
||||||
debug.warning("has no naeme : " + mod[0])
|
|
||||||
tmpList.append([mod[0], ""])
|
|
||||||
return tmpList
|
|
||||||
|
|
||||||
|
|
@@ -1,177 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import sys
|
|
||||||
import lutinDebug as debug
|
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
import Queue
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import lutinTools
|
|
||||||
import lutinEnv
|
|
||||||
|
|
||||||
queueLock = threading.Lock()
|
|
||||||
workQueue = Queue.Queue()
|
|
||||||
currentThreadWorking = 0
|
|
||||||
threads = []
|
|
||||||
|
|
||||||
exitFlag = False # resuest stop of the thread
|
|
||||||
isinit = False # the thread are initialized
|
|
||||||
errorOccured = False # a thread have an error
|
|
||||||
processorAvaillable = 1 # number of CPU core availlable
|
|
||||||
|
|
||||||
def store_command(cmdLine, file):
|
|
||||||
# write cmd line only after to prevent errors ...
|
|
||||||
if file != "" \
|
|
||||||
and file != None:
|
|
||||||
# Create directory:
|
|
||||||
lutinTools.create_directory_of_file(file)
|
|
||||||
# Store the command Line:
|
|
||||||
file2 = open(file, "w")
|
|
||||||
file2.write(cmdLine)
|
|
||||||
file2.flush()
|
|
||||||
file2.close()
|
|
||||||
|
|
||||||
|
|
||||||
def run_command(cmdLine, storeCmdLine=""):
|
|
||||||
debug.debug(lutinEnv.print_pretty(cmdLine))
|
|
||||||
try:
|
|
||||||
retcode = subprocess.call(cmdLine, shell=True)
|
|
||||||
except OSError as e:
|
|
||||||
print >>sys.stderr, "Execution failed:", e
|
|
||||||
|
|
||||||
if retcode != 0:
|
|
||||||
global errorOccured
|
|
||||||
errorOccured = True
|
|
||||||
global exitFlag
|
|
||||||
exitFlag = True
|
|
||||||
if retcode == 2:
|
|
||||||
debug.error("can not compile file ... [keyboard interrrupt]")
|
|
||||||
else:
|
|
||||||
debug.error("can not compile file ... ret : " + str(retcode))
|
|
||||||
return
|
|
||||||
|
|
||||||
# write cmd line only after to prevent errors ...
|
|
||||||
store_command(cmdLine, storeCmdLine)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class myThread(threading.Thread):
|
|
||||||
def __init__(self, threadID, lock, queue):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.threadID = threadID
|
|
||||||
self.name = "Thread " + str(threadID)
|
|
||||||
self.queue = queue
|
|
||||||
self.lock = lock
|
|
||||||
def run(self):
|
|
||||||
debug.verbose("Starting " + self.name)
|
|
||||||
global exitFlag
|
|
||||||
global currentThreadWorking
|
|
||||||
workingSet = False
|
|
||||||
while False==exitFlag:
|
|
||||||
self.lock.acquire()
|
|
||||||
if not self.queue.empty():
|
|
||||||
if workingSet==False:
|
|
||||||
currentThreadWorking += 1
|
|
||||||
workingSet = True
|
|
||||||
data = self.queue.get()
|
|
||||||
self.lock.release()
|
|
||||||
debug.verbose(self.name + " processing '" + data[0] + "'")
|
|
||||||
if data[0]=="cmdLine":
|
|
||||||
comment = data[2]
|
|
||||||
cmdLine = data[1]
|
|
||||||
cmdStoreFile = data[3]
|
|
||||||
debug.print_element( "[" + str(self.threadID) + "] " + comment[0], comment[1], comment[2], comment[3])
|
|
||||||
run_command(cmdLine, cmdStoreFile)
|
|
||||||
else:
|
|
||||||
debug.warning("unknow request command : " + data[0])
|
|
||||||
else:
|
|
||||||
if workingSet==True:
|
|
||||||
currentThreadWorking -= 1
|
|
||||||
workingSet=False
|
|
||||||
# no element to parse, just wait ...
|
|
||||||
self.lock.release()
|
|
||||||
time.sleep(0.2)
|
|
||||||
# kill requested ...
|
|
||||||
debug.verbose("Exiting " + self.name)
|
|
||||||
|
|
||||||
|
|
||||||
def error_occured():
|
|
||||||
global exitFlag
|
|
||||||
exitFlag = True
|
|
||||||
|
|
||||||
def set_core_number(numberOfcore):
|
|
||||||
global processorAvaillable
|
|
||||||
processorAvaillable = numberOfcore
|
|
||||||
debug.debug(" set number of core for multi process compilation : " + str(processorAvaillable))
|
|
||||||
# nothing else to do
|
|
||||||
|
|
||||||
def init():
|
|
||||||
global exitFlag
|
|
||||||
global isinit
|
|
||||||
if isinit==False:
|
|
||||||
isinit=True
|
|
||||||
global threads
|
|
||||||
global queueLock
|
|
||||||
global workQueue
|
|
||||||
# Create all the new threads
|
|
||||||
threadID = 0
|
|
||||||
while threadID < processorAvaillable:
|
|
||||||
thread = myThread(threadID, queueLock, workQueue)
|
|
||||||
thread.start()
|
|
||||||
threads.append(thread)
|
|
||||||
threadID += 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def un_init():
|
|
||||||
global exitFlag
|
|
||||||
# Notify threads it's time to exit
|
|
||||||
exitFlag = True
|
|
||||||
if processorAvaillable > 1:
|
|
||||||
# Wait for all threads to complete
|
|
||||||
for tmp in threads:
|
|
||||||
debug.verbose("join thread ...")
|
|
||||||
tmp.join()
|
|
||||||
debug.verbose("Exiting ALL Threads")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run_in_pool(cmdLine, comment, storeCmdLine=""):
|
|
||||||
if processorAvaillable <= 1:
|
|
||||||
debug.print_element(comment[0], comment[1], comment[2], comment[3])
|
|
||||||
run_command(cmdLine, storeCmdLine)
|
|
||||||
return
|
|
||||||
# multithreaded mode
|
|
||||||
init()
|
|
||||||
# Fill the queue
|
|
||||||
queueLock.acquire()
|
|
||||||
debug.verbose("add : in pool cmdLine")
|
|
||||||
workQueue.put(["cmdLine", cmdLine, comment, storeCmdLine])
|
|
||||||
queueLock.release()
|
|
||||||
|
|
||||||
|
|
||||||
def pool_synchrosize():
|
|
||||||
global errorOccured
|
|
||||||
if processorAvaillable <= 1:
|
|
||||||
#in this case : nothing to synchronise
|
|
||||||
return
|
|
||||||
|
|
||||||
debug.verbose("wait queue process ended\n")
|
|
||||||
# Wait for queue to empty
|
|
||||||
while not workQueue.empty() \
|
|
||||||
and False==errorOccured:
|
|
||||||
time.sleep(0.2)
|
|
||||||
pass
|
|
||||||
# Wait all thread have ended their current process
|
|
||||||
while currentThreadWorking != 0 \
|
|
||||||
and False==errorOccured:
|
|
||||||
time.sleep(0.2)
|
|
||||||
pass
|
|
||||||
if False==errorOccured:
|
|
||||||
debug.verbose("queue is empty")
|
|
||||||
else:
|
|
||||||
debug.debug("Thread return with error ... ==> stop all the pool")
|
|
||||||
un_init()
|
|
||||||
debug.error("Pool error occured ...")
|
|
||||||
|
|
337
lutinTarget.py
337
lutinTarget.py
@@ -1,337 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import lutinDebug as debug
|
|
||||||
import datetime
|
|
||||||
import lutinTools
|
|
||||||
import lutinModule
|
|
||||||
import lutinImage
|
|
||||||
|
|
||||||
class Target:
|
|
||||||
def __init__(self, name, typeCompilator, debugMode, generatePackage, arch, cross, sumulator=False):
|
|
||||||
if arch != "":
|
|
||||||
self.arch = "-arch " + arch
|
|
||||||
else:
|
|
||||||
self.arch = ""
|
|
||||||
self.sumulator = sumulator
|
|
||||||
self.cross = cross
|
|
||||||
self.name=name
|
|
||||||
self.endGeneratePackage = generatePackage
|
|
||||||
debug.info("=================================");
|
|
||||||
debug.info("== Target='" + self.name + "'");
|
|
||||||
debug.info("=================================");
|
|
||||||
self.ar=self.cross + "ar"
|
|
||||||
self.ranlib=self.cross + "ranlib"
|
|
||||||
if typeCompilator == "clang":
|
|
||||||
self.cc=self.cross + "clang"
|
|
||||||
self.xx=self.cross + "clang++"
|
|
||||||
#self.ar=self.cross + "llvm-ar"
|
|
||||||
#self.ranlib="ls"
|
|
||||||
else:
|
|
||||||
self.cc=self.cross + "gcc"
|
|
||||||
self.xx=self.cross + "g++"
|
|
||||||
#self.ar=self.cross + "ar"
|
|
||||||
#self.ranlib=self.cross + "ranlib"
|
|
||||||
self.ld=self.cross + "ld"
|
|
||||||
self.nm=self.cross + "nm"
|
|
||||||
self.strip=self.cross + "strip"
|
|
||||||
self.dlltool=self.cross + "dlltool"
|
|
||||||
###############################################################################
|
|
||||||
# Target global variables.
|
|
||||||
###############################################################################
|
|
||||||
self.global_include_cc=[]
|
|
||||||
self.global_flags_cc=['-D__TARGET_OS__'+self.name,
|
|
||||||
'-D_REENTRANT']
|
|
||||||
if self.name != "Windows":
|
|
||||||
self.global_flags_xx=['-std=c++11']
|
|
||||||
self.global_flags_mm=['-std=c++11']
|
|
||||||
else:
|
|
||||||
self.global_flags_xx=['-static-libgcc', '-static-libstdc++', '-L', '-std=c++11']
|
|
||||||
self.global_flags_mm=[]
|
|
||||||
self.global_flags_m=[]
|
|
||||||
self.global_flags_ar=['rcs']
|
|
||||||
self.global_flags_ld=[]
|
|
||||||
self.global_flags_ld_shared=[]
|
|
||||||
self.global_libs_ld=[]
|
|
||||||
self.global_libs_ld_shared=[]
|
|
||||||
|
|
||||||
self.global_sysroot=""
|
|
||||||
|
|
||||||
self.suffix_cmdLine='.cmd'
|
|
||||||
self.suffix_dependence='.d'
|
|
||||||
self.suffix_obj='.o'
|
|
||||||
self.suffix_lib_static='.a'
|
|
||||||
self.suffix_lib_dynamic='.so'
|
|
||||||
self.suffix_binary=''
|
|
||||||
self.suffix_package='.deb'
|
|
||||||
|
|
||||||
self.folder_arch="/" + self.name
|
|
||||||
|
|
||||||
if "debug" == debugMode:
|
|
||||||
self.buildMode = "debug"
|
|
||||||
self.global_flags_cc.append("-g")
|
|
||||||
self.global_flags_cc.append("-DDEBUG")
|
|
||||||
self.global_flags_cc.append("-O0")
|
|
||||||
else:
|
|
||||||
self.buildMode = "release"
|
|
||||||
self.global_flags_cc.append("-DNDEBUG")
|
|
||||||
self.global_flags_cc.append("-O3")
|
|
||||||
self.folder_out="/out" + self.folder_arch + "/" + self.buildMode
|
|
||||||
self.folder_final="/final/" + typeCompilator
|
|
||||||
self.folder_staging="/staging/" + typeCompilator
|
|
||||||
self.folder_build="/build/" + typeCompilator
|
|
||||||
self.folder_bin="/usr/bin"
|
|
||||||
self.folder_lib="/usr/lib"
|
|
||||||
self.folder_data="/usr/share"
|
|
||||||
self.folder_doc="/usr/share/doc"
|
|
||||||
self.buildDone=[]
|
|
||||||
self.buildTreeDone=[]
|
|
||||||
self.moduleList=[]
|
|
||||||
# output staging files list :
|
|
||||||
self.listFinalFile=[]
|
|
||||||
|
|
||||||
self.sysroot=""
|
|
||||||
|
|
||||||
self.externProjectManager = None
|
|
||||||
|
|
||||||
def set_use_of_extern_build_tool(self, mode):
|
|
||||||
if mode == True:
|
|
||||||
if self.externProjectManager == None:
|
|
||||||
debug.error("This target does not support extern tool")
|
|
||||||
else:
|
|
||||||
# remove extern tool generator...
|
|
||||||
self.externProjectManager = None
|
|
||||||
|
|
||||||
def get_build_mode(self):
|
|
||||||
return self.buildMode
|
|
||||||
|
|
||||||
def add_image_staging(self, inputFile, outputFile, sizeX, sizeY, cmdFile=None):
|
|
||||||
for source, dst, x, y, cmdFile2 in self.listFinalFile:
|
|
||||||
if dst == outputFile :
|
|
||||||
debug.verbose("already added : " + outputFile)
|
|
||||||
return
|
|
||||||
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'")
|
|
||||||
self.listFinalFile.append([inputFile,outputFile, sizeX, sizeY, cmdFile])
|
|
||||||
|
|
||||||
def add_file_staging(self, inputFile, outputFile, cmdFile=None):
|
|
||||||
for source, dst, x, y, cmdFile2 in self.listFinalFile:
|
|
||||||
if dst == outputFile :
|
|
||||||
debug.verbose("already added : " + outputFile)
|
|
||||||
return
|
|
||||||
debug.verbose("add file : '" + inputFile + "' ==> '" + outputFile + "'");
|
|
||||||
self.listFinalFile.append([inputFile, outputFile, -1, -1, cmdFile])
|
|
||||||
|
|
||||||
def copy_to_staging(self, binaryName):
|
|
||||||
baseFolder = self.get_staging_folder_data(binaryName)
|
|
||||||
for source, dst, x, y, cmdFile in self.listFinalFile:
|
|
||||||
if cmdFile != None \
|
|
||||||
and cmdFile != "":
|
|
||||||
debug.verbose("cmd file " + cmdFile)
|
|
||||||
if x == -1:
|
|
||||||
debug.verbose("must copy file : '" + source + "' ==> '" + dst + "'");
|
|
||||||
lutinTools.copy_file(source, baseFolder+"/"+dst, cmdFile)
|
|
||||||
else:
|
|
||||||
debug.verbose("resize image : '" + source + "' ==> '" + dst + "' size=(" + str(x) + "," + str(y) + ")");
|
|
||||||
lutinImage.resize(source, baseFolder+"/"+dst, x, y, cmdFile)
|
|
||||||
|
|
||||||
|
|
||||||
def clean_module_tree(self):
|
|
||||||
self.buildTreeDone = []
|
|
||||||
self.listFinalFile = []
|
|
||||||
|
|
||||||
|
|
||||||
# TODO : Remove this hack ... ==> really bad ... but usefull
|
|
||||||
def set_ewol_folder(self, folder):
|
|
||||||
self.folder_ewol = folder
|
|
||||||
|
|
||||||
|
|
||||||
def file_generate_object(self,binaryName,moduleName,basePath,file):
|
|
||||||
list=[]
|
|
||||||
list.append(basePath + "/" + file)
|
|
||||||
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_obj)
|
|
||||||
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_dependence)
|
|
||||||
list.append(self.get_build_folder(moduleName) + "/" + file + self.suffix_cmdLine)
|
|
||||||
return list
|
|
||||||
"""
|
|
||||||
return a list of 3 elements :
|
|
||||||
0 : sources files (can be a list)
|
|
||||||
1 : destination file
|
|
||||||
2 : dependence files module (*.d)
|
|
||||||
"""
|
|
||||||
def generate_file(self,binaryName,moduleName,basePath,file,type):
|
|
||||||
list=[]
|
|
||||||
if (type=="bin"):
|
|
||||||
list.append(file)
|
|
||||||
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_bin + "/" + moduleName + self.suffix_binary)
|
|
||||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
|
||||||
list.append(self.get_build_folder(binaryName) + "/" + self.folder_bin + "/" + moduleName + self.suffix_cmdLine)
|
|
||||||
elif (type=="lib-shared"):
|
|
||||||
list.append(file)
|
|
||||||
list.append(self.get_staging_folder(binaryName) + "/" + self.folder_lib + "/" + moduleName + self.suffix_lib_dynamic)
|
|
||||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
|
||||||
list.append(self.get_build_folder(binaryName) + "/" + self.folder_lib + "/" + moduleName + self.suffix_cmdLine)
|
|
||||||
elif (type=="lib-static"):
|
|
||||||
list.append(file)
|
|
||||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_lib_static)
|
|
||||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_dependence)
|
|
||||||
list.append(self.get_build_folder(moduleName) + "/" + moduleName + self.suffix_cmdLine)
|
|
||||||
elif (type=="image"):
|
|
||||||
list.append(self.get_build_folder(binaryName) + "/data/" + file + self.suffix_cmdLine)
|
|
||||||
else:
|
|
||||||
debug.error("unknow type : " + type)
|
|
||||||
return list
|
|
||||||
|
|
||||||
def get_final_folder(self):
|
|
||||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_final
|
|
||||||
|
|
||||||
def get_staging_folder(self, binaryName):
|
|
||||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_staging + "/" + binaryName
|
|
||||||
|
|
||||||
def get_staging_folder_data(self, binaryName):
|
|
||||||
return self.get_staging_folder(binaryName) + self.folder_data + "/" + binaryName
|
|
||||||
|
|
||||||
def get_build_folder(self, moduleName):
|
|
||||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_build + "/" + moduleName
|
|
||||||
|
|
||||||
def get_doc_folder(self, moduleName):
|
|
||||||
return lutinTools.get_run_folder() + self.folder_out + self.folder_doc + "/" + moduleName
|
|
||||||
|
|
||||||
def is_module_build(self,module):
|
|
||||||
for mod in self.buildDone:
|
|
||||||
if mod == module:
|
|
||||||
return True
|
|
||||||
self.buildDone.append(module)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def is_module_buildTree(self,module):
|
|
||||||
for mod in self.buildTreeDone:
|
|
||||||
if mod == module:
|
|
||||||
return True
|
|
||||||
self.buildTreeDone.append(module)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def add_module(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 build_tree(self, name, packagesName):
|
|
||||||
for module in self.moduleList:
|
|
||||||
if module.name == name:
|
|
||||||
module.build_tree(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 load_if_needed(self, name):
|
|
||||||
for elem in self.moduleList:
|
|
||||||
if elem.name == name:
|
|
||||||
return
|
|
||||||
lutinModule.load_module(self, name)
|
|
||||||
|
|
||||||
def load_all(self):
|
|
||||||
listOfAllTheModule = lutinModule.list_all_module()
|
|
||||||
for modName in listOfAllTheModule:
|
|
||||||
self.load_if_needed(modName)
|
|
||||||
|
|
||||||
def project_add_module(self, name, projectMng, addedModule):
|
|
||||||
for module in self.moduleList:
|
|
||||||
if module.name == name:
|
|
||||||
module.ext_project_add_module(self, projectMng, addedModule)
|
|
||||||
return
|
|
||||||
|
|
||||||
def build(self, name, packagesName=None):
|
|
||||||
if name == "dump":
|
|
||||||
debug.info("dump all")
|
|
||||||
self.load_all()
|
|
||||||
for mod in self.moduleList:
|
|
||||||
mod.display(self)
|
|
||||||
elif self.externProjectManager != None:
|
|
||||||
# TODO : Do it only if needed:
|
|
||||||
debug.debug("generate project")
|
|
||||||
# TODO : Set an option to force Regeneration of the project or the oposite....
|
|
||||||
self.load_all()
|
|
||||||
for mod in self.moduleList:
|
|
||||||
if mod.name != "edn":
|
|
||||||
continue
|
|
||||||
if mod.type == "PACKAGE":
|
|
||||||
mod.create_project(self, self.externProjectManager)
|
|
||||||
# TODO : Run project or do something else ...
|
|
||||||
debug.error("stop here ...")
|
|
||||||
else:
|
|
||||||
if name == "all":
|
|
||||||
debug.info("build all")
|
|
||||||
self.load_all()
|
|
||||||
for mod in self.moduleList:
|
|
||||||
if self.name=="Android":
|
|
||||||
if mod.type == "PACKAGE":
|
|
||||||
mod.build(self, None)
|
|
||||||
else:
|
|
||||||
if mod.type == "BINARY" \
|
|
||||||
or mod.type == "PACKAGE":
|
|
||||||
mod.build(self, None)
|
|
||||||
elif name == "clean":
|
|
||||||
debug.info("clean all")
|
|
||||||
self.load_all()
|
|
||||||
for mod in self.moduleList:
|
|
||||||
mod.clean(self)
|
|
||||||
else:
|
|
||||||
# get the action an the module ....
|
|
||||||
gettedElement = name.split("-")
|
|
||||||
moduleName = gettedElement[0]
|
|
||||||
if len(gettedElement)>=2:
|
|
||||||
actionName = gettedElement[1]
|
|
||||||
else :
|
|
||||||
actionName = "build"
|
|
||||||
debug.verbose("requested : " + moduleName + "-" + actionName)
|
|
||||||
if actionName == "install":
|
|
||||||
self.build(moduleName + "-build")
|
|
||||||
self.install_package(moduleName)
|
|
||||||
elif actionName == "uninstall":
|
|
||||||
self.un_install_package(moduleName)
|
|
||||||
elif actionName == "log":
|
|
||||||
self.Log(moduleName)
|
|
||||||
else:
|
|
||||||
self.load_if_needed(moduleName)
|
|
||||||
# clean requested
|
|
||||||
for mod in self.moduleList:
|
|
||||||
if mod.name == moduleName:
|
|
||||||
if actionName == "dump":
|
|
||||||
debug.info("dump module '" + moduleName + "'")
|
|
||||||
return mod.display(self)
|
|
||||||
elif actionName == "clean":
|
|
||||||
debug.info("clean module '" + moduleName + "'")
|
|
||||||
return mod.clean(self)
|
|
||||||
elif actionName == "build":
|
|
||||||
debug.debug("build module '" + moduleName + "'")
|
|
||||||
return mod.build(self, None)
|
|
||||||
debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it")
|
|
||||||
|
|
||||||
|
|
||||||
__startTargetName="lutinTarget"
|
|
||||||
|
|
||||||
def list_all_target():
|
|
||||||
tmpListName = ["Android", "Linux", "MacOs", "IOs", "Windows" ]
|
|
||||||
return tmpListName
|
|
||||||
|
|
||||||
def target_load(targetName, compilator, mode, generatePackage, externBuild, simulationMode):
|
|
||||||
theTarget = __import__(__startTargetName + targetName)
|
|
||||||
#try:
|
|
||||||
tmpTarget = theTarget.Target(compilator, mode, generatePackage, simulationMode)
|
|
||||||
tmpTarget.set_use_of_extern_build_tool(externBuild)
|
|
||||||
return tmpTarget
|
|
||||||
#except:
|
|
||||||
# debug.error("Can not create the Target : '" + targetName + "'")
|
|
@@ -1,62 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import lutinDebug as debug
|
|
||||||
import lutinTarget
|
|
||||||
import lutinTools
|
|
||||||
import os
|
|
||||||
import stat
|
|
||||||
import lutinHost
|
|
||||||
import sys
|
|
||||||
|
|
||||||
class Target(lutinTarget.Target):
|
|
||||||
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
|
|
||||||
# on windows board the basic path is not correct
|
|
||||||
# TODO : get external PATH for the minGW path
|
|
||||||
# TODO : Set the cyngwin path ...
|
|
||||||
if lutinHost.OS == "Windows":
|
|
||||||
cross = "c:\\MinGW\\bin\\"
|
|
||||||
sys.path.append("c:\\MinGW\\bin" )
|
|
||||||
os.environ['PATH'] += ";c:\\MinGW\\bin\\"
|
|
||||||
else:
|
|
||||||
#cross = "i586-mingw32msvc-"
|
|
||||||
cross = "x86_64-w64-mingw32-"
|
|
||||||
#cross = "i686-w64-mingw32-"
|
|
||||||
|
|
||||||
if typeCompilator!="gcc":
|
|
||||||
debug.error("Android does not support '" + typeCompilator + "' compilator ... availlable : [gcc]")
|
|
||||||
|
|
||||||
lutinTarget.Target.__init__(self, "Windows", typeCompilator, debugMode, generatePackage, "", cross)
|
|
||||||
|
|
||||||
self.folder_bin=""
|
|
||||||
self.folder_lib="/lib"
|
|
||||||
self.folder_data="/data"
|
|
||||||
self.folder_doc="/doc"
|
|
||||||
|
|
||||||
self.suffix_lib_static='.a'
|
|
||||||
self.suffix_lib_dynamic='.dll'
|
|
||||||
self.suffix_binary='.exe'
|
|
||||||
self.suffix_package=''
|
|
||||||
|
|
||||||
|
|
||||||
def get_staging_folder_data(self, binaryName):
|
|
||||||
return self.get_staging_folder(binaryName) + self.folder_data
|
|
||||||
|
|
||||||
def make_package(self, pkgName, pkgProperties, basePkgPath):
|
|
||||||
debug.debug("------------------------------------------------------------------------")
|
|
||||||
debug.info("Generate package '" + pkgName + "'")
|
|
||||||
debug.debug("------------------------------------------------------------------------")
|
|
||||||
debug.warning(" ==> TODO")
|
|
||||||
|
|
||||||
def install_package(self, pkgName):
|
|
||||||
debug.debug("------------------------------------------------------------------------")
|
|
||||||
debug.info("Install package '" + pkgName + "'")
|
|
||||||
debug.debug("------------------------------------------------------------------------")
|
|
||||||
debug.warning(" ==> TODO")
|
|
||||||
#sudo dpkg -i $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
|
||||||
|
|
||||||
def un_install_package(self, pkgName):
|
|
||||||
debug.debug("------------------------------------------------------------------------")
|
|
||||||
debug.info("Un-Install package '" + pkgName + "'")
|
|
||||||
debug.debug("------------------------------------------------------------------------")
|
|
||||||
debug.warning(" ==> TODO")
|
|
||||||
#sudo dpkg -r $(TARGET_OUT_FINAL)/$(PROJECT_NAME) + self.suffix_package
|
|
||||||
|
|
35
setup.py
Executable file
35
setup.py
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
def readme():
|
||||||
|
with open('README.rst') as f:
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||||
|
setup(name='lutin',
|
||||||
|
version='0.5.4',
|
||||||
|
description='Lutin generic builder',
|
||||||
|
long_description=readme(),
|
||||||
|
url='http://github.com/HeeroYui/lutin',
|
||||||
|
author='Edouard DUPIN',
|
||||||
|
author_email='yui.heero@gmail.com',
|
||||||
|
license='APACHE-2',
|
||||||
|
packages=['lutin',
|
||||||
|
'lutin/builder',
|
||||||
|
'lutin/system',
|
||||||
|
'lutin/target'
|
||||||
|
],
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 3 - Alpha',
|
||||||
|
'License :: OSI Approved :: Apache Software License',
|
||||||
|
'Programming Language :: Python',
|
||||||
|
'Topic :: Software Development :: Compilers',
|
||||||
|
],
|
||||||
|
keywords='builder c++ c android ios macos makefile cmake',
|
||||||
|
scripts=['bin/lutin'],
|
||||||
|
include_package_data = True,
|
||||||
|
zip_safe=False)
|
||||||
|
|
||||||
|
#To developp: ./setup.py install/develop
|
||||||
|
#TO register all in pip: ./setup.py register sdist upload
|
||||||
|
|
1403
xcodeprojExporter.py
1403
xcodeprojExporter.py
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user