From 513693ca3a5ee101636baaa0b8e2ea25fba19538 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Wed, 10 Aug 2016 13:25:02 +0200 Subject: [PATCH] build system: order per-region files to optimize placement success Make sure that files with a fixed position are placed first (whose order doesn't matter: either they collide or they don't), then all aligned files (where we just hope that the right thing happens) and finally the files with no further requirements (again, hope). It's still a pretty good heuristic given a typical coreboot image. The global sorting that happens earlier in the build flow will be removed in the future to make room for per-region requirements. Change-Id: I269c00b2ece262c95d310b76a6651c9574badb58 Signed-off-by: Patrick Georgi Reviewed-on: https://review.coreboot.org/16137 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Aaron Durbin --- Makefile.inc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index 4959a9fb4d..3852132201 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -677,9 +677,25 @@ all-files-in-region = $(foreach file,$(cbfs-files), \ $(subst $(comma),$(spc),$(call regions-for-file,$(call extract_nth,2,$(file))))), \ $(file))) +# $(call sort-files,subset of $(cbfs-files)) +# reorders the files in the given set to list files at fixed positions first, +# followed by aligned files and finally those with no constraints. +sort-files = \ + $(eval _tmp_fixed:=) \ + $(eval _tmp_aligned:=) \ + $(eval _tmp_regular:=) \ + $(foreach file,$(1), \ + $(if $(call extract_nth,5,$(file)),\ + $(eval _tmp_fixed += $(file)), \ + $(if $(call extract_nth,6,$(file)), \ + $(eval _tmp_aligned += $(file)), \ + $(eval _tmp_regular += $(file))))) \ + $(_tmp_fixed) $(_tmp_aligned) $(_tmp_regular) + # command list to add files to CBFS prebuild-files = $(foreach region,$(all-regions), \ - $(foreach file,$(call all-files-in-region,$(region)), \ + $(foreach file, \ + $(call sort-files,$(call all-files-in-region,$(region))), \ $(call cbfs-add-cmd,$(file),$(region),$(CONFIG_UPDATE_IMAGE)))) ifeq ($(CONFIG_FMDFILE),)