diff options
author | Yilun Lin <yllin@google.com> | 2019-05-24 11:18:26 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-06-03 01:11:04 -0700 |
commit | 49436b18d2a77b994fe76d8c2f070000e2cdb58a (patch) | |
tree | 327729dead0cf855fca17c067d499c66773ebe06 /Makefile | |
parent | 7ccb50f4352309813cffd98460bd7dcb48d4657f (diff) | |
download | chrome-ec-49436b18d2a77b994fe76d8c2f070000e2cdb58a.tar.gz |
Makefile: Replace flag -DX with -DX= to be supported by IS_ENABLED().
IS_ENABLED works for an empty-string-defined macro.
However, -D options default to define the macro to 1. This CL forces
those macros, such as BOARD_* CHIP_*, CORE_*, CHIP_VARIANT_* and
CHIP_FAMILIY_*, to be defined as an empty string, so that it can
be supported by IS_ENABLED macro.
TEST=use if(IS_ENABLED(BOARD_KRANE)) and see compilation success.
TEST=compares build directory w/ and w/o this CL, and see the .smap
are the same:
ls build/*/*/ec.*.smap | sed -e 's|build/||' | \
xargs -I{} diff -u -a build/{} build.new/{}
BUG=none
BRANCH=None
Change-Id: I96e2aa1cb5f3369e5e445a674595a9234f26707a
Signed-off-by: Yilun Lin <yllin@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1627840
Commit-Ready: Yilun Lin <yllin@chromium.org>
Tested-by: Yilun Lin <yllin@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 37 |
1 files changed, 21 insertions, 16 deletions
@@ -41,6 +41,11 @@ endif PROJECT?=ec +# An empty string. +# "-DMACRO" leads to MACRO=1. Define an empty string "-DMACRO=" to take +# advantage of IS_ENABLED magic macro, which only allows an empty string. +EMPTY= + # Output directory for build objects ifdef CTS_MODULE # CTS builds need different directories per board per suite. @@ -98,7 +103,7 @@ endif # Baseboard directory ifneq (,$(BASEBOARD)) BASEDIR:=baseboard/$(BASEBOARD) -CFLAGS_BASEBOARD=-DHAS_BASEBOARD -DBASEBOARD_$(UC_BASEBOARD) +CFLAGS_BASEBOARD=-DHAS_BASEBOARD=$(EMPTY) -DBASEBOARD_$(UC_BASEBOARD)=$(EMPTY) include $(BASEDIR)/build.mk else # If BASEBOARD is not defined, then assign BASEDIR to BDIR. This avoids @@ -130,8 +135,8 @@ includes+=cts/$(CTS_MODULE) cts endif ifeq "$(TEST_BUILD)" "y" _tsk_lst_file:=ec.tasklist - _tsk_lst_flags:=$(if $(TEST_FUZZ),-Ifuzz,-Itest) -DTEST_BUILD -imacros \ - $(PROJECT).tasklist + _tsk_lst_flags:=$(if $(TEST_FUZZ),-Ifuzz,-Itest) -DTEST_BUILD=$(EMPTY) \ + -imacros $(PROJECT).tasklist else ifdef CTS_MODULE _tsk_lst_file:=ec.tasklist _tsk_lst_flags:=-I cts/$(CTS_MODULE) -Icts -DCTS_MODULE=$(CTS_MODULE) \ @@ -141,13 +146,13 @@ else _tsk_lst_flags:= endif -_tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD) -I$(BASEDIR) \ - -DBASEBOARD_$(UC_BASEBOARD) -D_MAKEFILE \ - -imacros $(_tsk_lst_file) +_tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD)=$(EMPTY) -I$(BASEDIR) \ + -DBASEBOARD_$(UC_BASEBOARD)=$(EMPTY) \ + -D_MAKEFILE=$(EMPTY) -imacros $(_tsk_lst_file) -_tsk_lst_ro:=$(shell $(CPP) -P -DSECTION_IS_RO \ +_tsk_lst_ro:=$(shell $(CPP) -P -DSECTION_IS_RO=$(EMPTY) \ $(_tsk_lst_flags) include/task_filter.h) -_tsk_lst_rw:=$(shell $(CPP) -P -DSECTION_IS_RW \ +_tsk_lst_rw:=$(shell $(CPP) -P -DSECTION_IS_RW=$(EMPTY) \ $(_tsk_lst_flags) include/task_filter.h) _tsk_cfg_ro:=$(foreach t,$(_tsk_lst_ro) ,HAS_TASK_$(t)) @@ -157,22 +162,22 @@ _tsk_cfg:= $(filter $(_tsk_cfg_ro), $(_tsk_cfg_rw)) _tsk_cfg_ro:= $(filter-out $(_tsk_cfg), $(_tsk_cfg_ro)) _tsk_cfg_rw:= $(filter-out $(_tsk_cfg), $(_tsk_cfg_rw)) -CPPFLAGS_RO+=$(foreach t,$(_tsk_cfg_ro),-D$(t)) \ - $(foreach t,$(_tsk_cfg_rw),-D$(t)_RW) -CPPFLAGS_RW+=$(foreach t,$(_tsk_cfg_rw),-D$(t)) \ - $(foreach t,$(_tsk_cfg_ro),-D$(t)_RO) -CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t)) +CPPFLAGS_RO+=$(foreach t,$(_tsk_cfg_ro),-D$(t)=$(EMPTY)) \ + $(foreach t,$(_tsk_cfg_rw),-D$(t)_RW=$(EMPTY)) +CPPFLAGS_RW+=$(foreach t,$(_tsk_cfg_rw),-D$(t)=$(EMPTY)) \ + $(foreach t,$(_tsk_cfg_ro),-D$(t)_RO=$(EMPTY)) +CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t)=$(EMPTY)) ifneq ($(ENV_VARS),) -CPPFLAGS += -DINCLUDE_ENV_CONFIG +CPPFLAGS += -DINCLUDE_ENV_CONFIG=$(EMPTY) CFLAGS += -I$(realpath $(out)) endif # Get the CONFIG_ and VARIANT_ options that are defined for this target and make # them into variables available to this build script _flag_cfg_ro:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) \ - -I$(BASEDIR) -I$(BDIR) -DSECTION_IS_RO include/config.h | \ + -I$(BASEDIR) -I$(BDIR) -DSECTION_IS_RO=$(EMPTY) include/config.h | \ grep -o "\#define \(CONFIG\|VARIANT\)_[A-Z0-9_]*" | cut -c9- | sort) _flag_cfg_rw:=$(_tsk_cfg_rw) $(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) \ - -I$(BASEDIR) -I$(BDIR) -DSECTION_IS_RW include/config.h | \ + -I$(BASEDIR) -I$(BDIR) -DSECTION_IS_RW=$(EMPTY) include/config.h | \ grep -o "\#define \(CONFIG\|VARIANT\)_[A-Z0-9_]*" | cut -c9- | sort) _flag_cfg:= $(filter $(_flag_cfg_ro), $(_flag_cfg_rw)) |