summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-04-17 11:32:12 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-04-25 05:52:34 -0700
commit896409ef79b1d1c1c25bb8e410474b43a15238a5 (patch)
tree1aad179ea491de4252a5eb4584f91a964d5163d0
parent579a6b00e5b4f31bf3dbefd82aa19fb52b6905bb (diff)
downloadchrome-ec-896409ef79b1d1c1c25bb8e410474b43a15238a5.tar.gz
Makefile: Allow different task list for RO and RW
This adds new macros for tasks (_RO and _RW), which allows to enable a task only for RO or RW section. We also create a new task_filter.h include file, that helps pre-filter those tasks, and can be used either from Makefile, or included from task_id.h. BRANCH=none BUG=b:35582031 TEST=make buildall -j; make savesizes Apply this CL make buildall -j; make newsizes => No size change Change-Id: I472bc6d4ab250a0a0e1fa6aeb4b748ba6968bedf Reviewed-on: https://chromium-review.googlesource.com/479491 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Nick Sanders <nsanders@google.com>
-rw-r--r--Makefile55
-rw-r--r--Makefile.toolchain6
-rw-r--r--include/task_filter.h49
-rw-r--r--include/task_id.h15
4 files changed, 84 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index 385998ed61..2a93daba29 100644
--- a/Makefile
+++ b/Makefile
@@ -68,41 +68,48 @@ includes+=cts/$(CTS_MODULE) cts
endif
ifeq "$(TEST_BUILD)" "y"
_tsk_lst_file:=ec.tasklist
- _tsk_lst:=$(shell echo "CONFIG_TASK_LIST CONFIG_TEST_TASK_LIST" | \
- $(CPP) -P -I$(BDIR) -DBOARD_$(UC_BOARD) -Itest \
- -D"TASK_NOTEST(n, r, d, s)=" -D"TASK_ALWAYS(n, r, d, s)=n" \
- -D"TASK_TEST(n, r, d, s)=n" -imacros $(_tsk_lst_file) \
- -imacros $(PROJECT).tasklist)
+ _tsk_lst_flags:=-Itest -DTEST_BUILD -imacros $(PROJECT).tasklist
else ifdef CTS_MODULE
_tsk_lst_file:=ec.tasklist
- _tsk_lst:=$(shell echo "CONFIG_TASK_LIST CONFIG_CTS_TASK_LIST" | \
- $(CPP) -P -I cts/$(CTS_MODULE) -Icts -I$(BDIR) \
- -DBOARD_$(UC_BOARD) \
- -D"TASK_NOTEST(n, r, d, s)=n" \
- -D"TASK_ALWAYS(n, r, d, s)=n" \
- -imacros $(_tsk_lst_file) \
- -imacros cts.tasklist)
+ _tsk_lst_flags:=-I cts/$(CTS_MODULE) -Icts -DCTS_MODULE=$(CTS_MODULE) \
+ -imacros cts.tasklist
else
_tsk_lst_file:=$(PROJECT).tasklist
- _tsk_lst:=$(shell echo "CONFIG_TASK_LIST" | $(CPP) -P \
- -I$(BDIR) -DBOARD_$(UC_BOARD) \
- -D"TASK_NOTEST(n, r, d, s)=n" \
- -D"TASK_ALWAYS(n, r, d, s)=n" -imacros $(_tsk_lst_file))
+ _tsk_lst_flags:=
endif
-_tsk_cfg:=$(foreach t,$(_tsk_lst) ,HAS_TASK_$(t))
+_tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD) -D_MAKEFILE \
+ -imacros $(_tsk_lst_file)
+
+_tsk_lst_ro:=$(shell $(CPP) -P -DSECTION_IS_RO \
+ $(_tsk_lst_flags) include/task_filter.h)
+_tsk_lst_rw:=$(shell $(CPP) -P -DSECTION_IS_RW \
+ $(_tsk_lst_flags) include/task_filter.h)
+
+_tsk_cfg_ro:=$(foreach t,$(_tsk_lst_ro) ,HAS_TASK_$(t))
+_tsk_cfg_rw:=$(foreach t,$(_tsk_lst_rw) ,HAS_TASK_$(t))
+
+_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))
+CPPFLAGS_RW+=$(foreach t,$(_tsk_cfg_rw),-D$(t))
CPPFLAGS+=$(foreach t,$(_tsk_cfg),-D$(t))
-_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_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:=$(_tsk_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_rw) $(_flag_cfg_rw),$(eval $(c)=rw))
+$(foreach c,$(_tsk_cfg_ro) $(_flag_cfg_ro),$(eval $(c)=ro))
$(foreach c,$(_tsk_cfg) $(_flag_cfg),$(eval $(c)=y))
ifneq "$(CONFIG_COMMON_RUNTIME)" "y"
diff --git a/Makefile.toolchain b/Makefile.toolchain
index 202956d4ea..05d5d1255c 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -57,13 +57,13 @@ CFLAGS_DEFINE=-DOUTDIR=$(out)/$(BLD) -DCHIP=$(CHIP) -DBOARD_TASKFILE=$(_tsk_lst_
-DFINAL_OUTDIR=$(out)
CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) \
$(EXTRA_CFLAGS) $(CFLAGS_COVERAGE) $(LATE_CFLAGS_DEFINE) \
- -DSECTION_IS_$(BLD) -DSECTION=$(BLD)
+ -DSECTION_IS_$(BLD) -DSECTION=$(BLD) $(CPPFLAGS_$(BLD))
BUILD_CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) \
$(EXTRA_CFLAGS) $(CFLAGS_COVERAGE) $(LATE_CFLAGS_DEFINE) \
- -DSECTION_IS_$(BLD) -DSECTION=$(BLD)
+ -DSECTION_IS_$(BLD) -DSECTION=$(BLD) $(CPPFLAGS_$(BLD))
HOST_CPPFLAGS=$(CFLAGS_DEFINE) $(CFLAGS_INCLUDE) $(CFLAGS_TEST) \
$(EXTRA_CFLAGS) $(CFLAGS_COVERAGE) $(LATE_CFLAGS_DEFINE) \
- -DSECTION_IS_$(BLD) -DSECTION=$(BLD)
+ -DSECTION_IS_$(BLD) -DSECTION=$(BLD) $(CPPFLAGS_$(BLD))
ifneq ($(BOARD),host)
CPPFLAGS+=-ffreestanding -fno-builtin -nostdinc -nostdlib
CPPFLAGS+=-Ibuiltin/
diff --git a/include/task_filter.h b/include/task_filter.h
new file mode 100644
index 0000000000..cac1baf76c
--- /dev/null
+++ b/include/task_filter.h
@@ -0,0 +1,49 @@
+/* Copyright 2017 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Filter tasklist in *.tasklist, depending on section (RO/RW), or
+ * TEST/CTS build.
+ */
+
+#ifndef __CROS_EC_TASK_FILTER_H
+#define __CROS_EC_TASK_FILTER_H
+
+#ifdef SECTION_IS_RO
+#define TASK_NOTEST_RO TASK_NOTEST
+#define TASK_TEST_RO TASK_TEST
+#define TASK_ALWAYS_RO TASK_ALWAYS
+#define TASK_NOTEST_RW(n, r, d, s)
+#define TASK_TEST_RW(n, r, d, s)
+#define TASK_ALWAYS_RW(n, r, d, s)
+#else /* SECTION_IS_RW */
+#define TASK_NOTEST_RW TASK_NOTEST
+#define TASK_TEST_RW TASK_TEST
+#define TASK_ALWAYS_RW TASK_ALWAYS
+#define TASK_NOTEST_RO(n, r, d, s)
+#define TASK_TEST_RO(n, r, d, s)
+#define TASK_ALWAYS_RO(n, r, d, s)
+#endif
+
+/* excludes non-base tasks for test build */
+#ifdef TEST_BUILD
+#define TASK_NOTEST(n, r, d, s)
+#define TASK_TEST TASK
+#else
+#define TASK_NOTEST TASK
+#define CONFIG_TEST_TASK_LIST
+#endif
+
+#ifndef CTS_MODULE
+#define CONFIG_CTS_TASK_LIST
+#endif
+
+#define TASK_ALWAYS TASK
+
+/* If included directly from Makefile, dump task list. */
+#ifdef _MAKEFILE
+#define TASK(n, r, d, s) n
+CONFIG_TASK_LIST CONFIG_TEST_TASK_LIST CONFIG_CTS_TASK_LIST
+#endif
+
+#endif /* __CROS_EC_TASK_FILTER_H */
diff --git a/include/task_id.h b/include/task_id.h
index bcd0b61c85..b4ecf9bf82 100644
--- a/include/task_id.h
+++ b/include/task_id.h
@@ -8,20 +8,7 @@
#ifndef __CROS_EC_TASK_ID_H
#define __CROS_EC_TASK_ID_H
-/* excludes non-base tasks for test build */
-#ifdef TEST_BUILD
-#define TASK_NOTEST(n, r, d, s)
-#define TASK_TEST TASK
-#else
-#define TASK_NOTEST TASK
-#define CONFIG_TEST_TASK_LIST
-#endif
-
-#ifndef CTS_MODULE
-#define CONFIG_CTS_TASK_LIST
-#endif
-
-#define TASK_ALWAYS TASK
+#include "task_filter.h"
/* define the name of the header containing the list of tasks */
#define STRINGIFY0(name) #name