[tools] Python 3 compatibility support

This commit is contained in:
tangyuxin
2021-04-05 11:59:54 +08:00
parent 1e4a463f36
commit 510955ba42
12 changed files with 135 additions and 56 deletions

View File

@@ -85,7 +85,7 @@ class Win32Spawn:
try:
os.remove(f)
except Exception as e:
print ('Error removing file: ' + e)
print('Error removing file: ' + e)
return -1
return 0
@@ -106,8 +106,8 @@ class Win32Spawn:
try:
proc = subprocess.Popen(cmdline, env=_e, shell=False)
except Exception as e:
print ('Error in calling command:' + cmdline.split(' ')[0])
print ('Exception: ' + os.strerror(e.errno))
print('Error in calling command:' + cmdline.split(' ')[0])
print('Exception: ' + os.strerror(e.errno))
if (os.strerror(e.errno) == "No such file or directory"):
print ("\nPlease check Toolchains PATH setting.\n")
@@ -274,7 +274,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
os.environ['RTT_CC'] = rtconfig.CROSS_TOOL
utils.ReloadModule(rtconfig)
except KeyError:
print ('Unknow target: '+ tgt_name+'. Avaible targets: ' +', '.join(tgt_dict.keys()))
print('Unknow target: '+ tgt_name+'. Avaible targets: ' +', '.join(tgt_dict.keys()))
sys.exit(1)
# auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed
@@ -662,7 +662,7 @@ def DefineGroup(name, src, depend, **parameters):
# check whether to clean up library
if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
if group['src'] != []:
print ('Remove library:'+ GroupLibFullName(name, Env))
print('Remove library:'+ GroupLibFullName(name, Env))
fn = os.path.join(group['path'], GroupLibFullName(name, Env))
if os.path.exists(fn):
os.unlink(fn)
@@ -735,7 +735,7 @@ def BuildLibInstallAction(target, source, env):
if Group['name'] == lib_name:
lib_name = GroupLibFullName(Group['name'], env)
dst_name = os.path.join(Group['path'], lib_name)
print ('Copy '+lib_name+' => ' +dst_name)
print('Copy '+lib_name+' => ' + dst_name)
do_copy_file(lib_name, dst_name)
break
@@ -996,11 +996,11 @@ def GetVersion():
prepcessor.process_contents(contents)
def_ns = prepcessor.cpp_namespace
version = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_VERSION']))
subversion = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_SUBVERSION']))
version = int([ch for ch in def_ns['RT_VERSION'] if ch in '0123456789.'])
subversion = int([ch for ch in def_ns['RT_SUBVERSION'] if ch in '0123456789.'])
if 'RT_REVISION' in def_ns:
revision = int(filter(lambda ch: ch in '0123456789.', def_ns['RT_REVISION']))
revision = int([ch for ch in def_ns['RT_REVISION'] if ch in '0123456789.'])
return '%d.%d.%d' % (version, subversion, revision)
return '0.%d.%d' % (version, subversion)