mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 15:44:34 +02:00
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.
This commit is contained in:
@@ -189,18 +189,29 @@ OBJCOPY_EMBED_ARGS := --input binary --output elf32-xtensa-le --binary-architect
|
|||||||
# txt files are null-terminated before being embedded (otherwise
|
# txt files are null-terminated before being embedded (otherwise
|
||||||
# identical behaviour.)
|
# 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
|
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 $$@
|
$(summary) EMBED $$@
|
||||||
$(if $(filter-out $$(notdir $$(abspath $$<)),$$(abspath $$(notdir $$<))), cp $$< $$(notdir $$<) ) # copy input file to build dir, unless already in build dir
|
cd embed_$(2); $(OBJCOPY) $(OBJCOPY_EMBED_ARGS) $$(notdir $$<) ../$$@
|
||||||
$$(if $$(subst bin,,$(2)),echo -ne '\0' >> $$(notdir $$<) ) # trailing NUL byte on text output
|
|
||||||
$(OBJCOPY) $(OBJCOPY_EMBED_ARGS) $$(notdir $$<) $$@
|
CLEAN_FILES += embed_$(2)/$$(notdir $(1))
|
||||||
rm $$(notdir $$<)
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
embed_txt embed_bin:
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
# generate targets to embed binary & text files
|
# generate targets to embed binary & text files
|
||||||
$(foreach binfile,$(COMPONENT_EMBED_FILES), $(eval $(call GenerateEmbedTarget,$(binfile),bin)))
|
$(foreach binfile,$(COMPONENT_EMBED_FILES), $(eval $(call GenerateEmbedTarget,$(binfile),bin)))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user