summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-07-16 14:37:49 -0700
committerChromeBot <chrome-bot@google.com>2013-07-17 10:49:47 -0700
commitd48828757de2274938cf8ec862689c935adaae33 (patch)
treee0966e8ee3682a6ad606d592ecc58f31375d5c95
parent60a1f6cada2d068ce2644cec020cef1101d10d4e (diff)
downloadchrome-ec-d48828757de2274938cf8ec862689c935adaae33.tar.gz
Fix extracting CONFIG tokens from config.h
We need to use cpp -dM instead of -dN, because -dN doesn't process #undef statements. That is, if you have " #define CONFIG_FOO" " #undef CONFIG_FOO" then -dN will happily print both lines, which results in CONFIG_FOO being defined when processing the makefile. -dM processes the defines and undefs so that the resulting list of macros only includes those that are defined. We didn't notice this before, because we temporarily commented out config statements instead of #undef'ing them - or the configs which were undef'd only resulted in conditional non-compilation of pieces of code inside a file instead of the whole file not being compiled. This change also tidily alphabetizes the resulting configs. It also better filters CONFIGs to ensure that " #define __CROS_EC_CONFIG_CHIP_H" does not show up as a CONFIG_CHIP_H token, as it did previously. BUG=chrome-os-partner:20985 BRANCH=none (though may be needed if any future cherry-picked change requires undefining a CONFIG) TEST=Add #undef CONFIG_ADC to the end of config.h and see that the ADC module is not compiled. Also helps to add $(info $(_flag_cfg)) to the Makefile to see the list of tokens, and verify that CONFIG_ADC is not among them. Change-Id: I18db60099e87857473ba54c3c9fff1116d4f1a93 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/62230 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--Makefile6
1 files changed, 4 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 50e057d699..582d0a5c16 100644
--- a/Makefile
+++ b/Makefile
@@ -35,8 +35,10 @@ else
endif
_tsk_cfg:=$(foreach t,$(_tsk_lst) ,HAS_TASK_$(t))
CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t))
-_flag_cfg:=$(shell $(CPP) $(CPPFLAGS) -P -dN -Ichip/$(CHIP) -Iboard/$(BOARD) \
- include/config.h | grep -o "CONFIG_.*")
+_flag_cfg:=$(shell $(CPP) $(CPPFLAGS) -P -dM -Ichip/$(CHIP) -Iboard/$(BOARD) \
+ include/config.h | grep -o "\#define CONFIG_[A-Za-z0-9_]*" | \
+ cut -c9- | sort)
+
$(foreach c,$(_tsk_cfg) $(_flag_cfg),$(eval $(c)=y))
$(eval BOARD_$(BOARD)=y)