Explorar el Código

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

armink hace 7 años
padre
commit
9539892a1c
Se han modificado 1 ficheros con 12 adiciones y 3 borrados
  1. 12 3
      tools/iar.py

+ 12 - 3
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)
+    return re.search('[\d\.]+', stdout).group(0)