diff options
| author | xph <[email protected]> | 2020-04-09 16:35:28 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-04-09 16:35:28 +0800 |
| commit | ca7f01d79b3e0a997c771cec298e4ebd65b75809 (patch) | |
| tree | 3d2c48aae7203b14038ba7b98b500b5343ed7f2a /tools/utils.py | |
| parent | f763f8e7284b0492c5a65ad0abf94ee1963d7dcc (diff) | |
| parent | baa3145bfe61b3330b6a160523cc5470fa5db3a7 (diff) | |
Merge pull request #1 from RT-Thread/master
sync rtt
Diffstat (limited to 'tools/utils.py')
| -rw-r--r-- | tools/utils.py | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/tools/utils.py b/tools/utils.py index fb151189d8..9459396544 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -24,6 +24,7 @@ import sys import os +import re def splitall(loc): """ @@ -183,14 +184,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 +244,50 @@ def ProjectInfo(env): proj['CPPDEFINES'] = CPPDEFINES return proj + +def VersionCmp(ver1, ver2): + la=[] + if ver1: + la = re.split("[. ]", ver1) + lb = re.split("[. ]", ver2) + + 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, ValueError) 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") == 1: + # 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 |
