From 9539892a1c4922f18ed3d7538d187d1d8e8b6081 Mon Sep 17 00:00:00 2001 From: armink Date: Fri, 22 Jun 2018 10:03:03 +0800 Subject: [PATCH] [tools] Fix IAR get version failed on RT-Thread Env tools. --- tools/iar.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/iar.py b/tools/iar.py index 09271ba4eb..66864d1adf 100644 --- a/tools/iar.py +++ b/tools/iar.py @@ -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)