diff options
author | Nick Sanders <nsanders@chromium.org> | 2016-12-21 17:49:50 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-01-26 14:23:01 -0800 |
commit | ac59ddfcb90eb1102203889367324947fca863cc (patch) | |
tree | ad0fd148ab175028bb3ef97eb2fc71de31b82197 /Makefile | |
parent | 44676699b08f7f6ccaba3d8b89a41c79f3c29cb2 (diff) | |
download | chrome-ec-ac59ddfcb90eb1102203889367324947fca863cc.tar.gz |
makefile: allow different RO and RW CONFIG
This adds a separate CONFIG check for RO and RW.
Each section is built with the objects generated
based on it's own calculated CONFIGs, so that the
object list may be different for RO and RW.
The intent is to allow for differnt sized RO and
RW partitions to allow for a small RO and lager code
space for RW, for servo_v4 and hammer.
BRANCH=none
BUG=chrome-os-partner:61170
TEST=builds successfully
Change-Id: I5549cc7ac218e0c7681108074ecfd3b80d4af545
Reviewed-on: https://chromium-review.googlesource.com/433079
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 62 |
1 files changed, 45 insertions, 17 deletions
@@ -92,10 +92,17 @@ endif _tsk_cfg:=$(foreach t,$(_tsk_lst) ,HAS_TASK_$(t)) CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t)) -_flag_cfg:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) -I$(BDIR) \ - include/config.h | grep -o "\#define CONFIG_[A-Z0-9_]*" | \ +_flag_cfg_ro:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) -I$(BDIR) \ + -DSECTION_IS_RO include/config.h | grep -o "\#define CONFIG_[A-Z0-9_]*" | \ cut -c9- | sort) +_flag_cfg_rw:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) -I$(BDIR) \ + -DSECTION_IS_RW include/config.h | grep -o "\#define CONFIG_[A-Z0-9_]*" | \ + cut -c9- | sort) +_flag_cfg:= $(filter $(_flag_cfg_ro), $(_flag_cfg_rw)) +_flag_cfg_ro:= $(filter-out $(_flag_cfg), $(_flag_cfg_ro)) +_flag_cfg_rw:= $(filter-out $(_flag_cfg), $(_flag_cfg_rw)) +$(foreach c,$(_flag_cfg_rw),$(eval $(c)=rw)) $(foreach c,$(_tsk_cfg) $(_flag_cfg),$(eval $(c)=y)) ifneq "$(CONFIG_COMMON_RUNTIME)" "y" @@ -125,8 +132,11 @@ $(eval CHIP_FAMILY_$(UC_CHIP_FAMILY)=y) # Private subdirectories may call this from their build.mk # First arg is the path to be prepended to configured *.o files. -# Second arg is the config variable (ie, "FOO" to select with $(FOO-y)). -objs_from_dir=$(foreach obj, $($(2)-y), $(1)/$(obj)) +# Second arg is the config variable (ie, "FOO" to select with $(FOO-$3)). +# Third arg is the config variable value ("y" for configuration options +# that are set for both RO and RW, "rw" for RW-only configuration options) +objs_from_dir_p=$(foreach obj, $($(2)-$(3)), $(1)/$(obj)) +objs_from_dir=$(call objs_from_dir_p,$(1),$(2),y) # Get build configuration from sub-directories # Note that this re-includes the board and chip makefiles @@ -151,33 +161,51 @@ include util/signer/build.mk includes+=$(includes-y) -# Get all sources to build -all-obj-y+=$(call objs_from_dir,core/$(CORE),core) -all-obj-y+=$(call objs_from_dir,chip/$(CHIP),chip) -all-obj-y+=$(call objs_from_dir,$(BDIR),board) -all-obj-y+=$(call objs_from_dir,private,private) +# Wrapper for fetching all the sources relevant to this build +# target. +# First arg is "y" indicating sources for all segments, +# or "rw" indicating sources for rw segment. +define get_sources = +# Get sources to build for this target +all-obj-$(1)+=$(call objs_from_dir_p,core/$(CORE),core,$(1)) +all-obj-$(1)+=$(call objs_from_dir_p,chip/$(CHIP),chip,$(1)) +all-obj-$(1)+=$(call objs_from_dir_p,$(BDIR),board,$(1)) +all-obj-$(1)+=$(call objs_from_dir_p,private,private,$(1)) ifneq ($(PDIR),) -all-obj-y+=$(call objs_from_dir,$(PDIR),$(PDIR)) +all-obj-$(1)+=$(call objs_from_dir_p,$(PDIR),$(PDIR),$(1)) endif -all-obj-y+=$(call objs_from_dir,common,common) -all-obj-y+=$(call objs_from_dir,driver,driver) -all-obj-y+=$(call objs_from_dir,power,power) +all-obj-$(1)+=$(call objs_from_dir_p,common,common,$(1)) +all-obj-$(1)+=$(call objs_from_dir_p,driver,driver,$(1)) +all-obj-$(1)+=$(call objs_from_dir_p,power,power,$(1)) ifdef CTS_MODULE -all-obj-y+=$(call objs_from_dir,cts,cts) +all-obj-$(1)+=$(call objs_from_dir_p,cts,cts,$(1)) endif -all-obj-y+=$(call objs_from_dir,test,$(PROJECT)) +all-obj-$(1)+=$(call objs_from_dir_p,test,$(PROJECT),$(1)) +endef + +# Get all sources to build +$(eval $(call get_sources,y)) +$(eval $(call get_sources,ro)) + dirs=core/$(CORE) chip/$(CHIP) $(BDIR) common power test cts/common cts/$(CTS_MODULE) dirs+= private $(PDIR) dirs+=$(shell find driver -type d) common_dirs=util ifeq ($(custom-ro_objs-y),) -ro-objs := $(sort $(foreach obj, $(all-obj-y), $(out)/RO/$(obj))) +ro-common-objs := $(sort $(foreach obj, $(all-obj-y), $(out)/RO/$(obj))) +ro-only-objs := $(sort $(foreach obj, $(all-obj-ro), $(out)/RO/$(obj))) +ro-objs := $(sort $(ro-common-objs) $(ro-only-objs)) else ro-objs := $(sort $(foreach obj, $(custom-ro_objs-y), $(out)/RO/$(obj))) endif -rw-objs := $(sort $(foreach obj, $(all-obj-y), $(out)/RW/$(obj))) +# Add RW-only sources to build +$(eval $(call get_sources,rw)) + +rw-common-objs := $(sort $(foreach obj, $(all-obj-y), $(out)/RW/$(obj))) +rw-only-objs := $(sort $(foreach obj, $(all-obj-rw), $(out)/RW/$(obj))) +rw-objs := $(sort $(rw-common-objs) $(rw-only-objs)) # Don't include the shared objects in the RO/RW image if we're enabling # the shared objects library. |