Compare commits

...

13 Commits
0.2.0 ... 0.3.0

20 changed files with 546 additions and 159 deletions

View File

@@ -1,4 +1,12 @@
#!/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
@@ -21,9 +29,11 @@ myLutinArg.add(lutinArg.ArgDefine("j", "jobs", haveParam=True, desc="Specifies t
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("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'"))
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("a", "arch", list=[["auto","Automatic choice"],["arm","Arm processer"],["x86","Generic PC : AMD/Intel"],["ppc","Power PC"]], desc="Architecture to compile"))
myLutinArg.add(lutinArg.ArgDefine("b", "bus", list=[["auto","Automatic choice"],["32","32 bits"],["64","64 bits"]], desc="Adressing size (Bus size)"))
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)"))
@@ -124,50 +134,59 @@ import lutinTools
def Start():
#available target : Linux / MacOs / Windows / Android ...
targetName=lutinHost.OS
#compilation base
compilator="gcc"
# build mode
mode="release"
# package generationMode
generatePackage=True
config = {
"compilator":"gcc",
"mode":"release",
"bus-size":"auto",
"arch":"auto",
"generate-package":True,
"simulation":False,
"extern-build":False
}
# 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
config["generate-package"]=False
elif argument.get_option_nName() == "simulation":
simulationMode=True
config["simulation"]=True
elif argument.get_option_nName() == "prj":
externBuild=True
config["extern-build"]=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 compilator!=argument.get_arg():
if config["compilator"] != argument.get_arg():
debug.debug("change compilator ==> " + argument.get_arg())
compilator=argument.get_arg()
config["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")
debug.debug("change target ==> '" + targetName + "' & reset mode : gcc&release")
#reset properties by defauult:
compilator="gcc"
mode="release"
generatePackage=True
simulationMode=False
config = {
"compilator":"gcc",
"mode":"release",
"bus-size":"auto",
"arch":"auto",
"generate-package":True,
"simulation":False,
"extern-build":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)
if config["mode"]!=argument.get_arg():
config["mode"] = argument.get_arg()
debug.debug("change mode ==> " + config["mode"])
#remove previous target
target = None
else:
@@ -177,14 +196,14 @@ def Start():
else:
#load the target if needed :
if target == None:
target = lutinTarget.target_load(targetName, compilator, mode, generatePackage, externBuild, simulationMode)
target = lutinTarget.load_target(targetName, config)
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 = lutinTarget.load_target(targetName, config)
target.build("all")
# stop all started threads
lutinMultiprocess.un_init()
@@ -208,6 +227,7 @@ if __name__ == '__main__':
and folder.lower()!="out" :
debug.debug("Automatic load path: '" + folder + "'")
lutinModule.import_path(folder)
lutinTarget.import_path(folder)
Start()

View File

@@ -1,4 +1,12 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import sys
import lutinDebug as debug

View File

@@ -1,8 +1,17 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import os
import thread
import lutinMultiprocess
import threading
import re
debugLevel=3
debugColor=False
@@ -41,58 +50,80 @@ def enable_color():
global color_cyan
color_cyan = "\033[36m"
def verbose(input):
def verbose(input, force=False):
global debugLock
global debugLevel
if debugLevel >= 5:
if debugLevel >= 5 \
or force == True:
debugLock.acquire()
print(color_blue + input + color_default)
debugLock.release()
def debug(input):
def debug(input, force=False):
global debugLock
global debugLevel
if debugLevel >= 4:
if debugLevel >= 4 \
or force == True:
debugLock.acquire()
print(color_green + input + color_default)
debugLock.release()
def info(input):
def info(input, force=False):
global debugLock
global debugLevel
if debugLevel >= 3:
if debugLevel >= 3 \
or force == True:
debugLock.acquire()
print(input + color_default)
debugLock.release()
def warning(input):
def warning(input, force=False):
global debugLock
global debugLevel
if debugLevel >= 2:
if debugLevel >= 2 \
or force == True:
debugLock.acquire()
print(color_purple + "[WARNING] " + input + color_default)
debugLock.release()
def error(input, threadID=-1):
def error(input, threadID=-1, force=False, crash=True):
global debugLock
global debugLevel
if debugLevel >= 1:
if debugLevel >= 1 \
or force == True:
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"
if crash==True:
lutinMultiprocess.error_occured()
if threadID != -1:
thread.interrupt_main()
exit(-1)
#os_exit(-1)
#raise "error happend"
def print_element(type, lib, dir, name):
def print_element(type, lib, dir, name, force=False):
global debugLock
global debugLevel
if debugLevel >= 3:
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()

