From a8b86b3a9f39e1215558eb5b78daa9be9c1c33d5 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Tue, 9 Aug 2016 20:19:19 +0200 Subject: build system: change addition order of files to go by region Instead of adding each file in all requested regions, sort by region, then by file. This is in preparation of per-region file options (eg. position, alignment) Change-Id: Ide09a1c8840279380294a059bbd5d2f9f0cba780 Signed-off-by: Patrick Georgi Reviewed-on: https://review.coreboot.org/16130 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Martin Roth --- Makefile.inc | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Makefile.inc b/Makefile.inc index 917426f08a..4959a9fb4d 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -647,18 +647,40 @@ endef # newline # cbfs-add-cmd -# $(call cbfs-add-cmd,file in extract_nth format,non-empty if file removal requested) +# $(call cbfs-add-cmd, +# file in extract_nth format, +# region name, +# non-empty if file removal requested) define cbfs-add-cmd printf " CBFS $(call extract_nth,2,$(1))\n" - $(if $(2),-$(CBFSTOOL) $@.tmp remove -n $(call extract_nth,2,$(file)) 2>/dev/null) - $(eval _tmp-cbfs-add-cmd-regions=$(call regions-for-file,$(call extract_nth,2,$(1)))) \ - $(foreach region,$(subst $(comma),$(spc),$(_tmp-cbfs-add-cmd-regions)), \ - $(call cbfs-add-cmd-for-region,$(1),$(region))) + $(if $(3),-$(CBFSTOOL) $@.tmp remove -n $(call extract_nth,2,$(file)) 2>/dev/null) + $(call cbfs-add-cmd-for-region,$(1),$(2)) endef cbfs-files=$(cbfs-files-fixed) $(cbfs-files-aligned) $(cbfs-files-regular) + +# list of files to add (using their file system names, not CBFS names), +# for dependencies etc. prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file))) -prebuild-files = $(foreach file,$(cbfs-files), $(call cbfs-add-cmd,$(file),$(CONFIG_UPDATE_IMAGE))) + +# $(all-regions) +# returns full list of fmap regions that we add files to +all-regions = $(sort $(subst $(comma),$(spc), \ + $(foreach file,$(cbfs-files), \ + $(call regions-for-file,$(call extract_nth,2,$(file)))))) + +# $(call all-files-in-region,region name) +# returns elements in $(cbfs-files) that end up in that region, in the order +# they appear in $(cbfs-files) +all-files-in-region = $(foreach file,$(cbfs-files), \ + $(if $(filter $(1), \ + $(subst $(comma),$(spc),$(call regions-for-file,$(call extract_nth,2,$(file))))), \ + $(file))) + +# command list to add files to CBFS +prebuild-files = $(foreach region,$(all-regions), \ + $(foreach file,$(call all-files-in-region,$(region)), \ + $(call cbfs-add-cmd,$(file),$(region),$(CONFIG_UPDATE_IMAGE)))) ifeq ($(CONFIG_FMDFILE),) # For a description of the flash layout described by these variables, check -- cgit v1.2.3