[scripts] Enable to build targets without specifying the building

directory
This commit is contained in:
Émilie Feral
2019-06-28 13:55:26 +02:00
parent 2ddb586bdc
commit 725ea64a45
4 changed files with 22 additions and 14 deletions

View File

@@ -81,6 +81,8 @@ objs = $(call object_for,$(src))
# but allows correct yet optimal incremental builds.
-include $(objs:.o=.d)
executables = epsilon test
#define platform generic targets
$(BUILD_DIR)/epsilon.$(EXE): $(objs) $(call object_for,$(ion_device_dfu_relocated_src) $(epsilon_src))
@@ -91,17 +93,7 @@ $(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(objs) $(call o
# We include them before the standard ones to give them precedence.
-include scripts/targets.$(PLATFORM).mak
# Define rules for executables
# Those can be built directly with make executable.exe as a shortcut. They also
# depends on $(objs)
executables = epsilon test
define rules_for_executable
.PHONY: $(1).$$(EXE)
$(1).$$(EXE): $$(BUILD_DIR)/$(1).$$(EXE)
endef
$(foreach executable,$(executables),$(eval $(call rules_for_executable,$(executable))))
$(foreach executable,$(executables),$(eval $(call rules_for_targets,$(executable),$(EXE))))
# Define standard compilation rules

View File

@@ -35,3 +35,12 @@ ifeq ("$(origin V)", "command line")
endif
BUILD_DIR = build/$(PLATFORM)
# Define rules for targets
# Those can be built directly with make executable.extension as a shortcut.
define rules_for_targets
.PHONY: $(1).$(2)
$(1).$(2): $$(BUILD_DIR)/$(1).$(2)
endef

View File

@@ -1,12 +1,17 @@
%.dfu: %.$(EXE)
executables += flasher.light flasher.verbose bench.RAM bench.flash
extensions = dfu hex bin
$(foreach extension,$(extensions),$(foreach executable,$(executables),$(eval $(call rules_for_targets,$(executable),$(extension)))))
$(BUILD_DIR)/%.dfu: $(BUILD_DIR)/%.$(EXE)
@echo "DFUSE $@"
$(Q) $(PYTHON) scripts/device/elf2dfu.py $< $@
%.hex: %.$(EXE)
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.$(EXE)
@echo "OBJCOPY $@"
$(Q) $(OBJCOPY) -O ihex $< $@
%.bin: %.$(EXE)
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.$(EXE)
@echo "OBJCOPY $@"
$(Q) $(OBJCOPY) -O binary $< $@
# We pad the device binary files because there was a bug in an older version of

View File

@@ -1,2 +1,4 @@
executables += test_external_flash
$(BUILD_DIR)/test_external_flash.$(EXE): LDSCRIPT = ion/test/external_flash_tests.ld
$(BUILD_DIR)/test_external_flash.$(EXE): $(BUILD_DIR)/quiz/src/external_flash_tests_symbols.o $(runner_objs) $(call object_for,$(tests_external_flash)) $(call object_for,$(ion_device_dfu_relocated_src))