From 91b0cecc2849c57e1b6c3620baf7d04bfaeb905c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 20 Feb 2015 21:40:03 +0100 Subject: [PATCH] [DEV] add getter version of gcc --- lutinModule.py | 2 +- lutinMultiprocess.py | 24 ++++++++++++++++++++++-- lutinTarget.py | 28 ++++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/lutinModule.py b/lutinModule.py index 754c07d..57915e6 100644 --- a/lutinModule.py +++ b/lutinModule.py @@ -112,7 +112,7 @@ class Module: "-Wall", "-Wsign-compare", "-Wreturn-type", - "-Wint-to-pointer-cast", + #"-Wint-to-pointer-cast", "-Wno-write-strings", "-Woverloaded-virtual", "-Wnon-virtual-dtor", diff --git a/lutinMultiprocess.py b/lutinMultiprocess.py index faef3ac..ec17edb 100644 --- a/lutinMultiprocess.py +++ b/lutinMultiprocess.py @@ -49,6 +49,28 @@ def store_command(cmdLine, file): 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() + # 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 @@ -62,10 +84,8 @@ def run_command(cmdLine, storeCmdLine="", buildId=-1, file=""): p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except subprocess.CalledProcessError as e: debug.error("subprocess.CalledProcessError : TODO ...") - debug.verbose("done 1") # launch the subprocess: output, err = p.communicate() - debug.verbose("done 2") # Check error : if p.returncode == 0: debug.debug(lutinEnv.print_pretty(cmdLine)) diff --git a/lutinTarget.py b/lutinTarget.py index a884646..074c19d 100644 --- a/lutinTarget.py +++ b/lutinTarget.py @@ -19,6 +19,7 @@ import lutinModule import lutinSystem import lutinImage import lutinHost +import lutinMultiprocess as multiprocess class Target: def __init__(self, name, config, arch): @@ -60,8 +61,13 @@ class Target: '-D_REENTRANT'] if self.name != "Windows": - self.global_flags_xx=['-std=c++11'] - self.global_flags_mm=['-std=c++11'] + if self.config["compilator"] == "clang" \ + or self.xx_version > 4007000: + self.global_flags_xx=['-std=c++11'] + self.global_flags_mm=['-std=c++11'] + else: + self.global_flags_xx=['-std=c++0x'] + self.global_flags_mm=['-std=c++0x'] else: self.global_flags_xx=['-static-libgcc', '-static-libstdc++', '-std=c++11'] self.global_flags_mm=[] @@ -118,6 +124,16 @@ class Target: 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(".") + 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 + "'"); @@ -133,6 +149,14 @@ class Target: 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.debug(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"