summaryrefslogtreecommitdiff
path: root/tools/utils.py
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-11-10 18:29:08 +0800
committerBernard Xiong <[email protected]>2018-11-10 18:29:08 +0800
commitd687cfb22841ba0e1ccf4c946f672dfaeae239cb (patch)
treeaf7d6547eef20e642e1230c141585507f839924e /tools/utils.py
parentb69baa965809420fc3fcd19dd55fc1126a68c08d (diff)
[Tools] Change building script for Py3
Diffstat (limited to 'tools/utils.py')
-rw-r--r--tools/utils.py50
1 files changed, 47 insertions, 3 deletions
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