From c838c4657c7ca3b830b85789ec701beedffbd0c3 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Wed, 18 Sep 2019 14:12:03 +0200 Subject: [PATCH] [build] Use rule_for/rule_label when needed --- build/targets.device.mak | 24 +++++++++++++----------- ion/src/device/shared/usb/Makefile | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/build/targets.device.mak b/build/targets.device.mak index ac5b239ab..60e5f9f33 100644 --- a/build/targets.device.mak +++ b/build/targets.device.mak @@ -3,23 +3,25 @@ include build/targets.device.$(MODEL).mak executables += flasher.light flasher.verbose bench.ram bench.flash extensions += .dfu .hex .bin -$(BUILD_DIR)/%.dfu: $(BUILD_DIR)/%.$(EXE) - @echo "DFUSE $@" - $(Q) $(PYTHON) build/device/elf2dfu.py $< $@ +$(eval $(call rule_for, \ + DFUSE, %.dfu, %.$$(EXE), \ + $$(PYTHON) build/device/elf2dfu.py $$< $$@ \ +)) -$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.$(EXE) - @echo "OBJCOPY $@" - $(Q) $(OBJCOPY) -O ihex $< $@ +$(eval $(call rule_for, \ + OBJCOPY, %.hex, %.$$(EXE), \ + $$(OBJCOPY) -O ihex $$< $$@ \ +)) -$(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 # the dfu code, and it did not upload properly a binary of length non-multiple # of 32 bits. #TODO: We over-pad here, pad with the the needed amount of bytes only. - @echo "Padding $@" - $(Q) printf "\xFF\xFF\xFF\xFF" >> $@ +$(eval $(call rule_for, \ + OBJCOPY, %.bin, %.$$(EXE), \ + $$(OBJCOPY) -O ihex $$< $$@ && printf "\xFF\xFF\xFF\xFF" >> $$@, \ + with_local_version \ +)) .PHONY: %_size %_size: $(BUILD_DIR)/%.$(EXE) diff --git a/ion/src/device/shared/usb/Makefile b/ion/src/device/shared/usb/Makefile index 4149116d4..cf2f0cbf7 100644 --- a/ion/src/device/shared/usb/Makefile +++ b/ion/src/device/shared/usb/Makefile @@ -79,8 +79,8 @@ $(BUILD_DIR)/ion/src/device/shared/usb/dfu.elf: $(call object_for,$(usb_src) $(d # For our purpose, dfu.o can go in rodata section and we rename the start and # end of binary symbols: _dfu_bootloader_flash_[start/end] $(BUILD_DIR)/ion/src/device/shared/usb/dfu.o: $(BUILD_DIR)/ion/src/device/shared/usb/dfu.bin - @echo "OBJCOPY $@" + $(call rule_label,OBJCOPY) $(Q) cd $(dir $<) ; $(OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata.dfu_bootloader --redefine-sym _binary_dfu_bin_start=_dfu_bootloader_flash_start --redefine-sym _binary_dfu_bin_end=_dfu_bootloader_flash_end $(notdir $<) $(notdir $@) ion_device_dfu_relocated_src += ion/src/device/shared/usb/dfu.cpp -ion_device_dfu_relocated_src += ion/src/device/shared/usb/dfu_relocated.cpp \ No newline at end of file +ion_device_dfu_relocated_src += ion/src/device/shared/usb/dfu_relocated.cpp