| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved. | 
 | 2 | // | 
 | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 4 | // you may not use this file except in compliance with the License. | 
 | 5 | // You may obtain a copy of the License at | 
 | 6 | // | 
 | 7 | //     http://www.apache.org/licenses/LICENSE-2.0 | 
 | 8 | // | 
 | 9 | // Unless required by applicable law or agreed to in writing, software | 
 | 10 | // distributed under the License is distributed on an "AS IS" BASIS, | 
 | 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 12 | // See the License for the specific language governing permissions and | 
 | 13 | // limitations under the License. | 
 | 14 |  | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 15 | package android | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 16 |  | 
 | 17 | import ( | 
 | 18 | 	"fmt" | 
 | 19 | 	"reflect" | 
| Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 20 | 	"runtime" | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 21 | 	"strings" | 
 | 22 |  | 
| Cole Faust | 701ca25 | 2021-11-23 19:02:08 -0800 | [diff] [blame] | 23 | 	"android/soong/bazel" | 
 | 24 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 25 | 	"github.com/google/blueprint/proptools" | 
 | 26 | ) | 
 | 27 |  | 
 | 28 | func init() { | 
| Paul Duffin | e7a055c | 2021-03-07 15:46:33 +0000 | [diff] [blame] | 29 | 	registerVariableBuildComponents(InitRegistrationContext) | 
 | 30 | } | 
 | 31 |  | 
 | 32 | func registerVariableBuildComponents(ctx RegistrationContext) { | 
 | 33 | 	ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { | 
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 34 | 		ctx.BottomUp("variable", VariableMutator).Parallel() | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 35 | 	}) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 36 | } | 
 | 37 |  | 
| Paul Duffin | e7a055c | 2021-03-07 15:46:33 +0000 | [diff] [blame] | 38 | var PrepareForTestWithVariables = FixtureRegisterWithContext(registerVariableBuildComponents) | 
 | 39 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 40 | type variableProperties struct { | 
 | 41 | 	Product_variables struct { | 
| Dan Willemsen | 47cf66b | 2015-09-16 16:48:54 -0700 | [diff] [blame] | 42 | 		Platform_sdk_version struct { | 
 | 43 | 			Asflags []string | 
| Colin Cross | ceeff0f | 2017-05-08 13:43:00 -0700 | [diff] [blame] | 44 | 			Cflags  []string | 
| Dan Willemsen | 9fe1410 | 2021-07-13 21:52:04 -0700 | [diff] [blame] | 45 | 			Cmd     *string | 
| Dan Willemsen | 47cf66b | 2015-09-16 16:48:54 -0700 | [diff] [blame] | 46 | 		} | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 47 |  | 
| Yuntao Xu | 402e9b0 | 2021-08-09 15:44:44 -0700 | [diff] [blame] | 48 | 		Platform_sdk_version_or_codename struct { | 
 | 49 | 			Java_resource_dirs []string | 
 | 50 | 		} | 
 | 51 |  | 
| Anton Hansson | b021bf8 | 2021-08-27 17:35:40 +0100 | [diff] [blame] | 52 | 		Platform_sdk_extension_version struct { | 
 | 53 | 			Cmd *string | 
 | 54 | 		} | 
 | 55 |  | 
| Dan Willemsen | 9fe1410 | 2021-07-13 21:52:04 -0700 | [diff] [blame] | 56 | 		Platform_version_name struct { | 
 | 57 | 			Base_dir *string | 
 | 58 | 		} | 
 | 59 |  | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 60 | 		// unbundled_build is a catch-all property to annotate modules that don't build in one or | 
 | 61 | 		// more unbundled branches, usually due to dependencies missing from the manifest. | 
 | 62 | 		Unbundled_build struct { | 
 | 63 | 			Enabled *bool `android:"arch_variant"` | 
 | 64 | 		} `android:"arch_variant"` | 
| Dan Willemsen | 496e395 | 2016-01-05 14:27:55 -0800 | [diff] [blame] | 65 |  | 
| Jeongik Cha | f08e59c | 2023-02-09 10:47:59 +0900 | [diff] [blame] | 66 | 		// similar to `Unbundled_build`, but `Always_use_prebuilt_sdks` means that it uses prebuilt | 
 | 67 | 		// sdk specifically. | 
 | 68 | 		Always_use_prebuilt_sdks struct { | 
 | 69 | 			Enabled *bool `android:"arch_variant"` | 
 | 70 | 		} `android:"arch_variant"` | 
 | 71 |  | 
| Dan Willemsen | 97cae01 | 2016-03-01 14:08:42 -0800 | [diff] [blame] | 72 | 		Malloc_not_svelte struct { | 
| Christopher Ferris | c71193a | 2019-12-16 09:55:10 -0800 | [diff] [blame] | 73 | 			Cflags              []string `android:"arch_variant"` | 
 | 74 | 			Shared_libs         []string `android:"arch_variant"` | 
 | 75 | 			Whole_static_libs   []string `android:"arch_variant"` | 
 | 76 | 			Exclude_static_libs []string `android:"arch_variant"` | 
| Christopher Ferris | dea6617 | 2021-09-24 00:07:53 -0700 | [diff] [blame] | 77 | 			Srcs                []string `android:"arch_variant"` | 
 | 78 | 			Header_libs         []string `android:"arch_variant"` | 
| Sasha Smundak | 61ebf8d | 2018-08-31 16:56:05 -0700 | [diff] [blame] | 79 | 		} `android:"arch_variant"` | 
| Evgenii Stepanov | 8391efa | 2016-05-12 18:04:18 -0700 | [diff] [blame] | 80 |  | 
| Evgenii Stepanov | 19ff3c9 | 2020-04-29 14:57:30 -0700 | [diff] [blame] | 81 | 		Malloc_zero_contents struct { | 
 | 82 | 			Cflags []string `android:"arch_variant"` | 
 | 83 | 		} `android:"arch_variant"` | 
 | 84 |  | 
 | 85 | 		Malloc_pattern_fill_contents struct { | 
 | 86 | 			Cflags []string `android:"arch_variant"` | 
 | 87 | 		} `android:"arch_variant"` | 
 | 88 |  | 
| Evgenii Stepanov | 8391efa | 2016-05-12 18:04:18 -0700 | [diff] [blame] | 89 | 		Safestack struct { | 
 | 90 | 			Cflags []string `android:"arch_variant"` | 
 | 91 | 		} `android:"arch_variant"` | 
| Dan Willemsen | a6f7d15 | 2016-07-12 14:57:40 -0700 | [diff] [blame] | 92 |  | 
| Dan Willemsen | 1be3538 | 2016-07-25 17:42:18 -0700 | [diff] [blame] | 93 | 		Binder32bit struct { | 
 | 94 | 			Cflags []string | 
 | 95 | 		} | 
| Dan Willemsen | fcebcd5 | 2016-09-22 14:49:10 -0700 | [diff] [blame] | 96 |  | 
| Colin Cross | 9543642 | 2017-05-04 13:57:05 -0700 | [diff] [blame] | 97 | 		Override_rs_driver struct { | 
 | 98 | 			Cflags []string | 
 | 99 | 		} | 
 | 100 |  | 
| Steven Moreland | c2b9f06 | 2017-12-13 14:06:20 -0800 | [diff] [blame] | 101 | 		// treble_linker_namespaces is true when the system/vendor linker namespace separation is | 
 | 102 | 		// enabled. | 
 | 103 | 		Treble_linker_namespaces struct { | 
 | 104 | 			Cflags []string | 
 | 105 | 		} | 
| Steven Moreland | c2b9f06 | 2017-12-13 14:06:20 -0800 | [diff] [blame] | 106 | 		// enforce_vintf_manifest is true when a device is required to have a vintf manifest. | 
 | 107 | 		Enforce_vintf_manifest struct { | 
 | 108 | 			Cflags []string | 
 | 109 | 		} | 
 | 110 |  | 
| Jihoon Kang | cbcad7c | 2023-06-01 22:31:52 +0000 | [diff] [blame] | 111 | 		Build_from_text_stub struct { | 
 | 112 | 			Static_libs         []string | 
 | 113 | 			Exclude_static_libs []string | 
 | 114 | 		} | 
 | 115 |  | 
| Colin Cross | 6bc59ef | 2016-12-08 09:46:35 -0800 | [diff] [blame] | 116 | 		// debuggable is true for eng and userdebug builds, and can be used to turn on additional | 
 | 117 | 		// debugging features that don't significantly impact runtime behavior.  userdebug builds | 
 | 118 | 		// are used for dogfooding and performance testing, and should be as similar to user builds | 
 | 119 | 		// as possible. | 
| Dan Willemsen | fcebcd5 | 2016-09-22 14:49:10 -0700 | [diff] [blame] | 120 | 		Debuggable struct { | 
| Sasha Smundak | b6d2305 | 2019-04-01 18:37:36 -0700 | [diff] [blame] | 121 | 			Cflags          []string | 
 | 122 | 			Cppflags        []string | 
 | 123 | 			Init_rc         []string | 
 | 124 | 			Required        []string | 
 | 125 | 			Host_required   []string | 
 | 126 | 			Target_required []string | 
| Philip Cuadra | 328e0bf | 2020-10-19 22:01:29 -0700 | [diff] [blame] | 127 | 			Strip           struct { | 
 | 128 | 				All                          *bool | 
 | 129 | 				Keep_symbols                 *bool | 
 | 130 | 				Keep_symbols_and_debug_frame *bool | 
 | 131 | 			} | 
| Yifan Hong | 8f323ae | 2021-06-23 20:01:13 -0700 | [diff] [blame] | 132 | 			Static_libs       []string | 
 | 133 | 			Whole_static_libs []string | 
 | 134 | 			Shared_libs       []string | 
| Jiyong Park | 16e77a9 | 2021-08-30 18:43:19 +0900 | [diff] [blame] | 135 |  | 
 | 136 | 			Cmdline []string | 
| Inseob Kim | f5ed300 | 2022-01-07 19:17:29 +0900 | [diff] [blame] | 137 |  | 
| Jay Aliomer | 2599d1d | 2021-09-23 15:49:54 -0400 | [diff] [blame] | 138 | 			Srcs         []string | 
 | 139 | 			Exclude_srcs []string | 
| Cole Faust | ed94000 | 2023-08-15 11:59:24 -0700 | [diff] [blame] | 140 | 			Cmd          *string | 
| Dan Willemsen | fcebcd5 | 2016-09-22 14:49:10 -0700 | [diff] [blame] | 141 | 		} | 
| Colin Cross | 6bc59ef | 2016-12-08 09:46:35 -0800 | [diff] [blame] | 142 |  | 
| Usta Shrestha | c725f47 | 2022-01-11 02:44:21 -0500 | [diff] [blame] | 143 | 		// eng is true for -eng builds, and can be used to turn on additional heavyweight debugging | 
| Colin Cross | 6bc59ef | 2016-12-08 09:46:35 -0800 | [diff] [blame] | 144 | 		// features. | 
 | 145 | 		Eng struct { | 
 | 146 | 			Cflags   []string | 
 | 147 | 			Cppflags []string | 
| John Reck | 1d2b7ee | 2018-07-11 11:01:59 -0700 | [diff] [blame] | 148 | 			Lto      struct { | 
 | 149 | 				Never *bool | 
 | 150 | 			} | 
| Colin Cross | 3273cc2 | 2018-10-26 23:58:42 -0700 | [diff] [blame] | 151 | 			Sanitize struct { | 
 | 152 | 				Address *bool | 
 | 153 | 			} | 
| Felka Chang | f13642e | 2019-06-21 20:58:27 +0800 | [diff] [blame] | 154 | 			Optimize struct { | 
 | 155 | 				Enabled *bool | 
 | 156 | 			} | 
| Colin Cross | 6bc59ef | 2016-12-08 09:46:35 -0800 | [diff] [blame] | 157 | 		} | 
| Colin Cross | b2123aa | 2017-05-05 13:37:11 -0700 | [diff] [blame] | 158 |  | 
| Dmitry Shmidt | dba5419 | 2017-08-23 14:58:37 -0700 | [diff] [blame] | 159 | 		Uml struct { | 
 | 160 | 			Cppflags []string | 
 | 161 | 		} | 
| Risan | ea004dd | 2017-11-27 18:14:46 +0900 | [diff] [blame] | 162 |  | 
 | 163 | 		Arc struct { | 
| Satoshi Niwa | 54f4826 | 2020-12-18 09:53:26 +0900 | [diff] [blame] | 164 | 			Cflags            []string `android:"arch_variant"` | 
 | 165 | 			Exclude_srcs      []string `android:"arch_variant"` | 
| Jasmine Chen | acace42 | 2021-03-05 00:56:40 +0800 | [diff] [blame] | 166 | 			Header_libs       []string `android:"arch_variant"` | 
| Satoshi Niwa | 54f4826 | 2020-12-18 09:53:26 +0900 | [diff] [blame] | 167 | 			Include_dirs      []string `android:"arch_variant"` | 
 | 168 | 			Shared_libs       []string `android:"arch_variant"` | 
 | 169 | 			Static_libs       []string `android:"arch_variant"` | 
 | 170 | 			Srcs              []string `android:"arch_variant"` | 
 | 171 | 			Whole_static_libs []string `android:"arch_variant"` | 
 | 172 | 		} `android:"arch_variant"` | 
| Roland Levillain | 2879d41 | 2019-08-13 15:00:18 +0100 | [diff] [blame] | 173 |  | 
| Colin Cross | d9a121b | 2020-01-27 13:26:42 -0800 | [diff] [blame] | 174 | 		Native_coverage struct { | 
| Colin Cross | 2b10ba0 | 2020-02-05 16:23:21 -0800 | [diff] [blame] | 175 | 			Src          *string  `android:"arch_variant"` | 
| Colin Cross | d9a121b | 2020-01-27 13:26:42 -0800 | [diff] [blame] | 176 | 			Srcs         []string `android:"arch_variant"` | 
 | 177 | 			Exclude_srcs []string `android:"arch_variant"` | 
 | 178 | 		} `android:"arch_variant"` | 
| Devin Moore | c381e10 | 2023-07-06 22:03:58 +0000 | [diff] [blame] | 179 |  | 
 | 180 | 		// release_aidl_use_unfrozen is "true" when a device can | 
 | 181 | 		// use the unfrozen versions of AIDL interfaces. | 
 | 182 | 		Release_aidl_use_unfrozen struct { | 
 | 183 | 			Cflags []string | 
 | 184 | 			Cmd    *string | 
 | 185 | 		} | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 186 | 	} `android:"arch_variant"` | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 187 | } | 
 | 188 |  | 
| Colin Cross | 6961a49 | 2020-02-06 16:57:45 -0800 | [diff] [blame] | 189 | var defaultProductVariables interface{} = variableProperties{} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 190 |  | 
| Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 191 | type ProductVariables struct { | 
| Dan Willemsen | 174978c | 2016-05-11 00:27:49 -0700 | [diff] [blame] | 192 | 	// Suffix to add to generated Makefiles | 
 | 193 | 	Make_suffix *string `json:",omitempty"` | 
 | 194 |  | 
| Colin Cross | 2a2e0db | 2020-02-21 16:55:46 -0800 | [diff] [blame] | 195 | 	BuildId         *string `json:",omitempty"` | 
 | 196 | 	BuildNumberFile *string `json:",omitempty"` | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 197 |  | 
| Colin Cross | 092c9da | 2019-04-02 22:56:43 -0700 | [diff] [blame] | 198 | 	Platform_version_name                     *string  `json:",omitempty"` | 
 | 199 | 	Platform_sdk_version                      *int     `json:",omitempty"` | 
 | 200 | 	Platform_sdk_codename                     *string  `json:",omitempty"` | 
| Yuntao Xu | 402e9b0 | 2021-08-09 15:44:44 -0700 | [diff] [blame] | 201 | 	Platform_sdk_version_or_codename          *string  `json:",omitempty"` | 
| Colin Cross | 092c9da | 2019-04-02 22:56:43 -0700 | [diff] [blame] | 202 | 	Platform_sdk_final                        *bool    `json:",omitempty"` | 
| Anton Hansson | b021bf8 | 2021-08-27 17:35:40 +0100 | [diff] [blame] | 203 | 	Platform_sdk_extension_version            *int     `json:",omitempty"` | 
| Anton Hansson | 97d0bae | 2022-02-16 16:15:10 +0000 | [diff] [blame] | 204 | 	Platform_base_sdk_extension_version       *int     `json:",omitempty"` | 
| Colin Cross | 092c9da | 2019-04-02 22:56:43 -0700 | [diff] [blame] | 205 | 	Platform_version_active_codenames         []string `json:",omitempty"` | 
| Dan Albert | 8c7a994 | 2023-03-27 20:34:01 +0000 | [diff] [blame] | 206 | 	Platform_version_all_preview_codenames    []string `json:",omitempty"` | 
| Colin Cross | 092c9da | 2019-04-02 22:56:43 -0700 | [diff] [blame] | 207 | 	Platform_vndk_version                     *string  `json:",omitempty"` | 
 | 208 | 	Platform_systemsdk_versions               []string `json:",omitempty"` | 
 | 209 | 	Platform_security_patch                   *string  `json:",omitempty"` | 
 | 210 | 	Platform_preview_sdk_version              *string  `json:",omitempty"` | 
 | 211 | 	Platform_min_supported_target_sdk_version *string  `json:",omitempty"` | 
 | 212 | 	Platform_base_os                          *string  `json:",omitempty"` | 
| Inseob Kim | 4f1f3d9 | 2022-04-25 18:23:58 +0900 | [diff] [blame] | 213 | 	Platform_version_last_stable              *string  `json:",omitempty"` | 
| Jiyong Park | 3707384 | 2022-06-21 10:13:42 +0900 | [diff] [blame] | 214 | 	Platform_version_known_codenames          *string  `json:",omitempty"` | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 215 |  | 
| Jeongik Cha | 219141c | 2020-08-06 23:00:37 +0900 | [diff] [blame] | 216 | 	DeviceName                            *string  `json:",omitempty"` | 
| Trevor Radcliffe | 90727f4 | 2022-03-21 19:34:02 +0000 | [diff] [blame] | 217 | 	DeviceProduct                         *string  `json:",omitempty"` | 
| Jeongik Cha | 219141c | 2020-08-06 23:00:37 +0900 | [diff] [blame] | 218 | 	DeviceArch                            *string  `json:",omitempty"` | 
 | 219 | 	DeviceArchVariant                     *string  `json:",omitempty"` | 
 | 220 | 	DeviceCpuVariant                      *string  `json:",omitempty"` | 
 | 221 | 	DeviceAbi                             []string `json:",omitempty"` | 
 | 222 | 	DeviceVndkVersion                     *string  `json:",omitempty"` | 
 | 223 | 	DeviceCurrentApiLevelForVendorModules *string  `json:",omitempty"` | 
 | 224 | 	DeviceSystemSdkVersions               []string `json:",omitempty"` | 
| Juan Yescas | 05d4d90 | 2023-04-07 10:35:35 -0700 | [diff] [blame] | 225 | 	DeviceMaxPageSizeSupported            *string  `json:",omitempty"` | 
| Vilas Bhat | b3d2d22 | 2023-12-04 22:51:20 +0000 | [diff] [blame] | 226 | 	DeviceNoBionicPageSizeMacro           *bool    `json:",omitempty"` | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 227 |  | 
| Justin Yun | 41cbb5e | 2023-11-29 17:58:16 +0900 | [diff] [blame] | 228 | 	VendorApiLevel *string `json:",omitempty"` | 
 | 229 |  | 
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 230 | 	RecoverySnapshotVersion *string `json:",omitempty"` | 
 | 231 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 232 | 	DeviceSecondaryArch        *string  `json:",omitempty"` | 
 | 233 | 	DeviceSecondaryArchVariant *string  `json:",omitempty"` | 
 | 234 | 	DeviceSecondaryCpuVariant  *string  `json:",omitempty"` | 
 | 235 | 	DeviceSecondaryAbi         []string `json:",omitempty"` | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 236 |  | 
| dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 237 | 	NativeBridgeArch         *string  `json:",omitempty"` | 
 | 238 | 	NativeBridgeArchVariant  *string  `json:",omitempty"` | 
 | 239 | 	NativeBridgeCpuVariant   *string  `json:",omitempty"` | 
 | 240 | 	NativeBridgeAbi          []string `json:",omitempty"` | 
 | 241 | 	NativeBridgeRelativePath *string  `json:",omitempty"` | 
| dimitry | 1f33e40 | 2019-03-26 12:39:31 +0100 | [diff] [blame] | 242 |  | 
| dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 243 | 	NativeBridgeSecondaryArch         *string  `json:",omitempty"` | 
 | 244 | 	NativeBridgeSecondaryArchVariant  *string  `json:",omitempty"` | 
 | 245 | 	NativeBridgeSecondaryCpuVariant   *string  `json:",omitempty"` | 
 | 246 | 	NativeBridgeSecondaryAbi          []string `json:",omitempty"` | 
 | 247 | 	NativeBridgeSecondaryRelativePath *string  `json:",omitempty"` | 
| dimitry | 1f33e40 | 2019-03-26 12:39:31 +0100 | [diff] [blame] | 248 |  | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 249 | 	HostArch          *string `json:",omitempty"` | 
 | 250 | 	HostSecondaryArch *string `json:",omitempty"` | 
| Colin Cross | 528d67e | 2021-07-23 22:23:07 +0000 | [diff] [blame] | 251 | 	HostMusl          *bool   `json:",omitempty"` | 
| Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 252 |  | 
 | 253 | 	CrossHost              *string `json:",omitempty"` | 
 | 254 | 	CrossHostArch          *string `json:",omitempty"` | 
 | 255 | 	CrossHostSecondaryArch *string `json:",omitempty"` | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 256 |  | 
| Jeongik Cha | cee5ba9 | 2021-02-19 12:11:51 +0900 | [diff] [blame] | 257 | 	DeviceResourceOverlays     []string `json:",omitempty"` | 
 | 258 | 	ProductResourceOverlays    []string `json:",omitempty"` | 
 | 259 | 	EnforceRROTargets          []string `json:",omitempty"` | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 260 | 	EnforceRROExcludedOverlays []string `json:",omitempty"` | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 261 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 262 | 	AAPTCharacteristics *string  `json:",omitempty"` | 
 | 263 | 	AAPTConfig          []string `json:",omitempty"` | 
 | 264 | 	AAPTPreferredConfig *string  `json:",omitempty"` | 
 | 265 | 	AAPTPrebuiltDPI     []string `json:",omitempty"` | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 266 |  | 
| Inseob Kim | 80fa798 | 2022-08-12 21:36:25 +0900 | [diff] [blame] | 267 | 	DefaultAppCertificate           *string `json:",omitempty"` | 
 | 268 | 	MainlineSepolicyDevCertificates *string `json:",omitempty"` | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 269 |  | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 270 | 	AppsDefaultVersionName *string `json:",omitempty"` | 
 | 271 |  | 
| Cole Faust | 701ca25 | 2021-11-23 19:02:08 -0800 | [diff] [blame] | 272 | 	Allow_missing_dependencies   *bool    `json:",omitempty"` | 
 | 273 | 	Unbundled_build              *bool    `json:",omitempty"` | 
 | 274 | 	Unbundled_build_apps         []string `json:",omitempty"` | 
 | 275 | 	Unbundled_build_image        *bool    `json:",omitempty"` | 
 | 276 | 	Always_use_prebuilt_sdks     *bool    `json:",omitempty"` | 
 | 277 | 	Skip_boot_jars_check         *bool    `json:",omitempty"` | 
 | 278 | 	Malloc_not_svelte            *bool    `json:",omitempty"` | 
 | 279 | 	Malloc_zero_contents         *bool    `json:",omitempty"` | 
 | 280 | 	Malloc_pattern_fill_contents *bool    `json:",omitempty"` | 
 | 281 | 	Safestack                    *bool    `json:",omitempty"` | 
 | 282 | 	HostStaticBinaries           *bool    `json:",omitempty"` | 
 | 283 | 	Binder32bit                  *bool    `json:",omitempty"` | 
 | 284 | 	UseGoma                      *bool    `json:",omitempty"` | 
 | 285 | 	UseRBE                       *bool    `json:",omitempty"` | 
 | 286 | 	UseRBEJAVAC                  *bool    `json:",omitempty"` | 
 | 287 | 	UseRBER8                     *bool    `json:",omitempty"` | 
 | 288 | 	UseRBED8                     *bool    `json:",omitempty"` | 
 | 289 | 	Debuggable                   *bool    `json:",omitempty"` | 
 | 290 | 	Eng                          *bool    `json:",omitempty"` | 
 | 291 | 	Treble_linker_namespaces     *bool    `json:",omitempty"` | 
 | 292 | 	Enforce_vintf_manifest       *bool    `json:",omitempty"` | 
 | 293 | 	Uml                          *bool    `json:",omitempty"` | 
 | 294 | 	Arc                          *bool    `json:",omitempty"` | 
 | 295 | 	MinimizeJavaDebugInfo        *bool    `json:",omitempty"` | 
| Jihoon Kang | cbcad7c | 2023-06-01 22:31:52 +0000 | [diff] [blame] | 296 | 	Build_from_text_stub         *bool    `json:",omitempty"` | 
| Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 297 |  | 
| Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 298 | 	Check_elf_files *bool `json:",omitempty"` | 
 | 299 |  | 
| Colin Cross | 5a0dcd5 | 2018-10-05 14:20:06 -0700 | [diff] [blame] | 300 | 	UncompressPrivAppDex             *bool    `json:",omitempty"` | 
 | 301 | 	ModulesLoadedByPrivilegedModules []string `json:",omitempty"` | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 302 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 303 | 	BootJars     ConfiguredJarList `json:",omitempty"` | 
 | 304 | 	ApexBootJars ConfiguredJarList `json:",omitempty"` | 
| Vladimir Marko | e8b00d6 | 2018-12-21 15:54:16 +0000 | [diff] [blame] | 305 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 306 | 	IntegerOverflowExcludePaths []string `json:",omitempty"` | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 307 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 308 | 	EnableCFI       *bool    `json:",omitempty"` | 
 | 309 | 	CFIExcludePaths []string `json:",omitempty"` | 
 | 310 | 	CFIIncludePaths []string `json:",omitempty"` | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 311 |  | 
| Kostya Kortchinsky | d5275c8 | 2019-02-01 08:42:56 -0800 | [diff] [blame] | 312 | 	DisableScudo *bool `json:",omitempty"` | 
 | 313 |  | 
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 314 | 	MemtagHeapExcludePaths      []string `json:",omitempty"` | 
 | 315 | 	MemtagHeapAsyncIncludePaths []string `json:",omitempty"` | 
 | 316 | 	MemtagHeapSyncIncludePaths  []string `json:",omitempty"` | 
 | 317 |  | 
| Hang Lu | a98aab9 | 2023-03-17 13:17:22 +0800 | [diff] [blame] | 318 | 	HWASanIncludePaths []string `json:",omitempty"` | 
| Tomislav Novak | f734f00 | 2023-08-22 10:51:44 -0700 | [diff] [blame] | 319 | 	HWASanExcludePaths []string `json:",omitempty"` | 
| Hang Lu | a98aab9 | 2023-03-17 13:17:22 +0800 | [diff] [blame] | 320 |  | 
| Justin Yun | d5f6c82 | 2019-06-25 16:47:17 +0900 | [diff] [blame] | 321 | 	VendorPath    *string `json:",omitempty"` | 
 | 322 | 	OdmPath       *string `json:",omitempty"` | 
 | 323 | 	ProductPath   *string `json:",omitempty"` | 
 | 324 | 	SystemExtPath *string `json:",omitempty"` | 
| Dan Willemsen | 4353bc4 | 2016-12-05 17:16:02 -0800 | [diff] [blame] | 325 |  | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 326 | 	ClangTidy  *bool   `json:",omitempty"` | 
 | 327 | 	TidyChecks *string `json:",omitempty"` | 
 | 328 |  | 
| Roland Levillain | ada1270 | 2020-06-09 13:07:36 +0100 | [diff] [blame] | 329 | 	JavaCoveragePaths        []string `json:",omitempty"` | 
 | 330 | 	JavaCoverageExcludePaths []string `json:",omitempty"` | 
 | 331 |  | 
| Pirama Arumuga Nainar | b37ae58 | 2022-01-26 22:14:32 -0800 | [diff] [blame] | 332 | 	GcovCoverage                *bool    `json:",omitempty"` | 
 | 333 | 	ClangCoverage               *bool    `json:",omitempty"` | 
 | 334 | 	NativeCoveragePaths         []string `json:",omitempty"` | 
 | 335 | 	NativeCoverageExcludePaths  []string `json:",omitempty"` | 
 | 336 | 	ClangCoverageContinuousMode *bool    `json:",omitempty"` | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 337 |  | 
| Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 338 | 	// Set by NewConfig | 
| Liz Kammer | 09f947d | 2021-05-12 14:51:49 -0400 | [diff] [blame] | 339 | 	Native_coverage *bool `json:",omitempty"` | 
| Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 340 |  | 
| Colin Cross | 23ae82a | 2016-11-02 14:34:39 -0700 | [diff] [blame] | 341 | 	SanitizeHost       []string `json:",omitempty"` | 
 | 342 | 	SanitizeDevice     []string `json:",omitempty"` | 
| Ivan Lozano | 0c3a1ef | 2017-06-28 09:10:48 -0700 | [diff] [blame] | 343 | 	SanitizeDeviceDiag []string `json:",omitempty"` | 
| Colin Cross | 23ae82a | 2016-11-02 14:34:39 -0700 | [diff] [blame] | 344 | 	SanitizeDeviceArch []string `json:",omitempty"` | 
| Hiroshi Yamauchi | e2a1063 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 345 |  | 
 | 346 | 	ArtUseReadBarrier *bool `json:",omitempty"` | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 347 |  | 
 | 348 | 	BtConfigIncludeDir *string `json:",omitempty"` | 
| Colin Cross | 9543642 | 2017-05-04 13:57:05 -0700 | [diff] [blame] | 349 |  | 
 | 350 | 	Override_rs_driver *string `json:",omitempty"` | 
| Jiyong Park | d773eb3 | 2017-07-03 13:18:12 +0900 | [diff] [blame] | 351 |  | 
 | 352 | 	DeviceKernelHeaders []string `json:",omitempty"` | 
| Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 353 |  | 
 | 354 | 	ExtraVndkVersions []string `json:",omitempty"` | 
| Jeff Gaston | 088e29e | 2017-11-29 16:47:17 -0800 | [diff] [blame] | 355 |  | 
 | 356 | 	NamespacesToExport []string `json:",omitempty"` | 
| Pirama Arumuga Nainar | 4954080 | 2018-01-29 23:11:42 -0800 | [diff] [blame] | 357 |  | 
| Vinh Tran | 7a8362c | 2022-11-01 15:33:51 -0400 | [diff] [blame] | 358 | 	PgoAdditionalProfileDirs []string `json:",omitempty"` | 
| Dan Willemsen | 0fe7866 | 2018-03-26 12:41:18 -0700 | [diff] [blame] | 359 |  | 
| Inseob Kim | ae55303 | 2019-05-14 18:52:49 +0900 | [diff] [blame] | 360 | 	VndkUseCoreVariant         *bool `json:",omitempty"` | 
 | 361 | 	VndkSnapshotBuildArtifacts *bool `json:",omitempty"` | 
| Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 362 |  | 
| Inseob Kim | 7cf1465 | 2021-01-06 23:06:52 +0900 | [diff] [blame] | 363 | 	DirectedVendorSnapshot bool            `json:",omitempty"` | 
 | 364 | 	VendorSnapshotModules  map[string]bool `json:",omitempty"` | 
 | 365 |  | 
| Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 366 | 	DirectedRecoverySnapshot bool            `json:",omitempty"` | 
 | 367 | 	RecoverySnapshotModules  map[string]bool `json:",omitempty"` | 
 | 368 |  | 
| Justin DeMartino | 383bfb3 | 2021-02-24 10:49:43 -0800 | [diff] [blame] | 369 | 	VendorSnapshotDirsIncluded   []string `json:",omitempty"` | 
 | 370 | 	VendorSnapshotDirsExcluded   []string `json:",omitempty"` | 
 | 371 | 	RecoverySnapshotDirsExcluded []string `json:",omitempty"` | 
 | 372 | 	RecoverySnapshotDirsIncluded []string `json:",omitempty"` | 
| Rob Seymour | 925aa09 | 2021-08-10 20:42:03 +0000 | [diff] [blame] | 373 | 	HostFakeSnapshotEnabled      bool     `json:",omitempty"` | 
| Justin DeMartino | 383bfb3 | 2021-02-24 10:49:43 -0800 | [diff] [blame] | 374 |  | 
| Inseob Kim | 5eb7ee9 | 2022-04-27 10:30:34 +0900 | [diff] [blame] | 375 | 	MultitreeUpdateMeta bool `json:",omitempty"` | 
 | 376 |  | 
| Inseob Kim | 6077b23 | 2023-08-31 16:49:59 +0900 | [diff] [blame] | 377 | 	BoardVendorSepolicyDirs      []string `json:",omitempty"` | 
 | 378 | 	BoardOdmSepolicyDirs         []string `json:",omitempty"` | 
 | 379 | 	SystemExtPublicSepolicyDirs  []string `json:",omitempty"` | 
 | 380 | 	SystemExtPrivateSepolicyDirs []string `json:",omitempty"` | 
 | 381 | 	BoardSepolicyM4Defs          []string `json:",omitempty"` | 
| Tri Vo | 35a5143 | 2018-03-25 20:00:00 -0700 | [diff] [blame] | 382 |  | 
| Inseob Kim | 16ebd5a | 2020-12-09 23:08:17 +0900 | [diff] [blame] | 383 | 	BoardSepolicyVers       *string `json:",omitempty"` | 
 | 384 | 	PlatformSepolicyVersion *string `json:",omitempty"` | 
| Inseob Kim | a10ef27 | 2021-09-15 03:04:53 +0000 | [diff] [blame] | 385 | 	TotSepolicyVersion      *string `json:",omitempty"` | 
| Inseob Kim | 16ebd5a | 2020-12-09 23:08:17 +0900 | [diff] [blame] | 386 |  | 
| Inseob Kim | 1a0afcc | 2022-02-14 23:10:51 +0900 | [diff] [blame] | 387 | 	SystemExtSepolicyPrebuiltApiDir *string `json:",omitempty"` | 
 | 388 | 	ProductSepolicyPrebuiltApiDir   *string `json:",omitempty"` | 
 | 389 |  | 
| Inseob Kim | 843f664 | 2022-01-07 09:11:23 +0900 | [diff] [blame] | 390 | 	PlatformSepolicyCompatVersions []string `json:",omitempty"` | 
 | 391 |  | 
| Dan Willemsen | 0fe7866 | 2018-03-26 12:41:18 -0700 | [diff] [blame] | 392 | 	VendorVars map[string]map[string]string `json:",omitempty"` | 
| Colin Cross | 395f2cf | 2018-10-24 16:10:32 -0700 | [diff] [blame] | 393 |  | 
| Dan Albert | d05ba00 | 2021-04-13 15:55:47 -0700 | [diff] [blame] | 394 | 	Ndk_abis *bool `json:",omitempty"` | 
| Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 395 |  | 
| Dennis Shen | e2ed70c | 2023-01-11 14:15:43 +0000 | [diff] [blame] | 396 | 	TrimmedApex                  *bool `json:",omitempty"` | 
| Jiyong Park | 4da0797 | 2021-01-05 21:01:11 +0900 | [diff] [blame] | 397 | 	ForceApexSymlinkOptimization *bool `json:",omitempty"` | 
 | 398 | 	CompressedApex               *bool `json:",omitempty"` | 
 | 399 | 	Aml_abis                     *bool `json:",omitempty"` | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 400 |  | 
 | 401 | 	DexpreoptGlobalConfig *string `json:",omitempty"` | 
| Jiyong Park | 7f67f48 | 2019-01-05 12:57:48 +0900 | [diff] [blame] | 402 |  | 
| Inseob Kim | 7b85eeb | 2021-03-23 20:52:24 +0900 | [diff] [blame] | 403 | 	WithDexpreopt bool `json:",omitempty"` | 
 | 404 |  | 
| Jiakai Zhang | 4d90da2 | 2023-07-12 16:51:48 +0100 | [diff] [blame] | 405 | 	ManifestPackageNameOverrides   []string `json:",omitempty"` | 
 | 406 | 	CertificateOverrides           []string `json:",omitempty"` | 
 | 407 | 	PackageNameOverrides           []string `json:",omitempty"` | 
 | 408 | 	ConfiguredJarLocationOverrides []string `json:",omitempty"` | 
| Jeongik Cha | c946414 | 2019-01-07 12:07:27 +0900 | [diff] [blame] | 409 |  | 
| Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 410 | 	ApexGlobalMinSdkVersionOverride *string `json:",omitempty"` | 
 | 411 |  | 
| Jeongik Cha | c946414 | 2019-01-07 12:07:27 +0900 | [diff] [blame] | 412 | 	EnforceSystemCertificate          *bool    `json:",omitempty"` | 
| Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 413 | 	EnforceSystemCertificateAllowList []string `json:",omitempty"` | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 414 |  | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 415 | 	ProductHiddenAPIStubs       []string `json:",omitempty"` | 
 | 416 | 	ProductHiddenAPIStubsSystem []string `json:",omitempty"` | 
 | 417 | 	ProductHiddenAPIStubsTest   []string `json:",omitempty"` | 
| Dan Willemsen | 71c7460 | 2019-04-10 12:27:35 -0700 | [diff] [blame] | 418 |  | 
| Inseob Kim | 0866b00 | 2019-04-15 20:21:29 +0900 | [diff] [blame] | 419 | 	ProductPublicSepolicyDirs  []string `json:",omitempty"` | 
 | 420 | 	ProductPrivateSepolicyDirs []string `json:",omitempty"` | 
| Inseob Kim | 0866b00 | 2019-04-15 20:21:29 +0900 | [diff] [blame] | 421 |  | 
| Dan Willemsen | 54879d1 | 2019-04-18 10:08:46 -0700 | [diff] [blame] | 422 | 	TargetFSConfigGen []string `json:",omitempty"` | 
| Colin Cross | 50ddcc4 | 2019-05-16 12:28:22 -0700 | [diff] [blame] | 423 |  | 
| Jeongik Cha | 2cc570d | 2019-10-29 15:44:45 +0900 | [diff] [blame] | 424 | 	EnforceProductPartitionInterface *bool `json:",omitempty"` | 
| Jooyung Han | 3ab2c3e | 2019-12-05 16:27:44 +0900 | [diff] [blame] | 425 |  | 
| JaeMan Park | ff71556 | 2020-10-19 17:25:58 +0900 | [diff] [blame] | 426 | 	EnforceInterPartitionJavaSdkLibrary *bool    `json:",omitempty"` | 
 | 427 | 	InterPartitionJavaLibraryAllowList  []string `json:",omitempty"` | 
 | 428 |  | 
| Yifan Hong | 82db735 | 2020-01-21 16:12:26 -0800 | [diff] [blame] | 429 | 	BoardUsesRecoveryAsBoot *bool `json:",omitempty"` | 
| Yifan Hong | 97365ee | 2020-07-29 09:51:57 -0700 | [diff] [blame] | 430 |  | 
| Yifan Hong | 42bef8d | 2020-08-05 14:36:09 -0700 | [diff] [blame] | 431 | 	BoardKernelBinaries                []string `json:",omitempty"` | 
 | 432 | 	BoardKernelModuleInterfaceVersions []string `json:",omitempty"` | 
| Yifan Hong | dd8dacc | 2020-10-21 15:40:17 -0700 | [diff] [blame] | 433 |  | 
 | 434 | 	BoardMoveRecoveryResourcesToVendorBoot *bool `json:",omitempty"` | 
| Bill Peckham | bae4749 | 2021-01-08 09:34:44 -0800 | [diff] [blame] | 435 |  | 
 | 436 | 	PrebuiltHiddenApiDir *string `json:",omitempty"` | 
| Inseob Kim | 60c32f0 | 2020-12-21 22:53:05 +0900 | [diff] [blame] | 437 |  | 
 | 438 | 	ShippingApiLevel *string `json:",omitempty"` | 
| Inseob Kim | 0cac7b4 | 2021-02-03 18:16:46 +0900 | [diff] [blame] | 439 |  | 
| Cole Faust | ded7960 | 2023-09-05 17:48:11 -0700 | [diff] [blame] | 440 | 	BuildBrokenPluginValidation         []string `json:",omitempty"` | 
 | 441 | 	BuildBrokenClangAsFlags             bool     `json:",omitempty"` | 
 | 442 | 	BuildBrokenClangCFlags              bool     `json:",omitempty"` | 
 | 443 | 	BuildBrokenClangProperty            bool     `json:",omitempty"` | 
 | 444 | 	GenruleSandboxing                   *bool    `json:",omitempty"` | 
 | 445 | 	BuildBrokenEnforceSyspropOwner      bool     `json:",omitempty"` | 
 | 446 | 	BuildBrokenTrebleSyspropNeverallow  bool     `json:",omitempty"` | 
 | 447 | 	BuildBrokenUsesSoongPython2Modules  bool     `json:",omitempty"` | 
 | 448 | 	BuildBrokenVendorPropertyNamespace  bool     `json:",omitempty"` | 
 | 449 | 	BuildBrokenIncorrectPartitionImages bool     `json:",omitempty"` | 
 | 450 | 	BuildBrokenInputDirModules          []string `json:",omitempty"` | 
| Inseob Kim | 67e5add19 | 2021-03-17 18:05:33 +0900 | [diff] [blame] | 451 |  | 
| Jiakai Zhang | 48203e3 | 2023-06-02 23:42:21 +0100 | [diff] [blame] | 452 | 	BuildWarningBadOptionalUsesLibsAllowlist []string `json:",omitempty"` | 
 | 453 |  | 
| Hridya Valsaraju | 5a5c7d5 | 2021-04-02 16:45:24 -0700 | [diff] [blame] | 454 | 	BuildDebugfsRestrictionsEnabled bool `json:",omitempty"` | 
 | 455 |  | 
| Inseob Kim | 67e5add19 | 2021-03-17 18:05:33 +0900 | [diff] [blame] | 456 | 	RequiresInsecureExecmemForSwiftshader bool `json:",omitempty"` | 
 | 457 |  | 
 | 458 | 	SelinuxIgnoreNeverallows bool `json:",omitempty"` | 
 | 459 |  | 
| Devin Moore | c381e10 | 2023-07-06 22:03:58 +0000 | [diff] [blame] | 460 | 	Release_aidl_use_unfrozen *bool `json:",omitempty"` | 
 | 461 |  | 
| Inseob Kim | a10ef27 | 2021-09-15 03:04:53 +0000 | [diff] [blame] | 462 | 	SepolicyFreezeTestExtraDirs         []string `json:",omitempty"` | 
 | 463 | 	SepolicyFreezeTestExtraPrebuiltDirs []string `json:",omitempty"` | 
| Jiyong Park | d163d4d | 2021-10-12 16:47:43 +0900 | [diff] [blame] | 464 |  | 
 | 465 | 	GenerateAidlNdkPlatformBackend bool `json:",omitempty"` | 
| Christopher Ferris | 98f1022 | 2022-07-13 23:16:52 -0700 | [diff] [blame] | 466 |  | 
 | 467 | 	IgnorePrefer32OnDevice bool `json:",omitempty"` | 
| Spandan Das | c576383 | 2022-11-08 18:42:16 +0000 | [diff] [blame] | 468 |  | 
| Sam Delmerico | 98a7329 | 2023-02-21 11:50:29 -0500 | [diff] [blame] | 469 | 	IncludeTags    []string `json:",omitempty"` | 
 | 470 | 	SourceRootDirs []string `json:",omitempty"` | 
| Vinh Tran | 44cb78c | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 471 |  | 
 | 472 | 	AfdoProfiles []string `json:",omitempty"` | 
| Wei Li | c642d68 | 2023-05-04 09:06:06 -0700 | [diff] [blame] | 473 |  | 
 | 474 | 	ProductManufacturer string   `json:",omitempty"` | 
 | 475 | 	ProductBrand        string   `json:",omitempty"` | 
 | 476 | 	BuildVersionTags    []string `json:",omitempty"` | 
| Joe Onorato | fee845a | 2023-05-09 08:14:14 -0700 | [diff] [blame] | 477 |  | 
| Yu Liu | eebb259 | 2023-10-12 20:31:27 -0700 | [diff] [blame] | 478 | 	ReleaseVersion          string   `json:",omitempty"` | 
 | 479 | 	ReleaseAconfigValueSets []string `json:",omitempty"` | 
| Kiyoung Kim | e623c58 | 2023-07-06 16:43:44 +0900 | [diff] [blame] | 480 |  | 
| Zhi Dou | 3f65a41 | 2023-08-10 21:47:40 +0000 | [diff] [blame] | 481 | 	ReleaseAconfigFlagDefaultPermission string `json:",omitempty"` | 
 | 482 |  | 
| Alyssa Ketpreechasawat | 34ab879 | 2023-10-06 07:01:22 +0000 | [diff] [blame] | 483 | 	ReleaseDefaultModuleBuildFromSource *bool `json:",omitempty"` | 
 | 484 |  | 
| Kiyoung Kim | e623c58 | 2023-07-06 16:43:44 +0900 | [diff] [blame] | 485 | 	KeepVndk *bool `json:",omitempty"` | 
| Inseob Kim | 5bac3b6 | 2023-08-25 21:29:46 +0900 | [diff] [blame] | 486 |  | 
 | 487 | 	CheckVendorSeappViolations *bool `json:",omitempty"` | 
| Cole Faust | b4cb0c8 | 2023-09-14 15:16:58 -0700 | [diff] [blame] | 488 |  | 
| Cole Faust | cb193ec | 2023-09-20 16:01:18 -0700 | [diff] [blame] | 489 | 	// PartitionVarsForBazelMigrationOnlyDoNotUse are extra variables that are used to define the | 
 | 490 | 	// partition images. They should not be read from soong modules. | 
 | 491 | 	PartitionVarsForBazelMigrationOnlyDoNotUse PartitionVariables `json:",omitempty"` | 
| Jihoon Kang | cfbc407 | 2023-09-20 01:02:18 +0000 | [diff] [blame] | 492 |  | 
 | 493 | 	NextReleaseHideFlaggedApi *bool `json:",omitempty"` | 
| Jihoon Kang | f3aa322 | 2023-09-26 22:32:08 +0000 | [diff] [blame] | 494 |  | 
 | 495 | 	Release_expose_flagged_api *bool `json:",omitempty"` | 
| Inseob Kim | e4e85d5 | 2023-10-25 23:53:58 +0900 | [diff] [blame] | 496 |  | 
 | 497 | 	BuildFlags map[string]string `json:",omitempty"` | 
| Jihoon Kang | c1b04d6 | 2023-11-16 19:07:04 +0000 | [diff] [blame] | 498 |  | 
 | 499 | 	BuildFromSourceStub *bool `json:",omitempty"` | 
| Cole Faust | cb193ec | 2023-09-20 16:01:18 -0700 | [diff] [blame] | 500 | } | 
 | 501 |  | 
| Cole Faust | 11edf55 | 2023-10-13 11:32:14 -0700 | [diff] [blame] | 502 | type PartitionQualifiedVariablesType struct { | 
 | 503 | 	BuildingImage               bool   `json:",omitempty"` | 
 | 504 | 	BoardErofsCompressor        string `json:",omitempty"` | 
 | 505 | 	BoardErofsCompressHints     string `json:",omitempty"` | 
 | 506 | 	BoardErofsPclusterSize      string `json:",omitempty"` | 
 | 507 | 	BoardExtfsInodeCount        string `json:",omitempty"` | 
 | 508 | 	BoardExtfsRsvPct            string `json:",omitempty"` | 
 | 509 | 	BoardF2fsSloadCompressFlags string `json:",omitempty"` | 
 | 510 | 	BoardFileSystemCompress     string `json:",omitempty"` | 
 | 511 | 	BoardFileSystemType         string `json:",omitempty"` | 
 | 512 | 	BoardJournalSize            string `json:",omitempty"` | 
 | 513 | 	BoardPartitionReservedSize  string `json:",omitempty"` | 
 | 514 | 	BoardPartitionSize          string `json:",omitempty"` | 
 | 515 | 	BoardSquashfsBlockSize      string `json:",omitempty"` | 
 | 516 | 	BoardSquashfsCompressor     string `json:",omitempty"` | 
 | 517 | 	BoardSquashfsCompressorOpt  string `json:",omitempty"` | 
 | 518 | 	BoardSquashfsDisable4kAlign string `json:",omitempty"` | 
 | 519 | 	ProductBaseFsPath           string `json:",omitempty"` | 
 | 520 | 	ProductHeadroom             string `json:",omitempty"` | 
 | 521 | 	ProductVerityPartition      string `json:",omitempty"` | 
 | 522 |  | 
 | 523 | 	BoardAvbAddHashtreeFooterArgs string `json:",omitempty"` | 
 | 524 | 	BoardAvbKeyPath               string `json:",omitempty"` | 
 | 525 | 	BoardAvbAlgorithm             string `json:",omitempty"` | 
 | 526 | 	BoardAvbRollbackIndex         string `json:",omitempty"` | 
 | 527 | 	BoardAvbRollbackIndexLocation string `json:",omitempty"` | 
 | 528 | } | 
 | 529 |  | 
