Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 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 | # |
| 8 | ifndef KATI |
| 9 | $(warning Kati must be used to call dumpconfig.mk, not make.) |
| 10 | $(error stopping) |
| 11 | endif |
| 12 | |
| 13 | ifdef 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) |
| 17 | endif |
| 18 | |
| 19 | ifndef TARGET_PRODUCT |
| 20 | $(warning dumpconfig.mk requires TARGET_PRODUCT to be set) |
| 21 | $(error stopping) |
| 22 | endif |
| 23 | |
| 24 | ifndef TARGET_BUILD_VARIANT |
| 25 | $(warning dumpconfig.mk requires TARGET_BUILD_VARIANT to be set) |
| 26 | $(error stopping) |
| 27 | endif |
| 28 | |
| 29 | ifneq (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) |
| 32 | endif |
| 33 | |
| 34 | ifeq (,$(DUMPCONFIG_FILE)) |
| 35 | $(warning dumpconfig requires DUMPCONFIG_FILE to be set) |
| 36 | $(error stopping) |
| 37 | endif |
| 38 | |
Joe Onorato | 38a57bf | 2021-02-08 13:38:01 -0800 | [diff] [blame] | 39 | # Skip the second inclusion of all of the product config files, because |
| 40 | # we will do these checks in the product_config tool. |
| 41 | SKIP_ARTIFACT_PATH_REQUIREMENT_PRODUCTS_CHECK := true |
| 42 | |
Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 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 |
| 48 | dumpconfig: |
| 49 | $(file >> $(DUMPCONFIG_FILE),***DONE***) |
| 50 | @echo ***DONE*** |
| 51 | |
| 52 | # TODO(Remove): These need to be set externally |
| 53 | OUT_DIR := out |
| 54 | TMPDIR = /tmp/build-temp |
| 55 | BUILD_DATETIME_FILE := $(OUT_DIR)/build_date.txt |
| 56 | |
| 57 | # Escape quotation marks for CSV, and wraps in quotation marks. |
| 58 | define escape-for-csv |
| 59 | "$(subst ","",$1)" |
| 60 | endef |
| 61 | |
| 62 | # Args: |
| 63 | # $(1): include stack |
| 64 | define dump-import-start |
| 65 | $(eval $(file >> $(DUMPCONFIG_FILE),import,$(strip $(1)))) |
| 66 | endef |
| 67 | |
| 68 | # Args: |
| 69 | # $(1): include stack |
| 70 | define dump-import-done |
| 71 | $(eval $(file >> $(DUMPCONFIG_FILE),imported,$(strip $(1)))) |
| 72 | endef |
| 73 | |
| 74 | # Args: |
| 75 | # $(1): Current file |
| 76 | # $(2): Inherited file |
| 77 | define dump-inherit |
| 78 | $(eval $(file >> $(DUMPCONFIG_FILE),inherit,$(strip $(1)),$(strip $(2)))) |
| 79 | endef |
| 80 | |
| 81 | # Args: |
Joe Onorato | 38a57bf | 2021-02-08 13:38:01 -0800 | [diff] [blame] | 82 | # $(1): Config phase (PRODUCT, EXPAND, or DEVICE) |
Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 83 | # $(2): Root nodes to import |
| 84 | # $(3): All variable names |
| 85 | # $(4): Single-value variables |
Joe Onorato | 64f3db2 | 2021-02-05 11:46:03 -0800 | [diff] [blame] | 86 | # $(5): Makefile being processed |
| 87 | define dump-phase-start |
Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 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))) \ |
Joe Onorato | 64f3db2 | 2021-02-05 11:46:03 -0800 | [diff] [blame] | 91 | ) \ |
| 92 | $(call dump-config-vals,$(strip $(5)),initial) |
| 93 | endef |
| 94 | |
| 95 | # Args: |
| 96 | # $(1): Makefile being processed |
| 97 | define dump-phase-end |
| 98 | $(call dump-config-vals,$(strip $(1)),final) |
Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 99 | endef |
| 100 | |
| 101 | define dump-debug |
| 102 | $(eval $(file >> $(DUMPCONFIG_FILE),debug,$(1))) |
| 103 | endef |
| 104 | |
| 105 | # Skip these when dumping. They're not used and they cause a lot of noise in the dump. |
| 106 | DUMPCONFIG_SKIP_VARS := \ |
| 107 | .VARIABLES \ |
| 108 | .KATI_SYMBOLS \ |
| 109 | 1 \ |
| 110 | 2 \ |
Joe Onorato | 38a57bf | 2021-02-08 13:38:01 -0800 | [diff] [blame] | 111 | 3 \ |
| 112 | 4 \ |
| 113 | 5 \ |
| 114 | 6 \ |
| 115 | 7 \ |
| 116 | 8 \ |
| 117 | 9 \ |
Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 118 | LOCAL_PATH \ |
| 119 | MAKEFILE_LIST \ |
Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 120 | current_mk \ |
Joe Onorato | 38a57bf | 2021-02-08 13:38:01 -0800 | [diff] [blame] | 121 | _eiv_ev \ |
| 122 | _eiv_i \ |
| 123 | _eiv_sv \ |
| 124 | _eiv_tv \ |
Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 125 | 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 Onorato | 64f3db2 | 2021-02-05 11:46:03 -0800 | [diff] [blame] | 135 | # $(2): block (before,import,after,initial,final) |
Joe Onorato | f20c93a | 2021-01-19 22:34:22 -0800 | [diff] [blame] | 136 | define 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 | ) |
| 140 | endef |
| 141 | |
| 142 | include build/make/core/config.mk |
| 143 | |