[tools] 修复 GCC 版本判断的方式并增加异常捕获
Signed-off-by: MurphyZhao <d2014zjt@163.com>
This commit is contained in:
parent
854d0144d3
commit
702277a9b9
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
def splitall(loc):
|
def splitall(loc):
|
||||||
"""
|
"""
|
||||||
|
@ -245,10 +246,11 @@ def ProjectInfo(env):
|
||||||
return proj
|
return proj
|
||||||
|
|
||||||
def VersionCmp(ver1, ver2):
|
def VersionCmp(ver1, ver2):
|
||||||
la=[];
|
la=[]
|
||||||
if ver1:
|
if ver1:
|
||||||
la = ver1.split('.')
|
la = re.split("[. ]", ver1)
|
||||||
lb = ver2.split('.')
|
lb = re.split("[. ]", ver2)
|
||||||
|
|
||||||
f = 0
|
f = 0
|
||||||
if len(la) > len(lb):
|
if len(la) > len(lb):
|
||||||
f = len(la)
|
f = len(la)
|
||||||
|
@ -262,7 +264,7 @@ def VersionCmp(ver1, ver2):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
return -1
|
return -1
|
||||||
except IndexError as e:
|
except (IndexError, ValueError) as e:
|
||||||
if len(la) > len(lb):
|
if len(la) > len(lb):
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
|
@ -274,7 +276,7 @@ def GCCC99Patch(cflags):
|
||||||
gcc_version = building.GetDepend('GCC_VERSION')
|
gcc_version = building.GetDepend('GCC_VERSION')
|
||||||
if gcc_version:
|
if gcc_version:
|
||||||
gcc_version = gcc_version.replace('"', '')
|
gcc_version = gcc_version.replace('"', '')
|
||||||
if VersionCmp(gcc_version, "4.8.0"):
|
if VersionCmp(gcc_version, "4.8.0") == 1:
|
||||||
# remove -std=c99 after GCC 4.8.x
|
# remove -std=c99 after GCC 4.8.x
|
||||||
cflags = cflags.replace('-std=c99', '')
|
cflags = cflags.replace('-std=c99', '')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue