blob: 640fe10f9c5e0b4715f8e7ada930cdc418a2c9d7 [file] [log] [blame]
Joe Onoratof20c93a2021-01-19 22:34:22 -08001# Read and dump the product configuration.
2
3# Called from the product-config tool, not from the main build system.
4
5#
6# Ensure we are being called correctly
7#
8ifndef KATI
9 $(warning Kati must be used to call dumpconfig.mk, not make.)
10 $(error stopping)
11endif
12
13ifdef DEFAULT_GOAL
14 $(warning Calling dumpconfig.mk from inside the make build system is not)
15 $(warning supported. It is only meant to be called via kati by product-confing.)
16 $(error stopping)
17endif
18
19ifndef TARGET_PRODUCT
20 $(warning dumpconfig.mk requires TARGET_PRODUCT to be set)
21 $(error stopping)
22endif
23
24ifndef TARGET_BUILD_VARIANT
25 $(warning dumpconfig.mk requires TARGET_BUILD_VARIANT to be set)
26 $(error stopping)
27endif
28
29ifneq (build/make/core/config.mk,$(wildcard build/make/core/config.mk))
30 $(warning dumpconfig must be called from the root of the source tree)
31 $(error stopping)
32endif
33
34ifeq (,$(DUMPCONFIG_FILE))
35 $(warning dumpconfig requires DUMPCONFIG_FILE to be set)
36 $(error stopping)
37endif
38
Joe Onorato38a57bf2021-02-08 13:38:01 -080039# Skip the second inclusion of all of the product config files, because
40# we will do these checks in the product_config tool.
41SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK := true
42
Joe Onoratof20c93a2021-01-19 22:34:22 -080043# Before we do anything else output the format version.
44$(file > $(DUMPCONFIG_FILE),dumpconfig_version,1)
45$(file >> $(DUMPCONFIG_FILE),dumpconfig_file,$(DUMPCONFIG_FILE))
46
47# Default goal for dumpconfig
48dumpconfig:
49 $(file >> $(DUMPCONFIG_FILE),***DONE***)
50 @echo ***DONE***
51
52# TODO(Remove): These need to be set externally
53OUT_DIR := out
54TMPDIR = /tmp/build-temp
55BUILD_DATETIME_FILE := $(OUT_DIR)/build_date.txt
56
57# Escape quotation marks for CSV, and wraps in quotation marks.
58define escape-for-csv
59"$(subst ","",$1)"
60endef
61
62# Args:
63# $(1): include stack
64define dump-import-start
65$(eval $(file >> $(DUMPCONFIG_FILE),import,$(strip $(1))))
66endef
67
68# Args:
69# $(1): include stack
70define dump-import-done
71$(eval $(file >> $(DUMPCONFIG_FILE),imported,$(strip $(1))))
72endef
73
74# Args:
75# $(1): Current file
76# $(2): Inherited file
77define dump-inherit
78$(eval $(file >> $(DUMPCONFIG_FILE),inherit,$(strip $(1)),$(strip $(2))))
79endef
80
81# Args:
Joe Onorato38a57bf2021-02-08 13:38:01 -080082# $(1): Config phase (PRODUCT, EXPAND, or DEVICE)
Joe Onoratof20c93a2021-01-19 22:34:22 -080083# $(2): Root nodes to import
84# $(3): All variable names
85# $(4): Single-value variables
Joe Onorato64f3db22021-02-05 11:46:03 -080086# $(5): Makefile being processed
87define dump-phase-start
Joe Onoratof20c93a2021-01-19 22:34:22 -080088$(eval $(file >> $(DUMPCONFIG_FILE),phase,$(strip $(1)),$(strip $(2)))) \
89$(foreach var,$(3), \
90 $(eval $(file >> $(DUMPCONFIG_FILE),var,$(if $(filter $(4),$(var)),single,list),$(var))) \
Joe Onorato64f3db22021-02-05 11:46:03 -080091) \
92$(call dump-config-vals,$(strip $(5)),initial)
93endef
94
95# Args:
96# $(1): Makefile being processed
97define dump-phase-end
98$(call dump-config-vals,$(strip $(1)),final)
Joe Onoratof20c93a2021-01-19 22:34:22 -080099endef
100
101define dump-debug
102$(eval $(file >> $(DUMPCONFIG_FILE),debug,$(1)))
103endef
104
105# Skip these when dumping. They're not used and they cause a lot of noise in the dump.
106DUMPCONFIG_SKIP_VARS := \
107 .VARIABLES \
108 .KATI_SYMBOLS \
109 1 \
110 2 \
Joe Onorato38a57bf2021-02-08 13:38:01 -0800111 3 \
112 4 \
113 5 \
114 6 \
115 7 \
116 8 \
117 9 \
Joe Onoratof20c93a2021-01-19 22:34:22 -0800118 LOCAL_PATH \
119 MAKEFILE_LIST \
Joe Onoratof20c93a2021-01-19 22:34:22 -0800120 current_mk \
Joe Onorato38a57bf2021-02-08 13:38:01 -0800121 _eiv_ev \
122 _eiv_i \
123 _eiv_sv \
124 _eiv_tv \
Joe Onoratof20c93a2021-01-19 22:34:22 -0800125 inherit_var \
126 np \
127 _node_import_context \
128 _included \
129 _include_stack \
130 _in \
131 _nic.%
132
133# Args:
134# $(1): Makefile that was included
Joe Onorato64f3db22021-02-05 11:46:03 -0800135# $(2): block (before,import,after,initial,final)
Joe Onoratof20c93a2021-01-19 22:34:22 -0800136define dump-config-vals
137$(foreach var,$(filter-out $(DUMPCONFIG_SKIP_VARS),$(.KATI_SYMBOLS)),\
138 $(eval $(file >> $(DUMPCONFIG_FILE),val,$(call escape-for-csv,$(1)),$(2),$(call escape-for-csv,$(var)),$(call escape-for-csv,$($(var))),$(call escape-for-csv,$(KATI_variable_location $(var))))) \
139)
140endef
141
142include build/make/core/config.mk
143