blob: cb7fbcb3ca96f6b82e76a74d2cf1044a73c82972 [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
39# Before we do anything else output the format version.
40$(file > $(DUMPCONFIG_FILE),dumpconfig_version,1)
41$(file >> $(DUMPCONFIG_FILE),dumpconfig_file,$(DUMPCONFIG_FILE))
42
43# Default goal for dumpconfig
44dumpconfig:
45 $(file >> $(DUMPCONFIG_FILE),***DONE***)
46 @echo ***DONE***
47
48# TODO(Remove): These need to be set externally
49OUT_DIR := out
50TMPDIR = /tmp/build-temp
51BUILD_DATETIME_FILE := $(OUT_DIR)/build_date.txt
52
53# Escape quotation marks for CSV, and wraps in quotation marks.
54define escape-for-csv
55"$(subst ","",$1)"
56endef
57
58# Args:
59# $(1): include stack
60define dump-import-start
61$(eval $(file >> $(DUMPCONFIG_FILE),import,$(strip $(1))))
62endef
63
64# Args:
65# $(1): include stack
66define dump-import-done
67$(eval $(file >> $(DUMPCONFIG_FILE),imported,$(strip $(1))))
68endef
69
70# Args:
71# $(1): Current file
72# $(2): Inherited file
73define dump-inherit
74$(eval $(file >> $(DUMPCONFIG_FILE),inherit,$(strip $(1)),$(strip $(2))))
75endef
76
77# Args:
78# $(1): Config phase (PRODUCT or DEVICE)
79# $(2): Root nodes to import
80# $(3): All variable names
81# $(4): Single-value variables
82define dump-product-var-names
83$(eval $(file >> $(DUMPCONFIG_FILE),phase,$(strip $(1)),$(strip $(2)))) \
84$(foreach var,$(3), \
85 $(eval $(file >> $(DUMPCONFIG_FILE),var,$(if $(filter $(4),$(var)),single,list),$(var))) \
86)
87endef
88
89define dump-debug
90$(eval $(file >> $(DUMPCONFIG_FILE),debug,$(1)))
91endef
92
93# Skip these when dumping. They're not used and they cause a lot of noise in the dump.
94DUMPCONFIG_SKIP_VARS := \
95 .VARIABLES \
96 .KATI_SYMBOLS \
97 1 \
98 2 \
99 LOCAL_PATH \
100 MAKEFILE_LIST \
101 PARENT_PRODUCT_FILES \
102 current_mk \
103 inherit_var \
104 np \
105 _node_import_context \
106 _included \
107 _include_stack \
108 _in \
109 _nic.%
110
111# Args:
112# $(1): Makefile that was included
113# $(2): block (before,import,after)
114define dump-config-vals
115$(foreach var,$(filter-out $(DUMPCONFIG_SKIP_VARS),$(.KATI_SYMBOLS)),\
116 $(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))))) \
117)
118endef
119
120include build/make/core/config.mk
121