diff options
| author | yangjie11 <[email protected]> | 2018-11-28 19:02:11 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-11-28 19:02:11 +0800 |
| commit | 1a7f95f92b84b0a3acd6243cb2a658b4f9b6f1ac (patch) | |
| tree | 3b90c3e4b7ced83ce239ae8df020926eaf74d7de /tools/utils.py | |
| parent | 4a43d3cdae1b731dcf51d3531048c51fd4142516 (diff) | |
| parent | d4469fe7d83d08913d096dc6d75a750dd854c0cc (diff) | |
Merge pull request #1 from RT-Thread/master
test
Diffstat (limited to 'tools/utils.py')
| -rw-r--r-- | tools/utils.py | 63 |
1 files changed, 56 insertions, 7 deletions
diff --git a/tools/utils.py b/tools/utils.py index fa501096a4..6dc56322a5 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -114,11 +114,14 @@ def walk_children(child): # print child full_path = child.rfile().abspath - file_type = full_path.rsplit('.',1)[1] + file_type_list = full_path.rsplit('.',1) #print file_type - if file_type in source_ext: - if full_path not in source_list: - source_list.append(full_path) + if (len(file_type_list) > 1): + file_type = full_path.rsplit('.',1)[1] + + if file_type in source_ext: + if full_path not in source_list: + source_list.append(full_path) children = child.all_children() if children != []: @@ -180,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) @@ -240,3 +243,49 @@ def ProjectInfo(env): proj['CPPDEFINES'] = CPPDEFINES return proj + +def VersionCmp(ver1, ver2): + la=[]; + if ver1: + 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 |