View File

@@ -1,4 +1,12 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import os
import lutinDebug as debug
import lutinEnv as environement
@@ -21,6 +29,11 @@ def need_re_build(dst, src, dependFile=None, file_cmd="", cmdLine=""):
and os.path.exists(dst) == False:
debug.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
# chek the basic date if the 2 files
if dst != "" \
and dst != None \

View File

@@ -1,4 +1,12 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import lutinDebug as debug
@@ -21,7 +29,7 @@ printPrettyMode=False
def set_print_pretty_mode(val):
global printPrettyMode
if val==True:
if val == True:
printPrettyMode = True
else:
printPrettyMode = False
@@ -30,9 +38,10 @@ def get_print_pretty_mode():
global printPrettyMode
return printPrettyMode
def print_pretty(myString):
def print_pretty(myString, force=False):
global printPrettyMode
if True==printPrettyMode:
if printPrettyMode == True \
or force == True:
if myString[len(myString)-1]==' ' :
tmpcmdLine = myString[:len(myString)-1]
else :

View File

@@ -1,4 +1,12 @@
#!/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 datetime
import lutinTools

View File

@@ -1,4 +1,12 @@
#!/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 datetime
import lutinTools as tools

View File

@@ -1,4 +1,12 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import sys
import lutinDebug as debug

View File

@@ -1,4 +1,12 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import platform
import sys
import lutinDebug as debug
@@ -13,8 +21,13 @@ elif platform.system() == "Darwin":
else:
debug.error("Unknow the Host OS ... '" + platform.system() + "'")
debug.debug(" host.OS = " + OS)
debug.debug("host.OS = " + OS)
OS64BITS = sys.maxsize > 2**32
OS32BITS = OS64BITS==False
if sys.maxsize > 2**32:
BUS_SIZE = 64
else:
BUS_SIZE = 32
debug.debug("host.BUS_SIZE = " + str(BUS_SIZE))

View File

@@ -1,15 +1,27 @@
#!/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 lutinTools as tools
import platform
import os
import lutinMultiprocess
import lutinDepend as dependency
if platform.system() == "Darwin":
import CoreGraphics
else:
from PIL import Image
enableResizeImage = True
try:
if platform.system() == "Darwin":
import CoreGraphics
else:
from PIL import Image
except:
enableResizeImage = False
debug.warning("Missing python tools : CoreGraphics (MacOs) or PIL")
def get_pow_2_multiple(size):
base = 2
@@ -22,6 +34,8 @@ def get_pow_2_multiple(size):
# check if time change
# check if command line change
def resize(srcFile, destFile, x, y, cmd_file=None):
if enableResizeImage == False:
return
if os.path.exists(srcFile) == False:
debug.error("Request a resize an image that does not existed : '" + srcFile + "'")
cmd_line = "resize Image : " + srcFile + " ==> " + destFile + " newSize=(" + str(x) + "x" + str(y) + ")"

View File

@@ -1,4 +1,12 @@
#!/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
@@ -318,7 +326,7 @@ class Module:
lutinTools.create_directory_of_file(file_dst)
debug.print_element("SharedLib", libName, "==>", file_dst)
lutinMultiprocess.run_command(cmdLine)
if "release"==target.buildMode \
if target.config["mode"] == "release" \
or lutinEnv.get_force_strip_mode()==True:
# get the file size of the non strip file
originSize = lutinTools.file_size(file_dst);
@@ -360,7 +368,7 @@ class Module:
debug.print_element("Executable", self.name, "==>", file_dst)
lutinMultiprocess.run_command(cmdLine)
if "release"==target.buildMode \
if "release"==target.config["mode"] \
or lutinEnv.get_force_strip_mode()==True:
# get the file size of the non strip file
originSize = lutinTools.file_size(file_dst);
@@ -475,7 +483,7 @@ class Module:
resFile = self.compile_m_to_o(file, packageName, target, self.subHeritageList)
listSubFileNeededTobuild.append(resFile)
else:
debug.verbose(" TODO : gcc " + self.originFolder + "/" + file)
debug.warning(" UN-SUPPORTED file format: '" + self.originFolder + "/" + file + "'")
# when multiprocess availlable, we need to synchronize here ...
lutinMultiprocess.pool_synchrosize()

