@@ -914,16 +914,19 @@ def compile_command(self, source, object, includes):
914
914
deps = []
915
915
config_file = ([self .config .app_config_location ]
916
916
if self .config .app_config_location else [])
917
- deps .append (join (self .build_dir , self .PROFILE_FILE_NAME ))
918
917
deps .append (config_file )
918
+ if ext == '.cpp' or self .COMPILE_C_AS_CPP :
919
+ deps .append (join (self .build_dir , self .PROFILE_FILE_NAME + "-cxx" ))
920
+ else :
921
+ deps .append (join (self .build_dir , self .PROFILE_FILE_NAME + "-c" ))
919
922
if len (deps ) == 0 or self .need_update (object , deps ):
920
923
if ext == '.cpp' or self .COMPILE_C_AS_CPP :
921
924
return self .compile_cpp (source , object , includes )
922
925
else :
923
926
return self .compile_c (source , object , includes )
924
927
elif ext == '.s' :
925
928
deps = [source ]
926
- deps .append (join (self .build_dir , self .PROFILE_FILE_NAME ))
929
+ deps .append (join (self .build_dir , self .PROFILE_FILE_NAME + "-asm" ))
927
930
if self .need_update (object , deps ):
928
931
return self .assemble (source , object , includes )
929
932
else :
@@ -1018,8 +1021,9 @@ def link_program(self, r, tmp_path, name):
1018
1021
r .objects = sorted (set (r .objects ))
1019
1022
config_file = ([self .config .app_config_location ]
1020
1023
if self .config .app_config_location else [])
1021
- if self .need_update (elf , r .objects + r .libraries + [r .linker_script ] +
1022
- config_file ):
1024
+ dependencies = r .objects + r .libraries + [r .linker_script , config_file ]
1025
+ dependencies .append (join (self .build_dir , self .PROFILE_FILE_NAME + "-ld" ))
1026
+ if self .need_update (elf , dependencies ):
1023
1027
needed_update = True
1024
1028
self .progress ("link" , name )
1025
1029
self .link (elf , r .objects , r .libraries , r .lib_dirs , r .linker_script )
@@ -1170,12 +1174,18 @@ def get_config_header(self):
1170
1174
def dump_build_profile (self ):
1171
1175
"""Dump the current build profile and macros into the `.profile` file
1172
1176
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 )
1177
+ for key in ["cxx" , "c" , "asm" , "ld" ]:
1178
+ to_dump = (str (self .flags [key ]) + str (sorted (self .macros )))
1179
+ if key in ["cxx" , "c" ]:
1180
+ to_dump += str (self .flags ['common' ])
1181
+ where = join (self .build_dir , self .PROFILE_FILE_NAME + "-" + key )
1182
+ self ._overwrite_when_not_equal (where , to_dump )
1183
+
1184
+ @staticmethod
1185
+ def _overwrite_when_not_equal (filename , content ):
1186
+ if not exists (filename ) or content != open (filename ).read ():
1187
+ with open (filename , "wb" ) as out :
1188
+ out .write (content )
1179
1189
1180
1190
@staticmethod
1181
1191
def generic_check_executable (tool_key , executable_name , levels_up ,
0 commit comments