• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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
39# 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
43# 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:
82#   $(1): Config phase (PRODUCT, EXPAND, or DEVICE)
83#   $(2): Root nodes to import
84#   $(3): All variable names
85#   $(4): Single-value variables
86#   $(5): Makefile being processed
87define dump-phase-start
88$(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))) \
91) \
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)
99endef
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 \
111	3 \
112	4 \
113	5 \
114	6 \
115	7 \
116	8 \
117	9 \
118	LOCAL_PATH \
119	MAKEFILE_LIST \
120	PARENT_PRODUCT_FILES \
121	current_mk \
122	_eiv_ev \
123	_eiv_i \
124	_eiv_sv \
125	_eiv_tv \
126	inherit_var \
127	np \
128	_node_import_context \
129	_included \
130	_include_stack \
131	_in \
132	_nic.%
133
134# Args:
135#   $(1): Makefile that was included
136#   $(2): block (before,import,after,initial,final)
137define dump-config-vals
138$(foreach var,$(filter-out $(DUMPCONFIG_SKIP_VARS),$(.KATI_SYMBOLS)),\
139    $(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))))) \
140)
141endef
142
143include build/make/core/config.mk
144
145