View File

@@ -1,4 +1,12 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import sys
import lutinDebug as debug
import threading
@@ -8,11 +16,21 @@ import os
import subprocess
import lutinTools
import lutinEnv
import shlex
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
@@ -32,27 +50,62 @@ def store_command(cmdLine, file):
file2.close()
def run_command(cmdLine, storeCmdLine=""):
debug.debug(lutinEnv.print_pretty(cmdLine))
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:
retcode = subprocess.call(cmdLine, shell=True)
except OSError as e:
print >>sys.stderr, "Execution failed:", e
if retcode != 0:
global errorOccured
# 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()
# Check error :
if p.returncode == 0:
debug.debug(lutinEnv.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
global exitFlag
exitFlag = True
if retcode == 2:
debug.error("can not compile file ... [keyboard interrrupt]")
# if No ID : Not in a multiprocess mode ==> just stop here
if buildId < 0:
debug.debug(lutinEnv.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:
debug.error("can not compile file ... ret : " + str(retcode))
# 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
# write cmd line only after to prevent errors ...
store_command(cmdLine, storeCmdLine)
@@ -68,7 +121,7 @@ class myThread(threading.Thread):
global exitFlag
global currentThreadWorking
workingSet = False
while False==exitFlag:
while exitFlag == False:
self.lock.acquire()
if not self.queue.empty():
if workingSet==False:
@@ -81,8 +134,8 @@ class myThread(threading.Thread):
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)
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:
@@ -138,21 +191,24 @@ def un_init():
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)
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])
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
@@ -171,7 +227,17 @@ def pool_synchrosize():
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 ...")
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(lutinEnv.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"]))

View File

@@ -1,50 +1,67 @@
#!/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 lutinDebug as debug
import datetime
import lutinTools
import lutinModule
import lutinImage
import lutinHost
class Target:
def __init__(self, name, typeCompilator, debugMode, generatePackage, arch, cross, sumulator=False):
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 = ""
self.sumulator = sumulator
self.cross = cross
# todo : remove this :
self.sumulator = config["simulation"]
self.name=name
self.endGeneratePackage = generatePackage
self.endGeneratePackage = config["generate-package"]
debug.info("=================================");
debug.info("== Target='" + self.name + "'");
debug.info("== Target='" + self.name + "' " + config["bus-size"] + " bits for arch '" + config["arch"] + "'");
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"
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']
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_xx=['-static-libgcc', '-static-libstdc++', '-std=c++11']
self.global_flags_mm=[]
self.global_flags_m=[]
self.global_flags_ar=['rcs']
@@ -65,19 +82,14 @@ class Target:
self.folder_arch="/" + self.name
if "debug" == debugMode:
self.buildMode = "debug"
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.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.update_folder_tree()
self.folder_bin="/usr/bin"
self.folder_lib="/usr/lib"
self.folder_data="/usr/share"
@@ -92,6 +104,33 @@ class Target:
self.externProjectManager = None
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 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"
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 set_use_of_extern_build_tool(self, mode):
if mode == True:
if self.externProjectManager == None:
@@ -101,7 +140,7 @@ class Target:
self.externProjectManager = None
def get_build_mode(self):
return self.buildMode
return self.config["mode"]
def add_image_staging(self, inputFile, outputFile, sizeX, sizeY, cmdFile=None):
for source, dst, x, y, cmdFile2 in self.listFinalFile:
@@ -321,17 +360,61 @@ class Target:
debug.error("not know module name : '" + moduleName + "' to '" + actionName + "' it")
__startTargetName="lutinTarget"
targetList=[]
__startTargetName="lutinTarget_"
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, __startTargetName + "*.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)) )
targetName = filename.replace('.py', '')
targetName = targetName.replace(__startTargetName, '')
debug.debug("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)
#tmpTarget.set_use_of_extern_build_tool(externBuild)
return tmpTarget
def list_all_target():
tmpListName = ["Android", "Linux", "MacOs", "IOs", "Windows" ]
global targetList
tmpListName = []
for mod in targetList:
tmpListName.append(mod[0])
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 + "'")
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

View File

@@ -1,4 +1,12 @@
#!/usr/bin/python
##
## @author Edouard DUPIN
##
## @copyright 2012, Edouard DUPIN, all right reserved
##
## @license APACHE v2.0 (see license file)
##
import os
import shutil
import errno

View File

@@ -1,4 +1,12 @@
#!/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
@@ -6,11 +14,21 @@ import lutinTools
import lutinHost
import lutinImage
import lutinMultiprocess
import lutinHost
import os
import sys
class Target(lutinTarget.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"
lutinTarget.Target.__init__(self, "Android", config, arch)
self.folder_ndk = os.getenv('PROJECT_NDK', "AUTO")
self.folder_sdk = os.getenv('PROJECT_SDK', "AUTO")
@@ -36,18 +54,18 @@ class Target(lutinTarget.Target):
if not os.path.isdir(self.folder_sdk):
debug.error("SDK path not set !!! set env : PROJECT_SDK on the SDK path")
arch = ""#"ARMv7"
tmpOsVal = "64"
gccVersion = "4.8"
if lutinHost.OS64BITS==True:
if lutinHost.BUS_SIZE==64:
tmpOsVal = "_64"
if typeCompilator == "clang":
cross = self.folder_ndk + "/toolchains/llvm-3.3/prebuilt/linux-x86_64/bin/"
if self.config["compilator"] == "clang":
self.set_cross_base(self.folder_ndk + "/toolchains/llvm-3.3/prebuilt/linux-x86_64/bin/")
else:
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/"
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):
debug.error("Gcc Arm path does not exist !!!")
if not os.path.isdir(baseFolderMips):
@@ -55,7 +73,6 @@ class Target(lutinTarget.Target):
if not os.path.isdir(baseFolderX86):
debug.info("Gcc x86 path does not exist !!!")
lutinTarget.Target.__init__(self, "Android", typeCompilator, debugMode, generatePackage, arch, cross, sumulator)
arch = "ARMv7"
# for gcc :
@@ -78,7 +95,7 @@ class Target(lutinTarget.Target):
self.global_include_cc.append("-I" + self.folder_ndk +"/platforms/android-" + str(self.boardId) + "/arch-x86/usr/include/")
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/")
if arch == "ARMv5":
stdCppBasePath = self.folder_ndk +"/sources/cxx-stl/llvm-libc++/libcxx/libs/armeabi/"
@@ -182,7 +199,7 @@ class Target(lutinTarget.Target):
debug.info("Generate package '" + pkgName + "'")
debug.debug("------------------------------------------------------------------------")
pkgNameApplicationName = pkgName
if "debug"==self.buildMode:
if self.config["mode"] == "debug":
pkgNameApplicationName += "debug"
# FINAL_FOLDER_JAVA_PROJECT
self.folder_javaProject= self.get_staging_folder(pkgName) \
@@ -346,7 +363,7 @@ class Target(lutinTarget.Target):
tmpFile.write( ' <application android:label="' + pkgNameApplicationName + '" \n')
if "ICON" in pkgProperties.keys():
tmpFile.write( ' android:icon="@drawable/icon" \n')
if "debug"==self.buildMode:
if self.config["mode"] == "debug":
tmpFile.write( ' android:debuggable="true" \n')
tmpFile.write( ' >\n')
if "ADMOD_ID" in pkgProperties:
@@ -355,7 +372,7 @@ class Target(lutinTarget.Target):
tmpFile.write( ' <activity android:name=".' + pkgNameApplicationName + '" \n')
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
if "debug"==self.buildMode:
if self.config["mode"] == "debug":
tmpFile.write("-debug")
tmpFile.write( '"\n')
if "ICON" in pkgProperties.keys():
@@ -380,7 +397,7 @@ class Target(lutinTarget.Target):
tmpFile.write( ' >\n')
tmpFile.write( ' <service android:name=".' + pkgNameApplicationName + '" \n')
tmpFile.write( ' android:label="' + pkgProperties['NAME'])
if "debug"==self.buildMode:
if self.config["mode"] == "debug":
tmpFile.write("-debug")
tmpFile.write( '"\n')
if "ICON" in pkgProperties.keys():
@@ -562,7 +579,7 @@ class Target(lutinTarget.Target):
# 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")
lutinTools.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/20.0.0/"
adModResouceFolder = ""
if "ADMOD_ID" in pkgProperties:
adModResouceFolder = " -S " + self.folder_sdk + "/extras/google/google_play_services/libproject/google-play-services_lib/res/ "
@@ -647,7 +664,7 @@ class Target(lutinTarget.Target):
# http://developer.android.com/tools/publishing/app-signing.html
# 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
if "debug"==self.buildMode:
if self.config["mode"] == "debug":
tmpFile = open("tmpPass.boo", 'w')
tmpFile.write("Pass__AndroidDebugKey\n")
tmpFile.write("PassKey__AndroidDebugKey\n")
@@ -686,7 +703,7 @@ class Target(lutinTarget.Target):
debug.print_element("pkg", ".apk(aligned)", "<==", ".apk (not aligned)")
lutinTools.remove_file(self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk")
# 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) + "/" + pkgNameApplicationName + ".apk "
lutinMultiprocess.run_command(cmdLine)
@@ -701,7 +718,7 @@ class Target(lutinTarget.Target):
debug.info("Install package '" + pkgName + "'")
debug.debug("------------------------------------------------------------------------")
pkgNameApplicationName = pkgName
if "debug"==self.buildMode:
if self.config["mode"] == "debug":
pkgNameApplicationName += "debug"
cmdLine = self.folder_sdk + "/platform-tools/adb install -r " \
+ self.get_staging_folder(pkgName) + "/" + pkgNameApplicationName + ".apk "
@@ -712,7 +729,7 @@ class Target(lutinTarget.Target):
debug.info("Un-Install package '" + pkgName + "'")
debug.debug("------------------------------------------------------------------------")
pkgNameApplicationName = pkgName
if "debug"==self.buildMode:
if self.config["mode"] == "debug":
pkgNameApplicationName += "debug"
cmdLine = self.folder_sdk + "/platform-tools/adb uninstall " + pkgNameApplicationName
RlutinMultiprocess.unCommand(cmdLine)

View File

@@ -1,4 +1,12 @@
#!/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
import lutinTools
@@ -7,24 +15,34 @@ import os
import stat
import lutinExtProjectGeneratorXCode
import lutinMultiprocess
import lutinHost
import random
import re
class Target(lutinTarget.Target):
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
if typeCompilator == "gcc":
def __init__(self, config):
if config["compilator"] == "gcc":
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://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
if sumulator == True:
arch = "i386"
cross = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
else:
arch="arm64" # for ipad air
#arch="armv7" # for Iphone 4
cross = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
lutinTarget.Target.__init__(self, "IOs", typeCompilator, debugMode, generatePackage, arch, cross, sumulator)
lutinTarget.Target.__init__(self, "IOs", config, arch)
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 ...
self.ranlib=""

View File

@@ -1,4 +1,12 @@
#!/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
import lutinTools as tools
@@ -6,10 +14,25 @@ import os
import stat
import re
import lutinMultiprocess
import lutinHost
class Target(lutinTarget.Target):
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
lutinTarget.Target.__init__(self, "Linux", typeCompilator, debugMode, generatePackage, "", "")
def __init__(self, config):
#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(lutinHost.BUS_SIZE)
lutinTarget.Target.__init__(self, "Linux", config, "")
if self.config["bus-size"] == "64":
# 64 bits
if lutinHost.BUS_SIZE != 64:
self.global_flags_cc.append("-m64")
else:
# 32 bits
if lutinHost.BUS_SIZE != 32:
self.global_flags_cc.append("-m32")
def generate_list_separate_coma(self, list):
result = ""

View File

@@ -1,17 +1,30 @@
#!/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
import lutinTools
import lutinHost
import os
import stat
class Target(lutinTarget.Target):
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
cross = ""
def __init__(self, config):
#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(lutinHost.BUS_SIZE)
# http://biolpc22.york.ac.uk/pub/linux-mac-cross/
# http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
lutinTarget.Target.__init__(self, "MacOs", typeCompilator, debugMode, generatePackage, "", cross)
lutinTarget.Target.__init__(self, "MacOs", config, "")
self.folder_bin="/MacOS"
self.folder_lib="/lib"

View File

@@ -1,30 +1,49 @@
#!/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
import lutinTools
import lutinHost
import os
import stat
import lutinHost
import sys
class Target(lutinTarget.Target):
def __init__(self, typeCompilator, debugMode, generatePackage, sumulator=False):
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(lutinHost.BUS_SIZE)
lutinTarget.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 lutinHost.OS == "Windows":
cross = "c:\\MinGW\\bin\\"
self.set_cross_base("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)
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-")
self.folder_bin=""
self.folder_lib="/lib"