21
21
from tools .settings import ARM_BIN , ARM_INC , ARM_LIB , MY_ARM_CLIB , ARM_CPPLIB , GOANNA_PATH
22
22
from tools .hooks import hook_tool
23
23
from tools .utils import mkdir
24
+ import copy
24
25
25
26
class ARM (mbedToolchain ):
26
27
LINKER_EXT = '.sct'
@@ -30,6 +31,17 @@ class ARM(mbedToolchain):
30
31
DIAGNOSTIC_PATTERN = re .compile ('"(?P<file>[^"]+)", line (?P<line>\d+)( \(column (?P<column>\d+)\)|): (?P<severity>Warning|Error): (?P<message>.+)' )
31
32
DEP_PATTERN = re .compile ('\S+:\s(?P<file>.+)\n ' )
32
33
34
+
35
+ DEFAULT_FLAGS = {
36
+ 'common' : ["-c" , "--gnu" ,
37
+ "-Otime" , "--split_sections" , "--apcs=interwork" ,
38
+ "--brief_diagnostics" , "--restrict" , "--multibyte_chars" , "-I" , "\" " + ARM_INC + "\" " ],
39
+ 'asm' : [],
40
+ 'c' : ["--md" , "--no_depend_system_headers" , "--c99" , "-D__ASSERT_MSG" ],
41
+ 'cxx' : ["--cpp" , "--no_rtti" ],
42
+ 'ld' : [],
43
+ }
44
+
33
45
def __init__ (self , target , options = None , notify = None , macros = None , silent = False , extra_verbose = False ):
34
46
mbedToolchain .__init__ (self , target , options , notify , macros , silent , extra_verbose = extra_verbose )
35
47
@@ -43,34 +55,25 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
43
55
cpu = target .core
44
56
45
57
main_cc = join (ARM_BIN , "armcc" )
46
- common = ["-c" ,
47
- "--cpu=%s" % cpu , "--gnu" ,
48
- "-Otime" , "--split_sections" , "--apcs=interwork" ,
49
- "--brief_diagnostics" , "--restrict" , "--multibyte_chars"
50
- ]
51
58
59
+ self .flags = copy .deepcopy (self .DEFAULT_FLAGS )
60
+ self .flags ['common' ] += ["--cpu=%s" % cpu ]
52
61
if "save-asm" in self .options :
53
- common .extend (["--asm" , "--interleave" ])
62
+ self . flags [ ' common' ] .extend (["--asm" , "--interleave" ])
54
63
55
64
if "debug-info" in self .options :
56
- common .append ("-O0" )
65
+ self .flags ['common' ].append ("-g" )
66
+ self .flags ['c' ].append ("-O0" )
57
67
else :
58
- common .append ("-O3" )
59
- # add debug symbols for all builds
60
- common .append ("-g" )
61
-
62
- common_c = [
63
- "--md" , "--no_depend_system_headers" ,
64
- '-I%s' % ARM_INC
65
- ]
68
+ self .flags ['c' ].append ("-O3" )
66
69
67
- self .asm = [main_cc ] + common + [ '-I%s' % ARM_INC ]
70
+ self .asm = [main_cc ] + self . flags [ ' common' ] + self . flags [ 'asm' ]
68
71
if not "analyze" in self .options :
69
- self .cc = [main_cc ] + common + common_c + [ "--c99" ]
70
- self .cppc = [main_cc ] + common + common_c + [ "--cpp" , "--no_rtti" ]
72
+ self .cc = [main_cc ] + self . flags [ ' common' ] + self . flags [ 'c' ]
73
+ self .cppc = [main_cc ] + self . flags [ ' common' ] + self . flags [ 'c' ] + self . flags [ 'cxx' ]
71
74
else :
72
- self .cc = [join (GOANNA_PATH , "goannacc" ), "--with-cc=" + main_cc .replace ('\\ ' , '/' ), "--dialect=armcc" , '--output-format="%s"' % self .GOANNA_FORMAT ] + common + common_c + [ "--c99" ]
73
- self .cppc = [join (GOANNA_PATH , "goannac++" ), "--with-cxx=" + main_cc .replace ('\\ ' , '/' ), "--dialect=armcc" , '--output-format="%s"' % self .GOANNA_FORMAT ] + common + common_c + [ "--cpp" , "--no_rtti" ]
75
+ self .cc = [join (GOANNA_PATH , "goannacc" ), "--with-cc=" + main_cc .replace ('\\ ' , '/' ), "--dialect=armcc" , '--output-format="%s"' % self .GOANNA_FORMAT ] + self . flags [ ' common' ] + self . flags [ 'c' ]
76
+ self .cppc = [join (GOANNA_PATH , "goannac++" ), "--with-cxx=" + main_cc .replace ('\\ ' , '/' ), "--dialect=armcc" , '--output-format="%s"' % self .GOANNA_FORMAT ] + self . flags [ ' common' ] + self . flags [ 'c' ] + self . flags [ 'cxx' ]
74
77
75
78
self .ld = [join (ARM_BIN , "armlink" )]
76
79
self .sys_libs = []
@@ -214,8 +217,11 @@ def binary(self, resources, elf, bin):
214
217
class ARM_STD (ARM ):
215
218
def __init__ (self , target , options = None , notify = None , macros = None , silent = False , extra_verbose = False ):
216
219
ARM .__init__ (self , target , options , notify , macros , silent , extra_verbose = extra_verbose )
217
- self .cc += ["-D__ASSERT_MSG" ]
218
- self .cppc += ["-D__ASSERT_MSG" ]
220
+
221
+ # Extend flags
222
+ self .flags ['ld' ].extend (["--libpath" , ARM_LIB ])
223
+
224
+ # Run-time values
219
225
self .ld .extend (["--libpath" , ARM_LIB ])
220
226
221
227
@@ -225,18 +231,24 @@ class ARM_MICRO(ARM):
225
231
def __init__ (self , target , options = None , notify = None , macros = None , silent = False , extra_verbose = False ):
226
232
ARM .__init__ (self , target , options , notify , macros , silent , extra_verbose = extra_verbose )
227
233
228
- # Compiler
229
- self .asm += [ "-D__MICROLIB" ]
230
- self .cc += [ "--library_type=microlib" , "-D__MICROLIB" , "-D__ASSERT_MSG" ]
231
- self .cppc += [ "--library_type=microlib" , "-D__MICROLIB" , "-D__ASSERT_MSG" ]
234
+ # Extend flags
235
+ self .flags [ 'common' ]. extend ([ "-D__MICROLIB" ])
236
+ self .flags [ 'c' ]. extend ([ "--library_type=microlib" ])
237
+ self .flags [ 'ld' ]. extend ([ "--library_type=microlib" ])
232
238
233
- # Linker
234
- self .ld .append ("--library_type=microlib" )
239
+ # Run-time values
240
+ self .asm += ["-D__MICROLIB" ]
241
+ self .cc += ["-D__MICROLIB" , "--library_type=microlib" ]
242
+ self .cppc += ["-D__MICROLIB" , "--library_type=microlib" ]
243
+ self .ld += ["--library_type=microlib" ]
235
244
236
245
# We had to patch microlib to add C++ support
237
246
# In later releases this patch should have entered mainline
238
247
if ARM_MICRO .PATCHED_LIBRARY :
239
- self .ld .append ("--noscanlib" )
248
+ # Run-time values
249
+ self .flags ['ld' ].extend (["--noscanlib" ])
250
+ # Run-time values
251
+ self .ld += ["--noscanlib" ]
240
252
241
253
# System Libraries
242
254
self .sys_libs .extend ([join (MY_ARM_CLIB , lib + ".l" ) for lib in ["mc_p" , "mf_p" , "m_ps" ]])
@@ -247,4 +259,7 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
247
259
elif target .core in ["Cortex-M0" , "Cortex-M0+" ]:
248
260
self .sys_libs .extend ([join (ARM_CPPLIB , lib + ".l" ) for lib in ["cpp_ps" , "cpprt_p" ]])
249
261
else :
262
+ # Run-time values
263
+ self .flags ['ld' ].extend (["--libpath" , ARM_LIB ])
264
+ # Run-time values
250
265
self .ld .extend (["--libpath" , ARM_LIB ])
0 commit comments