Skip to content

Commit 5152c1c

Browse files
committed
Make object files depend on compiler flags
1 parent 5d0ce3c commit 5152c1c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tools/toolchains/__init__.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ class mbedToolchain:
252252

253253
MBED_CONFIG_FILE_NAME="mbed_config.h"
254254

255+
PROFILE_FILE_NAME = ".profile"
256+
255257
__metaclass__ = ABCMeta
256258

257259
profile_template = {'common':[], 'c':[], 'cxx':[], 'asm':[], 'ld':[]}
@@ -798,6 +800,7 @@ def compile_sources(self, resources, inc_dirs=None):
798800

799801
# Generate configuration header (this will update self.build_all if needed)
800802
self.get_config_header()
803+
self.dump_build_profile()
801804

802805
# Sort compile queue for consistency
803806
files_to_compile.sort()
@@ -911,13 +914,16 @@ def compile_command(self, source, object, includes):
911914
deps = []
912915
config_file = ([self.config.app_config_location]
913916
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):
915920
if ext == '.cpp' or self.COMPILE_C_AS_CPP:
916921
return self.compile_cpp(source, object, includes)
917922
else:
918923
return self.compile_c(source, object, includes)
919924
elif ext == '.s':
920925
deps = [source]
926+
deps.append(join(self.build_dir, self.PROFILE_FILE_NAME))
921927
if self.need_update(object, deps):
922928
return self.assemble(source, object, includes)
923929
else:
@@ -1161,6 +1167,16 @@ def get_config_header(self):
11611167
self.config_processed = True
11621168
return self.config_file
11631169

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+
11641180
@staticmethod
11651181
def generic_check_executable(tool_key, executable_name, levels_up,
11661182
nested_dir=None):

0 commit comments

Comments
 (0)