Skip to content

Commit

Permalink
fixup!
Browse files Browse the repository at this point in the history
  • Loading branch information
paulsc96 committed Nov 14, 2024
1 parent ab359fb commit 89242a4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions sw/sw.mk
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ CHS_SW_GEN_HDRS += $(OTPROOT)/.generated
%.o: %.S $(CHS_SW_GEN_HDRS)
$(CHS_SW_CC) $(CHS_SW_INCLUDES) $(CHS_SW_CCFLAGS) -c $< -o $@

# Programs may specify a linking mode in their name, e.g. `helloworld.spm.c`.
# Tests with such infixes are built only for one linking mode, tests without them for all
define chs_sw_ld_elf_rule
.PRECIOUS: %.$(1).elf

Expand All @@ -109,6 +111,13 @@ endef

$(foreach link,$(patsubst $(CHS_SW_LD_DIR)/%.ld,%,$(wildcard $(CHS_SW_LD_DIR)/*.ld)),$(eval $(call chs_sw_ld_elf_rule,$(link))))

# %.$(1).elf: $$(CHS_SW_LD_DIR)/$(1).ld %.$(1).o $$(CHS_SW_LIBS)
# $$(CHS_SW_CC) $$(CHS_SW_INCLUDES) -T$$< $$(CHS_SW_LDFLAGS) -o $$@ $$*.$(1).o $$(CHS_SW_LIBS)

# CHS_SW_LINK_MODES ?= $(patsubst $(CHS_SW_LD_DIR)/%.ld,%,$(wildcard $(CHS_SW_LD_DIR)/*.ld))

# $(foreach link,$(CHS_SW_LINK_MODES),$(eval $(call chs_sw_ld_elf_rule,$(link))))

%.dump: %.elf
$(CHS_SW_OBJDUMP) -d -S $< > $@

Expand Down Expand Up @@ -158,6 +167,28 @@ $(CHS_SW_DIR)/boot/linux.%.gpt.bin: $(CHS_SW_DIR)/boot/zsl.rom.bin $(CHS_SW_DIR)
# Tests #
#########

# # Accumulate single-link-mode sources and corresponding .dump targets
# define chs_sw_tests_add_rule
# BLA += $(wildcard $(2)/*.$(1).c)
# CHS_SW_TEST_LONE += $(wildcard $(2)/*.$(1).c) $(wildcard $(2)/*.$(1).S)
# CHS_SW_TEST_DUMP += $(patsubst %.c,%.dump,$(wildcard $(2)/*.$(1).c)) $(patsubst %.S,%.dump,$(wildcard $(2)/*.$(1).S))
# endef

# # Accumulate tests for all link modes
# $(foreach link,$(CHS_SW_LINK_MODES),$(eval $(call chs_sw_tests_add_rule,$(link),$(CHS_SW_DIR)/tests)))

# # Collect mode-agnostic tests, which should be build for all modes, and their .dump targets
# CHS_SW_TEST_C_LALL = $(filter-out $(CHS_SW_TEST_LONE), $(wildcard $(CHS_SW_DIR)/tests/*.c))
# CHS_SW_TEST_S_LALL = $(filter-out $(CHS_SW_TEST_LONE), $(wildcard $(CHS_SW_DIR)/tests/*.S))
# $(foreach link,$(CHS_SW_LINK_MODES),$(eval CHS_SW_TEST_DUMP += $(CHS_SW_TEST_C_LALL:.c=.$(link).dump) $(CHS_SW_TEST_S_LALL:.S=.$(link).dump)))

# # Generate .memh targets for ROM-linked tests
# CHS_SW_TEST_ROM_DUMP = $(filter %.rom.dump,$(CHS_SW_TEST_DUMP))
# CHS_SW_TESTS += $(CHS_SW_TEST_ROM_DUMP:.rom.dump=.rom.memh) $(CHS_SW_TEST_ROM_DUMP:.rom.dump=.gpt.memh)

# # Add all dumps to test build
# CHS_SW_TESTS += $(CHS_SW_TEST_DUMP)

CHS_SW_TEST_SRCS_S = $(wildcard $(CHS_SW_DIR)/tests/*.S)
CHS_SW_TEST_SRCS_C = $(wildcard $(CHS_SW_DIR)/tests/*.c)
CHS_SW_TEST_DRAM_DUMP = $(CHS_SW_TEST_SRCS_S:.S=.dram.dump) $(CHS_SW_TEST_SRCS_C:.c=.dram.dump)
Expand Down

0 comments on commit 89242a4

Please sign in to comment.