[tools] Fix IAR get version failed on RT-Thread Env tools.

This commit is contained in:
armink 2018-06-22 10:03:03 +08:00
parent ff9162a994
commit 9539892a1c
1 changed files with 12 additions and 3 deletions

View File

@ -164,7 +164,7 @@ def IARVersion():
def IARPath():
import rtconfig
# set environ
# backup environ
old_environ = os.environ
os.environ['RTT_CC'] = 'iar'
reload(rtconfig)
@ -178,12 +178,21 @@ def IARVersion():
return path
# get the IAR path in 'RTT_EXEC_PATH'
path = IARPath();
# retry to get IAR path on 'rtconfig.py'
if not os.path.exists(path):
rtt_exec_path = os.environ['RTT_EXEC_PATH']
if rtt_exec_path:
del os.environ['RTT_EXEC_PATH']
path = IARPath();
os.environ['RTT_EXEC_PATH'] = rtt_exec_path
if os.path.exists(path):
cmd = os.path.join(path, 'iccarm.exe')
else:
print('Get IAR version error. Please update IAR installation path in rtconfig.h!')
print('Get IAR version error. Please update IAR installation path in rtconfig.py!')
return "0.0"
child = subprocess.Popen([cmd, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)