build system: add easier targetting of cbfstool options per region

The first attempt of providing a options-for-region function to call
to determining a file's cbfstool options would work, but it means there
can only be one instance which has to handle all of the files that may
need an override. That logic can be problematic in impelementation.

Instead, provide a mechanism to target cbfstool options for a given
CBFS region where the implementation is tightly coupled in the build
system to where the file as requested to be added to cbfs. This allows
there to be a base set of cbfstool options while more easily extending
arguments on specific regions.

Example which adds '-b 0x10000' only for the COREBOOT CBFS region:
cbfs-files-y += file.bin
file.bin-COREBOOT-cbfstool-opts := -b 0x10000

Change-Id: Idfafb0205be42768adb04bb0a30fe46a9ca1bd57
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/14640
Tested-by: build bot (Jenkins)
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
This commit is contained in:
Aaron Durbin 2016-05-06 16:01:25 -05:00 committed by Patrick Georgi
parent 6c481755c4
commit bcbb205454
1 changed files with 11 additions and 9 deletions

View File

@ -606,12 +606,13 @@ extract_nth=$(subst *,$(spc),$(patsubst -%-,%,$(word $(1), $(subst |,- -,-$(2)-)
# multiple CBFSes in fmap regions, override it.
regions-for-file ?= COREBOOT
# options-for-region
# $(call options-for-region,$(filename),$(region),$(options))
# The last sequence of the cbfs-add-cmd-for-region allows for per-file CBFS
# options associated with a given region. The following example adds
# '-b 0x10000' to the cbfstool arguments when being added to the COREBOOT
# region. This allows options to specifically target certain CBFS regions.
#
# Returns potentially modified options, depending on file and region.
# Default is to return it unmodified
options-for-region ?= $(3)
# cbfs-files-y += file.bin
# file.bin-COREBOOT-cbfstool-opts := -b 0x10000
ifeq ($(CONFIG_CBFS_AUTOGEN_ATTRIBUTES),y)
cbfs-autogen-attributes=-g
@ -631,10 +632,11 @@ define cbfs-add-cmd-for-region
$(if $(call extract_nth,4,$(1)),-c $(call extract_nth,4,$(1))) \
$(cbfs-autogen-attributes) \
-r $(2) \
$(call options-for-region,$(call extract_nth,2,$(1)),$(2), \
$(if $(call extract_nth,6,$(1)),-a $(call extract_nth,6,$(file)), \
$(if $(call extract_nth,5,$(file)),-b $(call extract_nth,5,$(file)))) \
$(call extract_nth,7,$(1)))
$(call extract_nth,7,$(1)) \
$($(call extract_nth,2,$(1))-$(2)-cbfstool-opts)
endef
# Empty line before endef is necessary so cbfs-add-cmd-for-region ends in a