From 33dc55d84bcf8ba1a4b1dcb0f8db13458febea92 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 16 Sep 2014 21:40:07 +0200 Subject: [PATCH] [DEV] Add target searching and multi processor compilation --- lutin.py | 70 ++++---- lutinArg.py | 8 + lutinDebug.py | 8 + lutinDepend.py | 8 + lutinEnv.py | 8 + lutinExtProjectGenerator.py | 8 + lutinExtProjectGeneratorXCode.py | 8 + lutinHeritage.py | 8 + lutinHost.py | 19 +- lutinImage.py | 8 + lutinModule.py | 10 +- lutinMultiprocess.py | 8 + lutinTarget.py | 163 +++++++++++++----- lutinTools.py | 8 + .../lutinTarget_Android.py | 38 +++- .../lutinTarget_IOs.py | 30 +++- .../lutinTarget_Linux.py | 19 +- .../lutinTarget_MacOs.py | 21 ++- .../lutinTarget_Windows.py | 42 +++-- 19 files changed, 385 insertions(+), 107 deletions(-) rename lutinTargetAndroid.py => target/lutinTarget_Android.py (98%) rename lutinTargetIOs.py => target/lutinTarget_IOs.py (96%) rename lutinTargetLinux.py => target/lutinTarget_Linux.py (91%) rename lutinTargetMacOs.py => target/lutinTarget_MacOs.py (88%) rename lutinTargetWindows.py => target/lutinTarget_Windows.py (68%) diff --git a/lutin.py b/lutin.py index f3bf2c5..65ea217 100755 --- a/lutin.py +++ b/lutin.py @@ -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,7 +29,7 @@ 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")) @@ -126,60 +134,61 @@ import lutinTools def Start(): #available target : Linux / MacOs / Windows / Android ... targetName=lutinHost.OS - #compilation base - compilator="gcc" - # build mode - mode="release" - bus="auto" - arch="auto" - # 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": debug.warning("argument bus is not implemented") - bus=argument.get_arg() + config["bus-size"]=argument.get_arg() elif argument.get_option_nName() == "arch": debug.warning("argument arch is not implemented") - arch=argument.get_arg() + config["arch"]=argument.get_arg() elif argument.get_option_nName() == "compilator": if 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" - bus="auto" - arch="auto" - 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: @@ -189,14 +198,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() @@ -220,6 +229,7 @@ if __name__ == '__main__': and folder.lower()!="out" : debug.debug("Automatic load path: '" + folder + "'") lutinModule.import_path(folder) + lutinTarget.import_path(folder) Start() diff --git a/lutinArg.py b/lutinArg.py index 85669c4..92f3674 100644 --- a/lutinArg.py +++ b/lutinArg.py @@ -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 diff --git a/lutinDebug.py b/lutinDebug.py index bf8f8ae..955b531 100644 --- a/lutinDebug.py +++ b/lutinDebug.py @@ -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 thread import lutinMultiprocess diff --git a/lutinDepend.py b/lutinDepend.py index 5971d93..995a71c 100644 --- a/lutinDepend.py +++ b/lutinDepend.py @@ -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 diff --git a/lutinEnv.py b/lutinEnv.py index 439e9bd..f447070 100644 --- a/lutinEnv.py +++ b/lutinEnv.py @@ -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 diff --git a/lutinExtProjectGenerator.py b/lutinExtProjectGenerator.py index 967e80d..b265db5 100644 --- a/lutinExtProjectGenerator.py +++ b/lutinExtProjectGenerator.py @@ -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 diff --git a/lutinExtProjectGeneratorXCode.py b/lutinExtProjectGeneratorXCode.py index 41a4d4c..73ad0a4 100644 --- a/lutinExtProjectGeneratorXCode.py +++ b/lutinExtProjectGeneratorXCode.py @@ -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 diff --git a/lutinHeritage.py b/lutinHeritage.py index 62d4891..2888d4f 100644 --- a/lutinHeritage.py +++ b/lutinHeritage.py @@ -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 diff --git a/lutinHost.py b/lutinHost.py index 849b7c5..931c864 100644 --- a/lutinHost.py +++ b/lutinHost.py @@ -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)) + diff --git a/lutinImage.py b/lutinImage.py index 04b8051..a2caec7 100644 --- a/lutinImage.py +++ b/lutinImage.py @@ -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 lutinTools as tools import platform diff --git a/lutinModule.py b/lutinModule.py index 05dd244..36a50d4 100644 --- a/lutinModule.py +++ b/lutinModule.py @@ -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 @@ -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); diff --git a/lutinMultiprocess.py b/lutinMultiprocess.py index d9d3fb3..345e4ce 100644 --- a/lutinMultiprocess.py +++ b/lutinMultiprocess.py @@ -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 diff --git a/lutinTarget.py b/lutinTarget.py index 4830c61..cab519b 100644 --- a/lutinTarget.py +++ b/lutinTarget.py @@ -1,49 +1,62 @@ #!/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.info("config=" + str(config)) if arch != "": self.arch = "-arch " + arch else: self.arch = "" - #processor type selection (auto/arm/ppc/x86) - self.selectArch = "auto" - #bus size selection (auto/32/64) - self.selectBus = "auto" - 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("================================="); - 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'] @@ -69,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" @@ -96,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: @@ -105,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: @@ -325,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 diff --git a/lutinTools.py b/lutinTools.py index 3d5fe23..f91ae72 100644 --- a/lutinTools.py +++ b/lutinTools.py @@ -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 diff --git a/lutinTargetAndroid.py b/target/lutinTarget_Android.py similarity index 98% rename from lutinTargetAndroid.py rename to target/lutinTarget_Android.py index 0d0b5fd..b73645c 100644 --- a/lutinTargetAndroid.py +++ b/target/lutinTarget_Android.py @@ -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,8 +73,14 @@ 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" + + if self.selectBus = "auto": + + + if self.selectArch = "auto": + lutinHost.BUS_SIZE + # for gcc : # for clang : diff --git a/lutinTargetIOs.py b/target/lutinTarget_IOs.py similarity index 96% rename from lutinTargetIOs.py rename to target/lutinTarget_IOs.py index 670d54c..88a3f64 100644 --- a/lutinTargetIOs.py +++ b/target/lutinTarget_IOs.py @@ -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="" diff --git a/lutinTargetLinux.py b/target/lutinTarget_Linux.py similarity index 91% rename from lutinTargetLinux.py rename to target/lutinTarget_Linux.py index d11f901..2ead658 100644 --- a/lutinTargetLinux.py +++ b/target/lutinTarget_Linux.py @@ -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,17 @@ 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, "") def generate_list_separate_coma(self, list): result = "" diff --git a/lutinTargetMacOs.py b/target/lutinTarget_MacOs.py similarity index 88% rename from lutinTargetMacOs.py rename to target/lutinTarget_MacOs.py index c263408..bcdf0ea 100644 --- a/lutinTargetMacOs.py +++ b/target/lutinTarget_MacOs.py @@ -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" diff --git a/lutinTargetWindows.py b/target/lutinTarget_Windows.py similarity index 68% rename from lutinTargetWindows.py rename to target/lutinTarget_Windows.py index 33d7ab5..bd494d5 100644 --- a/lutinTargetWindows.py +++ b/target/lutinTarget_Windows.py @@ -1,31 +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: - #target 64 bits: - cross = "x86_64-w64-mingw32-" - # target 32 bits: - 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"