From d687cfb22841ba0e1ccf4c946f672dfaeae239cb Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sat, 10 Nov 2018 18:29:08 +0800 Subject: [Tools] Change building script for Py3 --- tools/utils.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'tools/utils.py') diff --git a/tools/utils.py b/tools/utils.py index fb151189d8..692cf36c69 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -183,14 +183,14 @@ def ProjectInfo(env): for group in project: # get each files - if group.has_key('src') and group['src']: + if 'src' in group and group['src']: FILES += group['src'] # get each include path - if group.has_key('CPPPATH') and group['CPPPATH']: + if 'CPPPATH' in group and group['CPPPATH']: CPPPATH += group['CPPPATH'] - if env.has_key('CPPDEFINES'): + if 'CPPDEFINES' in env: CPPDEFINES = env['CPPDEFINES'] CPPDEFINES = ListMap(CPPDEFINES) @@ -243,3 +243,47 @@ def ProjectInfo(env): proj['CPPDEFINES'] = CPPDEFINES return proj + +def VersionCmp(ver1, ver2): + la = ver1.split('.') + lb = ver2.split('.') + f = 0 + if len(la) > len(lb): + f = len(la) + else: + f = len(lb) + for i in range(f): + try: + if int(la[i]) > int(lb[i]): + return 1 + elif int(la[i]) == int(lb[i]): + continue + else: + return -1 + except IndexError as e: + if len(la) > len(lb): + return 1 + else: + return -1 + return 0 + +def GCCC99Patch(cflags): + import building + gcc_version = building.GetDepend('GCC_VERSION') + if gcc_version: + gcc_version = gcc_version.replace('"', '') + if VersionCmp(gcc_version, "4.8.0"): + # remove -std=c99 after GCC 4.8.x + cflags = cflags.replace('-std=c99', '') + + return cflags + +def ReloadModule(module): + import sys + if sys.version_info.major >= 3: + import importlib + importlib.reload(module) + else: + reload(module) + + return -- cgit v1.3.1 From 3c9f58a7abf015260e9aeffc97be2bd172c523e7 Mon Sep 17 00:00:00 2001 From: XXXXzzzz000 <119524428@qq.com> Date: Fri, 23 Nov 2018 09:23:31 +0800 Subject: [tools] fix bug. --- tools/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools/utils.py') diff --git a/tools/utils.py b/tools/utils.py index 692cf36c69..6dc56322a5 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -245,7 +245,9 @@ def ProjectInfo(env): return proj def VersionCmp(ver1, ver2): - la = ver1.split('.') + la=[]; + if ver1: + la = ver1.split('.') lb = ver2.split('.') f = 0 if len(la) > len(lb): -- cgit v1.3.1 From 702277a9b9a7298b3a00b6a4ed612d6fb5db4fde Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Sat, 11 May 2019 15:51:40 +0800 Subject: [tools] 修复 GCC 版本判断的方式并增加异常捕获 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- tools/utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tools/utils.py') diff --git a/tools/utils.py b/tools/utils.py index 6dc56322a5..9459396544 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -24,6 +24,7 @@ import sys import os +import re def splitall(loc): """ @@ -245,10 +246,11 @@ def ProjectInfo(env): return proj def VersionCmp(ver1, ver2): - la=[]; + la=[] if ver1: - la = ver1.split('.') - lb = ver2.split('.') + la = re.split("[. ]", ver1) + lb = re.split("[. ]", ver2) + f = 0 if len(la) > len(lb): f = len(la) @@ -262,7 +264,7 @@ def VersionCmp(ver1, ver2): continue else: return -1 - except IndexError as e: + except (IndexError, ValueError) as e: if len(la) > len(lb): return 1 else: @@ -274,7 +276,7 @@ def GCCC99Patch(cflags): gcc_version = building.GetDepend('GCC_VERSION') if gcc_version: 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 cflags = cflags.replace('-std=c99', '') -- cgit v1.3.1