the other jimmy / mbed-sdk-tools

Fork of mbed-sdk-tools by mbed official

Revision:
29:1210849dba19
Parent:
24:25bff2709c20
Child:
30:f12ce67666d0
diff -r e080013bb94e -r 1210849dba19 toolchains/iar.py
--- a/toolchains/iar.py	Mon Aug 29 10:55:42 2016 +0100
+++ b/toolchains/iar.py	Mon Aug 29 11:18:36 2016 +0100
@@ -17,6 +17,7 @@
 import re
 from os import remove
 from os.path import join, exists, dirname, splitext, exists
+from distutils.spawn import find_executable
 
 from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
 from tools.hooks import hook_tool
@@ -50,6 +51,12 @@
             cpuchoice = "Cortex-M7"
         else:
             cpuchoice = target.core
+
+        if not TOOLCHAIN_PATHS['IAR']:
+            exe =  find_executable('iccarm')
+            if exe:
+                TOOLCHAIN_PATHS['IAR'] = dirname(dirname(exe))
+
         # flags_cmd are used only by our scripts, the project files have them already defined,
         # using this flags results in the errors (duplication)
         # asm accepts --cpu Core or --fpu FPU, not like c/c++ --cpu=Core
@@ -101,6 +108,8 @@
         self.ar = join(IAR_BIN, "iarchive")
         self.elf2bin = join(IAR_BIN, "ielftool")
 
+        self.toolchain_path = TOOLCHAIN_PATHS['IAR']
+
     def parse_dependencies(self, dep_path):
         return [(self.CHROOT if self.CHROOT else '')+path.strip() for path in open(dep_path).readlines()
                 if (path and not path.isspace())]
@@ -151,12 +160,7 @@
         else:
             opts += ["-I%s" % i for i in includes]
 
-        config_header = self.get_config_header()
-        if for_asm:
-            # The assembler doesn't support '--preinclude', so we need to add
-            # the macros directly
-            opts = opts + ['-D%s' % d for d in self.get_config_macros()]
-        else:
+        if not for_asm:
             config_header = self.get_config_header()
             if config_header is not None:
                 opts = opts + self.get_config_option(config_header)
@@ -165,7 +169,7 @@
     @hook_tool
     def assemble(self, source, object, includes):
         # Build assemble command
-        cmd = self.asm + self.get_compile_options(self.get_symbols(), includes, for_asm=True) + ["-o", object, source]
+        cmd = self.asm + self.get_compile_options(self.get_symbols(True), includes, True) + ["-o", object, source]
 
         # Call cmdline hook
         cmd = self.hook.get_cmdline_assembler(cmd)