Skip to content

Commit 636d668

Browse files
committed
cortexm_common_ldscript: fix running test commands alone
When run alone, `make tests-rom-overflow` failed when it tried to compile ELFFILE as it was using the overflowing FW_ROM_LEN. In fact target specific variables are also use for prerequisites, except when the target is already built by another rule before. I used `BASELIBS` as it already the dependency for ELFFILE. https://www.gnu.org/software/make/manual/make.html#Target_002dspecific
1 parent 2de76c0 commit 636d668

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/cortexm_common_ldscript/Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ all: $(COMPILE_TESTS)
2020
.PHONY: $(COMPILE_TESTS)
2121

2222

23+
# Test elffiles should not have $(ELFFILE) prerequisite as target specific
24+
# variables are used for configuration and they also apply to prerequisites.
25+
#
26+
# https://www.gnu.org/software/make/manual/make.html#Target_002dspecific
27+
28+
ELFFILES_DEPS = $(BASELIBS) FORCE
29+
30+
2331
# Compile elf files with different ROM_OFFSET
2432
# and verify the offset is taken into account
2533

@@ -38,7 +46,7 @@ test-offset_%: $(BINDIR)/$(APPLICATION)_offset_%.elf
3846
$(Q)@echo [OK]
3947

4048
$(BINDIR)/$(APPLICATION)_offset_%.elf: ROM_OFFSET=$*
41-
$(BINDIR)/$(APPLICATION)_offset_%.elf: $(ELFFILE)
49+
$(BINDIR)/$(APPLICATION)_offset_%.elf: $(ELFFILES_DEPS)
4250
$(Q)$(_LINK) -o $@
4351
.PRECIOUS: $(BINDIR)/$(APPLICATION)_offset_%.elf
4452

@@ -63,7 +71,7 @@ test-fw_len_half_rom: $(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf
6371
fi
6472
$(Q)@echo [OK]
6573
$(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf: FW_ROM_LEN=$$(($(ROM_LEN_BYTES)/2))
66-
$(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf: $(ELFFILE)
74+
$(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf: $(ELFFILES_DEPS)
6775
$(Q)$(_LINK) -o $@
6876
.PRECIOUS: $(BINDIR)/$(APPLICATION)_fw_len_half_rom.elf
6977

@@ -80,7 +88,7 @@ $(BINDIR)/$(APPLICATION)_assert_overflow_too_big_for_rom.elf: FW_ROM_LEN=$$(($(R
8088
$(BINDIR)/$(APPLICATION)_assert_overflow_offset_and_romlen.elf: ROM_OFFSET=0x1000
8189
$(BINDIR)/$(APPLICATION)_assert_overflow_offset_and_romlen.elf: FW_ROM_LEN=$(ROM_LEN_BYTES)
8290

83-
$(BINDIR)/$(APPLICATION)_assert_overflow_%.elf: $(ELFFILE)
91+
$(BINDIR)/$(APPLICATION)_assert_overflow_%.elf: $(ELFFILES_DEPS)
8492
$(Q) echo -n "Test ROM overflow detection: "
8593
$(Q){ $(_LINK) -o $@ 2>&1 | grep -q 'Specified _fw_rom_length does not fit in ROM' ; } \
8694
&& echo [OK] || { echo [ERROR] Compilation should have failed >&2; exit 1; }

0 commit comments

Comments
 (0)