From: Angus Gratton Date: Wed, 16 Nov 2016 00:45:39 +0000 (+1100) Subject: build system: When embedding binary files, fix re-generating on partial builds X-Git-Tag: v1.0~48^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=872a481cf1c526263c0bf90afc0ebf7c25aa6a47;p=esp-idf build system: When embedding binary files, fix re-generating on partial builds When embedding a generated file (ie secure boot public key data), the file was being re-generated each time. --- diff --git a/make/component_wrapper.mk b/make/component_wrapper.mk index 005c996712..2c073af761 100644 --- a/make/component_wrapper.mk +++ b/make/component_wrapper.mk @@ -189,18 +189,29 @@ OBJCOPY_EMBED_ARGS := --input binary --output elf32-xtensa-le --binary-architect # txt files are null-terminated before being embedded (otherwise # identical behaviour.) # -# Files are temporarily copied to the build directory before objcopy, -# because objcopy generates the symbol name from the full command line -# path to the input file. define GenerateEmbedTarget -$(1).$(2).o: $(call resolvepath,$(1),$(COMPONENT_PATH)) | $$(dir $(1)) + +# copy the input file into the build dir (using a subdirectory +# in case the file already exists elsewhere in the build dir) +embed_bin/$$(notdir $(1)): $(call resolvepath,$(1),$(COMPONENT_PATH)) | embed_bin + cp $$< $$@ + +embed_txt/$$(notdir $(1)): $(call resolvepath,$(1),$(COMPONENT_PATH)) | embed_txt + cp $$< $$@ + echo -ne '\0' >> $$@ # null-terminate text files + +# messing about with the embed_X subdirectory then using 'cd' for objcopy is because the +# full path passed to OBJCOPY makes it into the name of the symbols in the .o file +$(1).$(2).o: embed_$(2)/$$(notdir $(1)) | $$(dir $(1)) $(summary) EMBED $$@ - $(if $(filter-out $$(notdir $$(abspath $$<)),$$(abspath $$(notdir $$<))), cp $$< $$(notdir $$<) ) # copy input file to build dir, unless already in build dir - $$(if $$(subst bin,,$(2)),echo -ne '\0' >> $$(notdir $$<) ) # trailing NUL byte on text output - $(OBJCOPY) $(OBJCOPY_EMBED_ARGS) $$(notdir $$<) $$@ - rm $$(notdir $$<) + cd embed_$(2); $(OBJCOPY) $(OBJCOPY_EMBED_ARGS) $$(notdir $$<) ../$$@ + +CLEAN_FILES += embed_$(2)/$$(notdir $(1)) endef +embed_txt embed_bin: + mkdir -p $@ + # generate targets to embed binary & text files $(foreach binfile,$(COMPONENT_EMBED_FILES), $(eval $(call GenerateEmbedTarget,$(binfile),bin)))