| Cole Faust | cb193ec | 2023-09-20 16:01:18 -0700 | [diff] [blame] | 530 | type PartitionVariables struct { | 
 | 531 | 	ProductDirectory            string `json:",omitempty"` | 
| Cole Faust | 11edf55 | 2023-10-13 11:32:14 -0700 | [diff] [blame] | 532 | 	PartitionQualifiedVariables map[string]PartitionQualifiedVariablesType | 
 | 533 | 	TargetUserimagesUseExt2     bool `json:",omitempty"` | 
 | 534 | 	TargetUserimagesUseExt3     bool `json:",omitempty"` | 
 | 535 | 	TargetUserimagesUseExt4     bool `json:",omitempty"` | 
| Cole Faust | cb193ec | 2023-09-20 16:01:18 -0700 | [diff] [blame] | 536 |  | 
 | 537 | 	TargetUserimagesSparseExtDisabled      bool `json:",omitempty"` | 
 | 538 | 	TargetUserimagesSparseErofsDisabled    bool `json:",omitempty"` | 
 | 539 | 	TargetUserimagesSparseSquashfsDisabled bool `json:",omitempty"` | 
 | 540 | 	TargetUserimagesSparseF2fsDisabled     bool `json:",omitempty"` | 
 | 541 |  | 
| Yi-Yo Chiang | 939fe1a | 2023-11-24 14:58:50 +0800 | [diff] [blame] | 542 | 	BoardErofsCompressor           string `json:",omitempty"` | 
 | 543 | 	BoardErofsCompressorHints      string `json:",omitempty"` | 
 | 544 | 	BoardErofsPclusterSize         string `json:",omitempty"` | 
 | 545 | 	BoardErofsShareDupBlocks       string `json:",omitempty"` | 
 | 546 | 	BoardErofsUseLegacyCompression string `json:",omitempty"` | 
 | 547 | 	BoardExt4ShareDupBlocks        string `json:",omitempty"` | 
 | 548 | 	BoardFlashLogicalBlockSize     string `json:",omitempty"` | 
 | 549 | 	BoardFlashEraseBlockSize       string `json:",omitempty"` | 
 | 550 | 	BoardUsesRecoveryAsBoot        bool   `json:",omitempty"` | 
 | 551 | 	ProductUseDynamicPartitionSize bool   `json:",omitempty"` | 
 | 552 | 	CopyImagesForTargetFilesZip    bool   `json:",omitempty"` | 
| Cole Faust | b505539 | 2023-09-27 13:44:40 -0700 | [diff] [blame] | 553 |  | 
 | 554 | 	BoardAvbEnable bool `json:",omitempty"` | 
| Cole Faust | 11edf55 | 2023-10-13 11:32:14 -0700 | [diff] [blame] | 555 |  | 
 | 556 | 	ProductPackages []string `json:",omitempty"` | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 557 | } | 
 | 558 |  | 
 | 559 | func boolPtr(v bool) *bool { | 
 | 560 | 	return &v | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 561 | } | 
 | 562 |  | 
