summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@chromium.org>2016-08-09 20:19:19 +0200
committerMartin Roth <martinroth@google.com>2016-08-10 21:13:27 +0200
commita8b86b3a9f39e1215558eb5b78daa9be9c1c33d5 (patch)
treea641fb29e0691ce76018ff7329382e31bd88d7a8
parent5de5458c2c65c47b731552bd1c97473f186ea877 (diff)
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 <pgeorgi@chromium.org> Reviewed-on: https://review.coreboot.org/16130 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Martin Roth <martinroth@google.com>
-rw-r--r--Makefile.inc34
1 files 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