@@ -252,6 +252,8 @@ class mbedToolchain:
252
252
253
253
MBED_CONFIG_FILE_NAME = "mbed_config.h"
254
254
255
+ PROFILE_FILE_NAME = ".profile"
256
+
255
257
__metaclass__ = ABCMeta
256
258
257
259
profile_template = {'common' :[], 'c' :[], 'cxx' :[], 'asm' :[], 'ld' :[]}
@@ -798,6 +800,7 @@ def compile_sources(self, resources, inc_dirs=None):
798
800
799
801
# Generate configuration header (this will update self.build_all if needed)
800
802
self .get_config_header ()
803
+ self .dump_build_profile ()
801
804
802
805
# Sort compile queue for consistency
803
806
files_to_compile .sort ()
@@ -911,13 +914,16 @@ def compile_command(self, source, object, includes):
911
914
deps = []
912
915
config_file = ([self .config .app_config_location ]
913
916
if self .config .app_config_location else [])
914
- if len (deps ) == 0 or self .need_update (object , deps + config_file ):
917
+ deps .append (join (self .build_dir , self .PROFILE_FILE_NAME ))
918
+ deps .append (config_file )
919
+ if len (deps ) == 0 or self .need_update (object , deps ):
915
920
if ext == '.cpp' or self .COMPILE_C_AS_CPP :
916
921
return self .compile_cpp (source , object , includes )
917
922
else :
918
923
return self .compile_c (source , object , includes )
919
924
elif ext == '.s' :
920
925
deps = [source ]
926
+ deps .append (join (self .build_dir , self .PROFILE_FILE_NAME ))
921
927
if self .need_update (object , deps ):
922
928
return self .assemble (source , object , includes )
923
929
else :
@@ -1161,6 +1167,16 @@ def get_config_header(self):
1161
1167
self .config_processed = True
1162
1168
return self .config_file
1163
1169
1170
+ def dump_build_profile (self ):
1171
+ """Dump the current build profile and macros into the `.profile` file
1172
+ in the build directory"""
1173
+ to_dump = (str (sorted (list (self .flags .iteritems ()))) +
1174
+ str (sorted (self .macros )))
1175
+ where = join (self .build_dir , self .PROFILE_FILE_NAME )
1176
+ if not exists (where ) or to_dump != open (where ).read ():
1177
+ with open (where , "wb" ) as out :
1178
+ out .write (to_dump )
1179
+
1164
1180
@staticmethod
1165
1181
def generic_check_executable (tool_key , executable_name , levels_up ,
1166
1182
nested_dir = None ):
0 commit comments