| Dan Willemsen | 47cf66b | 2015-09-16 16:48:54 -0700 | [diff] [blame] | 563 | func intPtr(v int) *int { | 
 | 564 | 	return &v | 
 | 565 | } | 
 | 566 |  | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 567 | func stringPtr(v string) *string { | 
 | 568 | 	return &v | 
 | 569 | } | 
 | 570 |  | 
| Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 571 | func (v *ProductVariables) SetDefaultConfig() { | 
 | 572 | 	*v = ProductVariables{ | 
| Colin Cross | 2a2e0db | 2020-02-21 16:55:46 -0800 | [diff] [blame] | 573 | 		BuildNumberFile: stringPtr("build_number.txt"), | 
| Dan Willemsen | b6d171b | 2019-04-07 09:41:44 -0700 | [diff] [blame] | 574 |  | 
| Dan Albert | 8c7a994 | 2023-03-27 20:34:01 +0000 | [diff] [blame] | 575 | 		Platform_version_name:                  stringPtr("S"), | 
 | 576 | 		Platform_base_sdk_extension_version:    intPtr(30), | 
 | 577 | 		Platform_sdk_version:                   intPtr(30), | 
 | 578 | 		Platform_sdk_codename:                  stringPtr("S"), | 
 | 579 | 		Platform_sdk_final:                     boolPtr(false), | 
 | 580 | 		Platform_version_active_codenames:      []string{"S"}, | 
 | 581 | 		Platform_version_all_preview_codenames: []string{"S"}, | 
 | 582 | 		Platform_vndk_version:                  stringPtr("S"), | 
| Dan Willemsen | cbf9e82 | 2017-11-13 14:34:56 -0800 | [diff] [blame] | 583 |  | 
| Vilas Bhat | b3d2d22 | 2023-12-04 22:51:20 +0000 | [diff] [blame] | 584 | 		HostArch:                    stringPtr("x86_64"), | 
 | 585 | 		HostSecondaryArch:           stringPtr("x86"), | 
 | 586 | 		DeviceName:                  stringPtr("generic_arm64"), | 
 | 587 | 		DeviceProduct:               stringPtr("aosp_arm-eng"), | 
 | 588 | 		DeviceArch:                  stringPtr("arm64"), | 
 | 589 | 		DeviceArchVariant:           stringPtr("armv8-a"), | 
 | 590 | 		DeviceCpuVariant:            stringPtr("generic"), | 
 | 591 | 		DeviceAbi:                   []string{"arm64-v8a"}, | 
 | 592 | 		DeviceSecondaryArch:         stringPtr("arm"), | 
 | 593 | 		DeviceSecondaryArchVariant:  stringPtr("armv8-a"), | 
 | 594 | 		DeviceSecondaryCpuVariant:   stringPtr("generic"), | 
 | 595 | 		DeviceSecondaryAbi:          []string{"armeabi-v7a", "armeabi"}, | 
 | 596 | 		DeviceMaxPageSizeSupported:  stringPtr("4096"), | 
 | 597 | 		DeviceNoBionicPageSizeMacro: boolPtr(false), | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 598 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 599 | 		AAPTConfig:          []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"}, | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 600 | 		AAPTPreferredConfig: stringPtr("xhdpi"), | 
 | 601 | 		AAPTCharacteristics: stringPtr("nosdcard"), | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 602 | 		AAPTPrebuiltDPI:     []string{"xhdpi", "xxhdpi"}, | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 603 |  | 
| Evgenii Stepanov | 19ff3c9 | 2020-04-29 14:57:30 -0700 | [diff] [blame] | 604 | 		Malloc_not_svelte:            boolPtr(true), | 
| Steven Moreland | d134201 | 2020-07-30 20:38:49 +0000 | [diff] [blame] | 605 | 		Malloc_zero_contents:         boolPtr(true), | 
| Evgenii Stepanov | 19ff3c9 | 2020-04-29 14:57:30 -0700 | [diff] [blame] | 606 | 		Malloc_pattern_fill_contents: boolPtr(false), | 
 | 607 | 		Safestack:                    boolPtr(false), | 
| Dennis Shen | e2ed70c | 2023-01-11 14:15:43 +0000 | [diff] [blame] | 608 | 		TrimmedApex:                  boolPtr(false), | 
| Jihoon Kang | cbcad7c | 2023-06-01 22:31:52 +0000 | [diff] [blame] | 609 | 		Build_from_text_stub:         boolPtr(false), | 
| Lukacs T. Berki | 720b396 | 2021-03-17 13:34:30 +0100 | [diff] [blame] | 610 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 611 | 		BootJars:     ConfiguredJarList{apexes: []string{}, jars: []string{}}, | 
 | 612 | 		ApexBootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}}, | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 613 | 	} | 
| Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 614 |  | 
 | 615 | 	if runtime.GOOS == "linux" { | 
 | 616 | 		v.CrossHost = stringPtr("windows") | 
 | 617 | 		v.CrossHostArch = stringPtr("x86") | 
| Dan Willemsen | 07cd051 | 2016-02-03 23:16:33 -0800 | [diff] [blame] | 618 | 		v.CrossHostSecondaryArch = stringPtr("x86_64") | 
| Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 619 | 	} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 620 | } | 
 | 621 |  | 
| Joe Onorato | 3fefc23 | 2023-12-04 17:35:15 +0000 | [diff] [blame] | 622 | func (this *ProductVariables) GetBuildFlagBool(flag string) bool { | 
 | 623 | 	val, ok := this.BuildFlags[flag] | 
 | 624 | 	if !ok { | 
 | 625 | 		return false | 
 | 626 | 	} | 
 | 627 | 	return val == "true" | 
 | 628 | } | 
 | 629 |  | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 630 | // ProductConfigContext requires the access to the Module to get product config properties. | 
 | 631 | type ProductConfigContext interface { | 
 | 632 | 	Module() Module | 
 | 633 | } | 
 | 634 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 635 | // ProductConfigOrSoongConfigProperty represents either a soong config variable + its value | 
 | 636 | // or a product config variable. You can get both a ConfigurationAxis and a SelectKey from it | 
 | 637 | // for use in bazel attributes. ProductVariableProperties() will return a map from properties -> | 
 | 638 | // this interface -> property structs for use in bp2build converters | 
 | 639 | type ProductConfigOrSoongConfigProperty interface { | 
 | 640 | 	// Name of the product variable or soong config variable | 
 | 641 | 	Name() string | 
 | 642 | 	// AlwaysEmit returns true for soong config variables but false for product variables. This | 
 | 643 | 	// is intended to indicate if we need to always emit empty lists in the select statements. | 
 | 644 | 	AlwaysEmit() bool | 
 | 645 | 	// ConfigurationAxis returns the bazel.ConfigurationAxis that represents this variable. The | 
 | 646 | 	// configuration axis will change depending on the variable and whether it's arch/os variant | 
 | 647 | 	// as well. | 
 | 648 | 	ConfigurationAxis() bazel.ConfigurationAxis | 
 | 649 | 	// SelectKey returns a string that represents the key of a select branch, however, it is not | 
 | 650 | 	// actually the real label written out to the build file. | 
 | 651 | 	// this.ConfigurationAxis().SelectKey(this.SelectKey()) will give the actual label. | 
 | 652 | 	SelectKey() string | 
 | 653 | } | 
 | 654 |  | 
 | 655 | // ProductConfigProperty represents a product config variable, and if it is arch-variant or not. | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 656 | type ProductConfigProperty struct { | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 657 | 	// The name of the product variable, e.g. "safestack", "malloc_not_svelte", | 
 | 658 | 	// "board" | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 659 | 	name string | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 660 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 661 | 	arch string | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 662 | } | 
 | 663 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 664 | func (p ProductConfigProperty) Name() string { | 
 | 665 | 	return p.name | 
| Jingwen Chen | 58ff680 | 2021-11-17 12:14:41 +0000 | [diff] [blame] | 666 | } | 
 | 667 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 668 | func (p ProductConfigProperty) AlwaysEmit() bool { | 
 | 669 | 	return false | 
 | 670 | } | 
 | 671 |  | 
 | 672 | func (p ProductConfigProperty) ConfigurationAxis() bazel.ConfigurationAxis { | 
 | 673 | 	return bazel.ProductVariableConfigurationAxis(p.arch != "", p.name+"__"+p.arch) | 
 | 674 | } | 
 | 675 |  | 
 | 676 | func (p ProductConfigProperty) SelectKey() string { | 
 | 677 | 	if p.arch == "" { | 
 | 678 | 		return strings.ToLower(p.name) | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 679 | 	} else { | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 680 | 		return strings.ToLower(p.name + "-" + p.arch) | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 681 | 	} | 
 | 682 | } | 
 | 683 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 684 | // SoongConfigProperty represents a soong config variable, its value if it's a string variable, | 
 | 685 | // and if it's dependent on the OS or not | 
 | 686 | type SoongConfigProperty struct { | 
 | 687 | 	name      string | 
 | 688 | 	namespace string | 
 | 689 | 	// Can be an empty string for bool/value soong config variables | 
 | 690 | 	value string | 
 | 691 | 	// If there is a target: field inside a soong config property struct, the os that it selects | 
 | 692 | 	// on will be represented here. | 
 | 693 | 	os string | 
 | 694 | } | 
 | 695 |  | 
 | 696 | func (p SoongConfigProperty) Name() string { | 
 | 697 | 	return p.name | 
 | 698 | } | 
 | 699 |  | 
 | 700 | func (p SoongConfigProperty) AlwaysEmit() bool { | 
 | 701 | 	return true | 
 | 702 | } | 
 | 703 |  | 
 | 704 | func (p SoongConfigProperty) ConfigurationAxis() bazel.ConfigurationAxis { | 
 | 705 | 	return bazel.ProductVariableConfigurationAxis(false, p.namespace+"__"+p.name+"__"+p.os) | 
 | 706 | } | 
 | 707 |  | 
