mirror of https://github.com/ARMmbed/mbed-os.git
Add pre-processing of linker scripts to Make exporter
For toolchains that do not implicitly run the C pre-processor on their linker scripts the toolchain is expected to define a `preproc` attribute. The Makefiles then pick up on this attribute and add another rule for pre-processing the linker script automatically.pull/3706/head
parent
af4d848144
commit
3155e71786
|
|
@ -67,6 +67,9 @@ CC = {{cc_cmd}}
|
|||
CPP = {{cppc_cmd}}
|
||||
LD = {{ld_cmd}}
|
||||
ELF2BIN = {{elf2bin_cmd}}
|
||||
{% if pp_cmd -%}
|
||||
PREPROC = {{pp_cmd}}
|
||||
{%- endif %}
|
||||
{% if hex_files %}
|
||||
SREC_CAT = srec_cat
|
||||
{%- endif %}
|
||||
|
|
@ -119,8 +122,13 @@ all: $(PROJECT).bin $(PROJECT).hex size
|
|||
+@echo "Compile: $(notdir $<)"
|
||||
@$(CPP) $(CXX_FLAGS) $(INCLUDE_PATHS) -o $@ $<
|
||||
|
||||
{% if pp_cmd %}
|
||||
$(PROJECT).link_script{{link_script_ext}}: $(LINKER_SCRIPT)
|
||||
@$(PREPROC) $< -o $@
|
||||
{% endif %}
|
||||
|
||||
{% block target_project_elf %}
|
||||
$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(LINKER_SCRIPT)
|
||||
$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) {% if pp_cmd -%} $(PROJECT).link_script{{link_script_ext}} {% else%} $(LINKER_SCRIPT) {% endif %}
|
||||
+@echo "link: $(notdir $@)"
|
||||
@$(LD) $(LD_FLAGS) {{link_script_option}} $(filter %{{link_script_ext}}, $^) $(LIBRARY_PATHS) --output $@ $(filter %.o, $^) $(LIBRARIES) $(LD_SYS_LIBS)
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,14 @@ class Makefile(Exporter):
|
|||
'user_library_flag': self.USER_LIBRARY_FLAG,
|
||||
}
|
||||
|
||||
if hasattr(self.toolchain, "preproc"):
|
||||
ctx['pp_cmd'] = " ".join(["\'" + part + "\'" for part
|
||||
in ([basename(self.toolchain.preproc[0])] +
|
||||
self.toolchain.preproc[1:] +
|
||||
self.toolchain.ld[1:])])
|
||||
else:
|
||||
ctx['pp_cmd'] = None
|
||||
|
||||
for key in ['include_paths', 'library_paths', 'linker_script',
|
||||
'hex_files']:
|
||||
if isinstance(ctx[key], list):
|
||||
|
|
|
|||
Loading…
Reference in New Issue