提交 9539892a 编写于 作者: armink_ztl's avatar armink_ztl

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

上级 ff9162a9
......@@ -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,16 +178,25 @@ 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)
stdout, stderr = child.communicate()
# example stdout: IAR ANSI C/C++ Compiler V8.20.1.14183/W32 for ARM
return re.search('[\d\.]+', stdout).group(0)
\ No newline at end of file
return re.search('[\d\.]+', stdout).group(0)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册