| Jingwen Chen | 25825ca | 2021-11-15 12:28:43 +0000 | [diff] [blame] | 708 | // SelectKey returns the literal string that represents this variable in a BUILD | 
 | 709 | // select statement. | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 710 | func (p SoongConfigProperty) SelectKey() string { | 
 | 711 | 	// p.value being conditions_default can happen with or without a desired os. When not using | 
 | 712 | 	// an os, we want to emit literally just //conditions:default in the select statement, but | 
 | 713 | 	// when using an os, we want to emit namespace__name__conditions_default__os, so that | 
 | 714 | 	// the branch is only taken if the variable is not set, and we're on the desired os. | 
 | 715 | 	// ConfigurationAxis#SelectKey will map the conditions_default result of this function to | 
 | 716 | 	// //conditions:default. | 
 | 717 | 	if p.value == bazel.ConditionsDefaultConfigKey && p.os == "" { | 
| Jingwen Chen | 25825ca | 2021-11-15 12:28:43 +0000 | [diff] [blame] | 718 | 		return bazel.ConditionsDefaultConfigKey | 
 | 719 | 	} | 
 | 720 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 721 | 	parts := []string{p.namespace, p.name} | 
 | 722 | 	if p.value != "" && p.value != bazel.ConditionsDefaultSelectKey { | 
 | 723 | 		parts = append(parts, p.value) | 
 | 724 | 	} | 
 | 725 | 	if p.os != "" { | 
 | 726 | 		parts = append(parts, p.os) | 
| Jingwen Chen | 25825ca | 2021-11-15 12:28:43 +0000 | [diff] [blame] | 727 | 	} | 
| Sam Delmerico | 0e33c9d | 2022-01-07 20:39:21 +0000 | [diff] [blame] | 728 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 729 | 	// e.g. acme__feature1, android__board__soc_a, my_namespace__my_variables__my_value__my_os | 
 | 730 | 	return strings.ToLower(strings.Join(parts, "__")) | 
| Jingwen Chen | 25825ca | 2021-11-15 12:28:43 +0000 | [diff] [blame] | 731 | } | 
 | 732 |  | 
 | 733 | // ProductConfigProperties is a map of maps to group property values according | 
 | 734 | // their property name and the product config variable they're set under. | 
 | 735 | // | 
 | 736 | // The outer map key is the name of the property, like "cflags". | 
 | 737 | // | 
 | 738 | // The inner map key is a ProductConfigProperty, which is a struct of product | 
 | 739 | // variable name, namespace, and the "full configuration" of the product | 
 | 740 | // variable. | 
 | 741 | // | 
 | 742 | // e.g. product variable name: board, namespace: acme, full config: vendor_chip_foo | 
 | 743 | // | 
 | 744 | // The value of the map is the interface{} representing the value of the | 
 | 745 | // property, like ["-DDEFINES"] for cflags. | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 746 | type ProductConfigProperties map[string]map[ProductConfigOrSoongConfigProperty]interface{} | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 747 |  | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 748 | func (p *ProductConfigProperties) AddProductConfigProperty( | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 749 | 	propertyName, productVariableName, arch string, propertyValue interface{}) { | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 750 |  | 
| Jingwen Chen | 25825ca | 2021-11-15 12:28:43 +0000 | [diff] [blame] | 751 | 	productConfigProp := ProductConfigProperty{ | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 752 | 		name: productVariableName, // e.g. size, feature1, feature2, FEATURE3, board | 
 | 753 | 		arch: arch,                // e.g. "", x86, arm64 | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 754 | 	} | 
| Jingwen Chen | 25825ca | 2021-11-15 12:28:43 +0000 | [diff] [blame] | 755 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 756 | 	p.AddEitherProperty(propertyName, productConfigProp, propertyValue) | 
 | 757 | } | 
 | 758 |  | 
 | 759 | func (p *ProductConfigProperties) AddSoongConfigProperty( | 
 | 760 | 	propertyName, namespace, variableName, value, os string, propertyValue interface{}) { | 
 | 761 |  | 
 | 762 | 	soongConfigProp := SoongConfigProperty{ | 
 | 763 | 		namespace: namespace, | 
 | 764 | 		name:      variableName, // e.g. size, feature1, feature2, FEATURE3, board | 
 | 765 | 		value:     value, | 
 | 766 | 		os:        os, // e.g. android, linux_x86 | 
 | 767 | 	} | 
 | 768 |  | 
 | 769 | 	p.AddEitherProperty(propertyName, soongConfigProp, propertyValue) | 
 | 770 | } | 
 | 771 |  | 
 | 772 | func (p *ProductConfigProperties) AddEitherProperty( | 
 | 773 | 	propertyName string, key ProductConfigOrSoongConfigProperty, propertyValue interface{}) { | 
 | 774 | 	if (*p)[propertyName] == nil { | 
 | 775 | 		(*p)[propertyName] = make(map[ProductConfigOrSoongConfigProperty]interface{}) | 
 | 776 | 	} | 
 | 777 |  | 
 | 778 | 	if existing, ok := (*p)[propertyName][key]; ok { | 
| Jingwen Chen | 84817de | 2021-11-17 10:57:35 +0000 | [diff] [blame] | 779 | 		switch dst := existing.(type) { | 
 | 780 | 		case []string: | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 781 | 			src, ok := propertyValue.([]string) | 
 | 782 | 			if !ok { | 
 | 783 | 				panic("Conflicting types") | 
| Jingwen Chen | 84817de | 2021-11-17 10:57:35 +0000 | [diff] [blame] | 784 | 			} | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 785 | 			dst = append(dst, src...) | 
 | 786 | 			(*p)[propertyName][key] = dst | 
| Jingwen Chen | 84817de | 2021-11-17 10:57:35 +0000 | [diff] [blame] | 787 | 		default: | 
| Spandan Das | 7b26e0f | 2023-07-28 01:31:15 +0000 | [diff] [blame] | 788 | 			if existing != propertyValue { | 
 | 789 | 				panic(fmt.Errorf("TODO: handle merging value %#v", existing)) | 
 | 790 | 			} | 
| Jingwen Chen | 84817de | 2021-11-17 10:57:35 +0000 | [diff] [blame] | 791 | 		} | 
 | 792 | 	} else { | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 793 | 		(*p)[propertyName][key] = propertyValue | 
| Jingwen Chen | 84817de | 2021-11-17 10:57:35 +0000 | [diff] [blame] | 794 | 	} | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 795 | } | 
 | 796 |  | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 797 | // maybeExtractConfigVarProp attempts to read this value as a config var struct | 
 | 798 | // wrapped by interfaces and ptrs. If it's not the right type, the second return | 
 | 799 | // value is false. | 
 | 800 | func maybeExtractConfigVarProp(v reflect.Value) (reflect.Value, bool) { | 
 | 801 | 	if v.Kind() == reflect.Interface { | 
 | 802 | 		// The conditions_default value can be either | 
 | 803 | 		// 1) an ptr to an interface of a struct (bool config variables and product variables) | 
 | 804 | 		// 2) an interface of 1) (config variables with nested structs, like string vars) | 
 | 805 | 		v = v.Elem() | 
 | 806 | 	} | 
 | 807 | 	if v.Kind() != reflect.Ptr { | 
 | 808 | 		return v, false | 
 | 809 | 	} | 
 | 810 | 	v = reflect.Indirect(v) | 
 | 811 | 	if v.Kind() == reflect.Interface { | 
 | 812 | 		// Extract the struct from the interface | 
 | 813 | 		v = v.Elem() | 
 | 814 | 	} | 
 | 815 |  | 
 | 816 | 	if !v.IsValid() { | 
 | 817 | 		return v, false | 
 | 818 | 	} | 
 | 819 |  | 
 | 820 | 	if v.Kind() != reflect.Struct { | 
 | 821 | 		return v, false | 
 | 822 | 	} | 
 | 823 | 	return v, true | 
 | 824 | } | 
 | 825 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 826 | func (productConfigProperties *ProductConfigProperties) AddProductConfigProperties(variableValues reflect.Value, arch string) { | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 827 | 	// Example of product_variables: | 
 | 828 | 	// | 
 | 829 | 	// product_variables: { | 
 | 830 | 	//     malloc_not_svelte: { | 
 | 831 | 	//         shared_libs: ["malloc_not_svelte_shared_lib"], | 
 | 832 | 	//         whole_static_libs: ["malloc_not_svelte_whole_static_lib"], | 
 | 833 | 	//         exclude_static_libs: [ | 
 | 834 | 	//             "malloc_not_svelte_static_lib_excludes", | 
 | 835 | 	//             "malloc_not_svelte_whole_static_lib_excludes", | 
 | 836 | 	//         ], | 
 | 837 | 	//     }, | 
 | 838 | 	// }, | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 839 |  | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 840 | 	for i := 0; i < variableValues.NumField(); i++ { | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 841 | 		// e.g. Platform_sdk_version, Unbundled_build, Malloc_not_svelte, etc. | 
 | 842 | 		productVariableName := variableValues.Type().Field(i).Name | 
 | 843 |  | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 844 | 		variableValue := variableValues.Field(i) | 
 | 845 | 		// Check if any properties were set for the module | 
 | 846 | 		if variableValue.IsZero() { | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 847 | 			// e.g. feature1: {}, malloc_not_svelte: {} | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 848 | 			continue | 
 | 849 | 		} | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 850 |  | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 851 | 		for j := 0; j < variableValue.NumField(); j++ { | 
 | 852 | 			property := variableValue.Field(j) | 
| Liz Kammer | f3963f8 | 2022-12-21 14:47:18 -0500 | [diff] [blame] | 853 | 			// e.g. Asflags, Cflags, Enabled, etc. | 
 | 854 | 			propertyName := variableValue.Type().Field(j).Name | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 855 | 			if property.Kind() != reflect.Interface { | 
 | 856 | 				productConfigProperties.AddProductConfigProperty(propertyName, productVariableName, arch, property.Interface()) | 
 | 857 | 			} | 
 | 858 | 		} | 
 | 859 | 	} | 
 | 860 |  | 
 | 861 | } | 
 | 862 |  | 
