tests: Use better linker method to pick up test case registration

This commit is contained in:
Angus Gratton 2016-02-17 17:31:46 +11:00
parent a109a19799
commit 3d4dcc9042
2 changed files with 4 additions and 6 deletions

View file

@ -279,7 +279,7 @@ $$($(1)_OBJ_DIR)%.o: $$($(1)_REAL_ROOT)%.S $$($(1)_MAKEFILE) $(wildcard $(ROOT)*
$$($(1)_AR): $$($(1)_OBJ_FILES) $$($(1)_SRC_FILES) $$($(1)_AR): $$($(1)_OBJ_FILES) $$($(1)_SRC_FILES)
$(vecho) "AR $$@" $(vecho) "AR $$@"
$(Q) mkdir -p $$(dir $$@) $(Q) mkdir -p $$(dir $$@)
$(Q) $(AR) cru $$@ $$^ $(Q) $(AR) cru $$@ $$(filter %.o,$$^)
COMPONENT_ARS += $$($(1)_AR) COMPONENT_ARS += $$($(1)_AR)

View file

@ -6,11 +6,9 @@ PROGRAM_SRC_DIR = $(PROGRAM_DIR) $(PROGRAM_DIR)cases
PROGRAM_INC_DIR = $(PROGRAM_DIR)unity/src PROGRAM_INC_DIR = $(PROGRAM_DIR)unity/src
PROGRAM_EXTRA_SRC_FILES = $(PROGRAM_DIR)unity/src/unity.c PROGRAM_EXTRA_SRC_FILES = $(PROGRAM_DIR)unity/src/unity.c
# append -u <basename_test_entry to the linker arguments for
# each source file in the 'cases' directory, so the test case
# entries get added to the compiled binary
TESTCASE_SRC_FILES = $(wildcard $(PROGRAM_DIR)cases/*.c) TESTCASE_SRC_FILES = $(wildcard $(PROGRAM_DIR)cases/*.c)
TESTCASE_ENTRIES = $(sort $(patsubst %.c,%,$(TESTCASE_SRC_FILES)))
EXTRA_LDFLAGS = $(foreach entry,$(TESTCASE_ENTRIES),$(BUILD_DIR)program/$(entry).o) # Link every object in the 'program' archive, to pick up constructor functions for test cases
EXTRA_LDFLAGS = -Wl,--whole-archive $(BUILD_DIR)program.a -Wl,--no-whole-archive
include ../common.mk include ../common.mk