| Liz Kammer | 9e2a5a7 | 2023-09-19 08:41:14 -0400 | [diff] [blame] | 863 | func (productConfigProperties *ProductConfigProperties) AddSoongConfigProperties(namespace string, soongConfigVariablesStruct reflect.Value) error { | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 864 | 	// | 
 | 865 | 	// Example of soong_config_variables: | 
 | 866 | 	// | 
 | 867 | 	// soong_config_variables: { | 
 | 868 | 	//      feature1: { | 
 | 869 | 	//          conditions_default: { | 
 | 870 | 	//               ... | 
 | 871 | 	//          }, | 
 | 872 | 	//          cflags: ... | 
 | 873 | 	//      }, | 
 | 874 | 	//      feature2: { | 
 | 875 | 	//          cflags: ... | 
 | 876 | 	//          conditions_default: { | 
 | 877 | 	//               ... | 
 | 878 | 	//          }, | 
 | 879 | 	//      }, | 
 | 880 | 	//      board: { | 
 | 881 | 	//         soc_a: { | 
 | 882 | 	//             ... | 
 | 883 | 	//         }, | 
 | 884 | 	//         soc_b: { | 
 | 885 | 	//             ... | 
 | 886 | 	//         }, | 
 | 887 | 	//         soc_c: {}, | 
 | 888 | 	//         conditions_default: { | 
 | 889 | 	//              ... | 
 | 890 | 	//         }, | 
 | 891 | 	//      }, | 
 | 892 | 	// } | 
 | 893 | 	for i := 0; i < soongConfigVariablesStruct.NumField(); i++ { | 
 | 894 | 		// e.g. feature1, feature2, board | 
 | 895 | 		variableName := soongConfigVariablesStruct.Type().Field(i).Name | 
 | 896 | 		variableStruct := soongConfigVariablesStruct.Field(i) | 
 | 897 | 		// Check if any properties were set for the module | 
 | 898 | 		if variableStruct.IsZero() { | 
 | 899 | 			// e.g. feature1: {} | 
 | 900 | 			continue | 
 | 901 | 		} | 
 | 902 |  | 
 | 903 | 		// Unlike product variables, config variables require a few more | 
 | 904 | 		// indirections to extract the struct from the reflect.Value. | 
 | 905 | 		if v, ok := maybeExtractConfigVarProp(variableStruct); ok { | 
 | 906 | 			variableStruct = v | 
| liulvping | 4d11d10 | 2023-05-24 10:27:44 +0800 | [diff] [blame] | 907 | 		} else if !v.IsValid() { | 
 | 908 | 			// Skip invalid variables which may not used, else leads to panic | 
 | 909 | 			continue | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 910 | 		} | 
 | 911 |  | 
 | 912 | 		for j := 0; j < variableStruct.NumField(); j++ { | 
 | 913 | 			propertyOrStruct := variableStruct.Field(j) | 
 | 914 | 			// propertyOrValueName can either be: | 
 | 915 | 			//  - A property, like: Asflags, Cflags, Enabled, etc. | 
 | 916 | 			//  - A soong config string variable's value, like soc_a, soc_b, soc_c in the example above | 
 | 917 | 			//  - "conditions_default" | 
 | 918 | 			propertyOrValueName := variableStruct.Type().Field(j).Name | 
| Liz Kammer | f3963f8 | 2022-12-21 14:47:18 -0500 | [diff] [blame] | 919 |  | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 920 | 			// If the property wasn't set, no need to pass it along | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 921 | 			if propertyOrStruct.IsZero() { | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 922 | 				continue | 
 | 923 | 			} | 
 | 924 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 925 | 			if v, ok := maybeExtractConfigVarProp(propertyOrStruct); ok { | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 926 | 				// The field is a struct, which is used by: | 
 | 927 | 				// 1) soong_config_string_variables | 
 | 928 | 				// | 
 | 929 | 				// soc_a: { | 
 | 930 | 				//     cflags: ..., | 
 | 931 | 				// } | 
 | 932 | 				// | 
 | 933 | 				// soc_b: { | 
 | 934 | 				//     cflags: ..., | 
 | 935 | 				// } | 
 | 936 | 				// | 
 | 937 | 				// 2) conditions_default structs for all soong config variable types. | 
 | 938 | 				// | 
 | 939 | 				// conditions_default: { | 
 | 940 | 				//     cflags: ..., | 
 | 941 | 				//     static_libs: ... | 
 | 942 | 				// } | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 943 | 				// | 
 | 944 | 				// This means that propertyOrValueName is either conditions_default, or a soong | 
 | 945 | 				// config string variable's value. | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 946 | 				field := v | 
| Liz Kammer | f3963f8 | 2022-12-21 14:47:18 -0500 | [diff] [blame] | 947 | 				// Iterate over fields of this struct prop. | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 948 | 				for k := 0; k < field.NumField(); k++ { | 
| Liz Kammer | f3963f8 | 2022-12-21 14:47:18 -0500 | [diff] [blame] | 949 | 					// For product variables, zero values are irrelevant; however, for soong config variables, | 
 | 950 | 					// empty values are relevant because there can also be a conditions default which is not | 
 | 951 | 					// applied for empty variables. | 
 | 952 | 					if field.Field(k).IsZero() && namespace == "" { | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 953 | 						continue | 
 | 954 | 					} | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 955 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 956 | 					propertyName := field.Type().Field(k).Name | 
 | 957 | 					if propertyName == "Target" { | 
 | 958 | 						productConfigProperties.AddSoongConfigPropertiesFromTargetStruct(namespace, variableName, proptools.PropertyNameForField(propertyOrValueName), field.Field(k)) | 
 | 959 | 					} else if propertyName == "Arch" || propertyName == "Multilib" { | 
| Liz Kammer | 9e2a5a7 | 2023-09-19 08:41:14 -0400 | [diff] [blame] | 960 | 						return fmt.Errorf("Arch/Multilib are not currently supported in soong config variable structs") | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 961 | 					} else { | 
 | 962 | 						productConfigProperties.AddSoongConfigProperty(propertyName, namespace, variableName, proptools.PropertyNameForField(propertyOrValueName), "", field.Field(k).Interface()) | 
 | 963 | 					} | 
| Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 964 | 				} | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 965 | 			} else if propertyOrStruct.Kind() != reflect.Interface { | 
| Jingwen Chen | 58ff680 | 2021-11-17 12:14:41 +0000 | [diff] [blame] | 966 | 				// If not an interface, then this is not a conditions_default or | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 967 | 				// a struct prop. That is, this is a bool/value config variable. | 
 | 968 | 				if propertyOrValueName == "Target" { | 
 | 969 | 					productConfigProperties.AddSoongConfigPropertiesFromTargetStruct(namespace, variableName, "", propertyOrStruct) | 
 | 970 | 				} else if propertyOrValueName == "Arch" || propertyOrValueName == "Multilib" { | 
| Liz Kammer | 9e2a5a7 | 2023-09-19 08:41:14 -0400 | [diff] [blame] | 971 | 					return fmt.Errorf("Arch/Multilib are not currently supported in soong config variable structs") | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 972 | 				} else { | 
 | 973 | 					productConfigProperties.AddSoongConfigProperty(propertyOrValueName, namespace, variableName, "", "", propertyOrStruct.Interface()) | 
 | 974 | 				} | 
| Liz Kammer | 47535c5 | 2021-06-02 16:02:22 -0400 | [diff] [blame] | 975 | 			} | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 976 | 		} | 
 | 977 | 	} | 
| Liz Kammer | 9e2a5a7 | 2023-09-19 08:41:14 -0400 | [diff] [blame] | 978 | 	return nil | 
| Liz Kammer | a060c45 | 2021-03-24 10:14:47 -0400 | [diff] [blame] | 979 | } | 
 | 980 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 981 | func (productConfigProperties *ProductConfigProperties) AddSoongConfigPropertiesFromTargetStruct(namespace, soongConfigVariableName string, soongConfigVariableValue string, targetStruct reflect.Value) { | 
 | 982 | 	// targetStruct will be a struct with fields like "android", "host", "arm", "x86", | 
 | 983 | 	// "android_arm", etc. The values of each of those fields will be a regular property struct. | 
 | 984 | 	for i := 0; i < targetStruct.NumField(); i++ { | 
 | 985 | 		targetFieldName := targetStruct.Type().Field(i).Name | 
 | 986 | 		archOrOsSpecificStruct := targetStruct.Field(i) | 
 | 987 | 		for j := 0; j < archOrOsSpecificStruct.NumField(); j++ { | 
 | 988 | 			property := archOrOsSpecificStruct.Field(j) | 
 | 989 | 			// e.g. Asflags, Cflags, Enabled, etc. | 
 | 990 | 			propertyName := archOrOsSpecificStruct.Type().Field(j).Name | 
| Jingwen Chen | 84817de | 2021-11-17 10:57:35 +0000 | [diff] [blame] | 991 |  | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 992 | 			if targetFieldName == "Android" { | 
 | 993 | 				productConfigProperties.AddSoongConfigProperty(propertyName, namespace, soongConfigVariableName, soongConfigVariableValue, "android", property.Interface()) | 
 | 994 | 			} else if targetFieldName == "Host" { | 
 | 995 | 				for _, os := range osTypeList { | 
 | 996 | 					if os.Class == Host { | 
 | 997 | 						productConfigProperties.AddSoongConfigProperty(propertyName, namespace, soongConfigVariableName, soongConfigVariableValue, os.Name, property.Interface()) | 
 | 998 | 					} | 
 | 999 | 				} | 
| Spandan Das | 474d43b | 2023-07-27 23:01:06 +0000 | [diff] [blame] | 1000 | 			} else if !archOrOsSpecificStruct.IsZero() { | 
| Cole Faust | 150f9a5 | 2023-04-26 10:52:24 -0700 | [diff] [blame] | 1001 | 				// One problem with supporting additional fields is that if multiple branches of | 
 | 1002 | 				// "target" overlap, we don't want them to be in the same select statement (aka | 
 | 1003 | 				// configuration axis). "android" and "host" are disjoint, so it's ok that we only | 
 | 1004 | 				// have 2 axes right now. (soongConfigVariables and soongConfigVariablesPlusOs) | 
 | 1005 | 				panic("TODO: support other target types in soong config variable structs: " + targetFieldName) | 
 | 1006 | 			} | 
 | 1007 | 		} | 
 | 1008 | 	} | 
| Jingwen Chen | 84817de | 2021-11-17 10:57:35 +0000 | [diff] [blame] | 1009 | } | 
 | 1010 |  | 
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 1011 | func VariableMutator(mctx BottomUpMutatorContext) { | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1012 | 	var module Module | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1013 | 	var ok bool | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1014 | 	if module, ok = mctx.Module().(Module); !ok { | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1015 | 		return | 
 | 1016 | 	} | 
 | 1017 |  | 
 | 1018 | 	// TODO: depend on config variable, create variants, propagate variants up tree | 
 | 1019 | 	a := module.base() | 
| Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 1020 |  | 
 | 1021 | 	if a.variableProperties == nil { | 
 | 1022 | 		return | 
 | 1023 | 	} | 
 | 1024 |  | 
 | 1025 | 	variableValues := reflect.ValueOf(a.variableProperties).Elem().FieldByName("Product_variables") | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1026 |  | 
| Colin Cross | 0cec312 | 2021-01-20 11:27:32 -0800 | [diff] [blame] | 1027 | 	productVariables := reflect.ValueOf(mctx.Config().productVariables) | 
 | 1028 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1029 | 	for i := 0; i < variableValues.NumField(); i++ { | 
 | 1030 | 		variableValue := variableValues.Field(i) | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 1031 | 		name := variableValues.Type().Field(i).Name | 
 | 1032 | 		property := "product_variables." + proptools.PropertyNameForField(name) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1033 |  | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 1034 | 		// Check that the variable was set for the product | 
| Colin Cross | 0cec312 | 2021-01-20 11:27:32 -0800 | [diff] [blame] | 1035 | 		val := productVariables.FieldByName(name) | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 1036 | 		if !val.IsValid() || val.Kind() != reflect.Ptr || val.IsNil() { | 
 | 1037 | 			continue | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1038 | 		} | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 1039 |  | 
 | 1040 | 		val = val.Elem() | 
 | 1041 |  | 
 | 1042 | 		// For bools, check that the value is true | 
 | 1043 | 		if val.Kind() == reflect.Bool && val.Bool() == false { | 
 | 1044 | 			continue | 
 | 1045 | 		} | 
 | 1046 |  | 
 | 1047 | 		// Check if any properties were set for the module | 
| Colin Cross | 6961a49 | 2020-02-06 16:57:45 -0800 | [diff] [blame] | 1048 | 		if variableValue.IsZero() { | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 1049 | 			continue | 
 | 1050 | 		} | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 1051 | 		a.setVariableProperties(mctx, property, variableValue, val.Interface()) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1052 | 	} | 
 | 1053 | } | 
 | 1054 |  | 
| Colin Cross | 4157e88 | 2019-06-06 16:57:04 -0700 | [diff] [blame] | 1055 | func (m *ModuleBase) setVariableProperties(ctx BottomUpMutatorContext, | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1056 | 	prefix string, productVariablePropertyValue reflect.Value, variableValue interface{}) { | 
 | 1057 |  | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1058 | 	printfIntoProperties(ctx, prefix, productVariablePropertyValue, variableValue) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1059 |  | 
| Usta | 851a327 | 2022-01-05 23:42:33 -0500 | [diff] [blame] | 1060 | 	err := proptools.AppendMatchingProperties(m.GetProperties(), | 
| Colin Cross | 06a931b | 2015-10-28 17:23:31 -0700 | [diff] [blame] | 1061 | 		productVariablePropertyValue.Addr().Interface(), nil) | 
 | 1062 | 	if err != nil { | 
 | 1063 | 		if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { | 
 | 1064 | 			ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) | 
 | 1065 | 		} else { | 
 | 1066 | 			panic(err) | 
 | 1067 | 		} | 
 | 1068 | 	} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1069 | } | 
 | 1070 |  | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1071 | func printfIntoPropertiesError(ctx BottomUpMutatorContext, prefix string, | 
 | 1072 | 	productVariablePropertyValue reflect.Value, i int, err error) { | 
 | 1073 |  | 
 | 1074 | 	field := productVariablePropertyValue.Type().Field(i).Name | 
 | 1075 | 	property := prefix + "." + proptools.PropertyNameForField(field) | 
 | 1076 | 	ctx.PropertyErrorf(property, "%s", err) | 
 | 1077 | } | 
 | 1078 |  | 
 | 1079 | func printfIntoProperties(ctx BottomUpMutatorContext, prefix string, | 
 | 1080 | 	productVariablePropertyValue reflect.Value, variableValue interface{}) { | 
 | 1081 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1082 | 	for i := 0; i < productVariablePropertyValue.NumField(); i++ { | 
 | 1083 | 		propertyValue := productVariablePropertyValue.Field(i) | 
| Colin Cross | dd0dbe6 | 2015-12-02 15:24:38 -0800 | [diff] [blame] | 1084 | 		kind := propertyValue.Kind() | 
 | 1085 | 		if kind == reflect.Ptr { | 
 | 1086 | 			if propertyValue.IsNil() { | 
 | 1087 | 				continue | 
 | 1088 | 			} | 
 | 1089 | 			propertyValue = propertyValue.Elem() | 
 | 1090 | 		} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1091 | 		switch propertyValue.Kind() { | 
 | 1092 | 		case reflect.String: | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1093 | 			err := printfIntoProperty(propertyValue, variableValue) | 
 | 1094 | 			if err != nil { | 
 | 1095 | 				printfIntoPropertiesError(ctx, prefix, productVariablePropertyValue, i, err) | 
 | 1096 | 			} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1097 | 		case reflect.Slice: | 
 | 1098 | 			for j := 0; j < propertyValue.Len(); j++ { | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1099 | 				err := printfIntoProperty(propertyValue.Index(j), variableValue) | 
 | 1100 | 				if err != nil { | 
 | 1101 | 					printfIntoPropertiesError(ctx, prefix, productVariablePropertyValue, i, err) | 
 | 1102 | 				} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1103 | 			} | 
| Colin Cross | dd0dbe6 | 2015-12-02 15:24:38 -0800 | [diff] [blame] | 1104 | 		case reflect.Bool: | 
 | 1105 | 			// Nothing | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1106 | 		case reflect.Struct: | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1107 | 			printfIntoProperties(ctx, prefix, propertyValue, variableValue) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1108 | 		default: | 
 | 1109 | 			panic(fmt.Errorf("unsupported field kind %q", propertyValue.Kind())) | 
 | 1110 | 		} | 
 | 1111 | 	} | 
 | 1112 | } | 
 | 1113 |  | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1114 | func printfIntoProperty(propertyValue reflect.Value, variableValue interface{}) error { | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1115 | 	s := propertyValue.String() | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1116 |  | 
 | 1117 | 	count := strings.Count(s, "%") | 
 | 1118 | 	if count == 0 { | 
 | 1119 | 		return nil | 
 | 1120 | 	} | 
 | 1121 |  | 
 | 1122 | 	if count > 1 { | 
 | 1123 | 		return fmt.Errorf("product variable properties only support a single '%%'") | 
 | 1124 | 	} | 
 | 1125 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1126 | 	if strings.Contains(s, "%d") { | 
 | 1127 | 		switch v := variableValue.(type) { | 
 | 1128 | 		case int: | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1129 | 			// Nothing | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1130 | 		case bool: | 
 | 1131 | 			if v { | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1132 | 				variableValue = 1 | 
 | 1133 | 			} else { | 
 | 1134 | 				variableValue = 0 | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1135 | 			} | 
 | 1136 | 		default: | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1137 | 			return fmt.Errorf("unsupported type %T for %%d", variableValue) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1138 | 		} | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1139 | 	} else if strings.Contains(s, "%s") { | 
 | 1140 | 		switch variableValue.(type) { | 
 | 1141 | 		case string: | 
 | 1142 | 			// Nothing | 
 | 1143 | 		default: | 
 | 1144 | 			return fmt.Errorf("unsupported type %T for %%s", variableValue) | 
 | 1145 | 		} | 
 | 1146 | 	} else { | 
 | 1147 | 		return fmt.Errorf("unsupported %% in product variable property") | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1148 | 	} | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 1149 |  | 
 | 1150 | 	propertyValue.Set(reflect.ValueOf(fmt.Sprintf(s, variableValue))) | 
 | 1151 |  | 
 | 1152 | 	return nil | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 1153 | } | 
| Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 1154 |  | 
 | 1155 | var variablePropTypeMap OncePer | 
 | 1156 |  | 
 | 1157 | // sliceToTypeArray takes a slice of property structs and returns a reflection created array containing the | 
 | 1158 | // reflect.Types of each property struct.  The result can be used as a key in a map. | 
 | 1159 | func sliceToTypeArray(s []interface{}) interface{} { | 
 | 1160 | 	// Create an array using reflection whose length is the length of the input slice | 
 | 1161 | 	ret := reflect.New(reflect.ArrayOf(len(s), reflect.TypeOf(reflect.TypeOf(0)))).Elem() | 
 | 1162 | 	for i, e := range s { | 
 | 1163 | 		ret.Index(i).Set(reflect.ValueOf(reflect.TypeOf(e))) | 
 | 1164 | 	} | 
 | 1165 | 	return ret.Interface() | 
 | 1166 | } | 
 | 1167 |  | 
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 1168 | func initProductVariableModule(m Module) { | 
 | 1169 | 	base := m.base() | 
 | 1170 |  | 
 | 1171 | 	// Allow tests to override the default product variables | 
 | 1172 | 	if base.variableProperties == nil { | 
 | 1173 | 		base.variableProperties = defaultProductVariables | 
 | 1174 | 	} | 
 | 1175 | 	// Filter the product variables properties to the ones that exist on this module | 
 | 1176 | 	base.variableProperties = createVariableProperties(m.GetProperties(), base.variableProperties) | 
 | 1177 | 	if base.variableProperties != nil { | 
 | 1178 | 		m.AddProperties(base.variableProperties) | 
 | 1179 | 	} | 
 | 1180 | } | 
 | 1181 |  | 
| Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 1182 | // createVariableProperties takes the list of property structs for a module and returns a property struct that | 
 | 1183 | // contains the product variable properties that exist in the property structs, or nil if there are none.  It | 
 | 1184 | // caches the result. | 
 | 1185 | func createVariableProperties(moduleTypeProps []interface{}, productVariables interface{}) interface{} { | 
 | 1186 | 	// Convert the moduleTypeProps to an array of reflect.Types that can be used as a key in the OncePer. | 
 | 1187 | 	key := sliceToTypeArray(moduleTypeProps) | 
 | 1188 |  | 
 | 1189 | 	// Use the variablePropTypeMap OncePer to cache the result for each set of property struct types. | 
 | 1190 | 	typ, _ := variablePropTypeMap.Once(NewCustomOnceKey(key), func() interface{} { | 
 | 1191 | 		// Compute the filtered property struct type. | 
 | 1192 | 		return createVariablePropertiesType(moduleTypeProps, productVariables) | 
 | 1193 | 	}).(reflect.Type) | 
 | 1194 |  | 
 | 1195 | 	if typ == nil { | 
 | 1196 | 		return nil | 
 | 1197 | 	} | 
 | 1198 |  | 
 | 1199 | 	// Create a new pointer to a filtered property struct. | 
 | 1200 | 	return reflect.New(typ).Interface() | 
 | 1201 | } | 
 | 1202 |  | 
 | 1203 | // createVariablePropertiesType creates a new type that contains only the product variable properties that exist in | 
 | 1204 | // a list of property structs. | 
 | 1205 | func createVariablePropertiesType(moduleTypeProps []interface{}, productVariables interface{}) reflect.Type { | 
 | 1206 | 	typ, _ := proptools.FilterPropertyStruct(reflect.TypeOf(productVariables), | 
 | 1207 | 		func(field reflect.StructField, prefix string) (bool, reflect.StructField) { | 
 | 1208 | 			// Filter function, returns true if the field should be in the resulting struct | 
 | 1209 | 			if prefix == "" { | 
 | 1210 | 				// Keep the top level Product_variables field | 
 | 1211 | 				return true, field | 
 | 1212 | 			} | 
 | 1213 | 			_, rest := splitPrefix(prefix) | 
 | 1214 | 			if rest == "" { | 
 | 1215 | 				// Keep the 2nd level field (i.e. Product_variables.Eng) | 
 | 1216 | 				return true, field | 
 | 1217 | 			} | 
 | 1218 |  | 
 | 1219 | 			// Strip off the first 2 levels of the prefix | 
 | 1220 | 			_, prefix = splitPrefix(rest) | 
 | 1221 |  | 
 | 1222 | 			for _, p := range moduleTypeProps { | 
 | 1223 | 				if fieldExistsByNameRecursive(reflect.TypeOf(p).Elem(), prefix, field.Name) { | 
 | 1224 | 					// Keep any fields that exist in one of the property structs | 
 | 1225 | 					return true, field | 
 | 1226 | 				} | 
 | 1227 | 			} | 
 | 1228 |  | 
 | 1229 | 			return false, field | 
 | 1230 | 		}) | 
 | 1231 | 	return typ | 
 | 1232 | } | 
 | 1233 |  | 
 | 1234 | func splitPrefix(prefix string) (first, rest string) { | 
 | 1235 | 	index := strings.IndexByte(prefix, '.') | 
 | 1236 | 	if index == -1 { | 
 | 1237 | 		return prefix, "" | 
 | 1238 | 	} | 
 | 1239 | 	return prefix[:index], prefix[index+1:] | 
 | 1240 | } | 
 | 1241 |  | 
 | 1242 | func fieldExistsByNameRecursive(t reflect.Type, prefix, name string) bool { | 
 | 1243 | 	if t.Kind() != reflect.Struct { | 
 | 1244 | 		panic(fmt.Errorf("fieldExistsByNameRecursive can only be called on a reflect.Struct")) | 
 | 1245 | 	} | 
 | 1246 |  | 
 | 1247 | 	if prefix != "" { | 
 | 1248 | 		split := strings.SplitN(prefix, ".", 2) | 
 | 1249 | 		firstPrefix := split[0] | 
 | 1250 | 		rest := "" | 
 | 1251 | 		if len(split) > 1 { | 
 | 1252 | 			rest = split[1] | 
 | 1253 | 		} | 
 | 1254 | 		f, exists := t.FieldByName(firstPrefix) | 
 | 1255 | 		if !exists { | 
 | 1256 | 			return false | 
 | 1257 | 		} | 
 | 1258 | 		ft := f.Type | 
 | 1259 | 		if ft.Kind() == reflect.Ptr { | 
 | 1260 | 			ft = ft.Elem() | 
 | 1261 | 		} | 
 | 1262 | 		if ft.Kind() != reflect.Struct { | 
 | 1263 | 			panic(fmt.Errorf("field %q in %q is not a struct", firstPrefix, t)) | 
 | 1264 | 		} | 
 | 1265 | 		return fieldExistsByNameRecursive(ft, rest, name) | 
 | 1266 | 	} else { | 
 | 1267 | 		_, exists := t.FieldByName(name) | 
 | 1268 | 		return exists | 
 | 1269 | 	} | 
 | 1270 | } |