| 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 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 23 | 	"github.com/google/blueprint/proptools" | 
 | 24 | ) | 
 | 25 |  | 
 | 26 | func init() { | 
| Paul Duffin | e7a055c | 2021-03-07 15:46:33 +0000 | [diff] [blame] | 27 | 	registerVariableBuildComponents(InitRegistrationContext) | 
 | 28 | } | 
 | 29 |  | 
 | 30 | func registerVariableBuildComponents(ctx RegistrationContext) { | 
 | 31 | 	ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) { | 
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 32 | 		ctx.BottomUp("variable", VariableMutator).Parallel() | 
| Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 33 | 	}) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 34 | } | 
 | 35 |  | 
| Paul Duffin | e7a055c | 2021-03-07 15:46:33 +0000 | [diff] [blame] | 36 | var PrepareForTestWithVariables = FixtureRegisterWithContext(registerVariableBuildComponents) | 
 | 37 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 38 | type variableProperties struct { | 
 | 39 | 	Product_variables struct { | 
| Dan Willemsen | 47cf66b | 2015-09-16 16:48:54 -0700 | [diff] [blame] | 40 | 		Platform_sdk_version struct { | 
 | 41 | 			Asflags []string | 
| Colin Cross | ceeff0f | 2017-05-08 13:43:00 -0700 | [diff] [blame] | 42 | 			Cflags  []string | 
| Dan Willemsen | 9fe1410 | 2021-07-13 21:52:04 -0700 | [diff] [blame] | 43 | 			Cmd     *string | 
| Dan Willemsen | 47cf66b | 2015-09-16 16:48:54 -0700 | [diff] [blame] | 44 | 		} | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 45 |  | 
| Yuntao Xu | 402e9b0 | 2021-08-09 15:44:44 -0700 | [diff] [blame] | 46 | 		Platform_sdk_version_or_codename struct { | 
 | 47 | 			Java_resource_dirs []string | 
 | 48 | 		} | 
 | 49 |  | 
| Anton Hansson | b021bf8 | 2021-08-27 17:35:40 +0100 | [diff] [blame] | 50 | 		Platform_sdk_extension_version struct { | 
 | 51 | 			Cmd *string | 
 | 52 | 		} | 
 | 53 |  | 
| Dan Willemsen | 9fe1410 | 2021-07-13 21:52:04 -0700 | [diff] [blame] | 54 | 		Platform_version_name struct { | 
 | 55 | 			Base_dir *string | 
 | 56 | 		} | 
 | 57 |  | 
| Steven Moreland | a48df2b | 2024-06-03 22:29:38 +0000 | [diff] [blame] | 58 | 		Shipping_api_level struct { | 
 | 59 | 			Cflags []string | 
 | 60 | 		} | 
 | 61 |  | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 62 | 		// unbundled_build is a catch-all property to annotate modules that don't build in one or | 
 | 63 | 		// more unbundled branches, usually due to dependencies missing from the manifest. | 
 | 64 | 		Unbundled_build struct { | 
| Cole Faust | a963b94 | 2024-04-11 17:43:00 -0700 | [diff] [blame] | 65 | 			Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"` | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 66 | 		} `android:"arch_variant"` | 
| Dan Willemsen | 496e395 | 2016-01-05 14:27:55 -0800 | [diff] [blame] | 67 |  | 
| Jeongik Cha | f08e59c | 2023-02-09 10:47:59 +0900 | [diff] [blame] | 68 | 		// similar to `Unbundled_build`, but `Always_use_prebuilt_sdks` means that it uses prebuilt | 
 | 69 | 		// sdk specifically. | 
 | 70 | 		Always_use_prebuilt_sdks struct { | 
| Cole Faust | a963b94 | 2024-04-11 17:43:00 -0700 | [diff] [blame] | 71 | 			Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"` | 
| Jeongik Cha | f08e59c | 2023-02-09 10:47:59 +0900 | [diff] [blame] | 72 | 		} `android:"arch_variant"` | 
 | 73 |  | 
| Christopher Ferris | a5a6b9c | 2024-04-23 17:17:49 -0700 | [diff] [blame] | 74 | 		Malloc_low_memory struct { | 
| Christopher Ferris | c71193a | 2019-12-16 09:55:10 -0800 | [diff] [blame] | 75 | 			Cflags              []string `android:"arch_variant"` | 
 | 76 | 			Shared_libs         []string `android:"arch_variant"` | 
 | 77 | 			Whole_static_libs   []string `android:"arch_variant"` | 
| Florian Mayer | ca2854e | 2024-01-16 16:42:34 -0800 | [diff] [blame] | 78 | 			Static_libs         []string `android:"arch_variant"` | 
| Christopher Ferris | c71193a | 2019-12-16 09:55:10 -0800 | [diff] [blame] | 79 | 			Exclude_static_libs []string `android:"arch_variant"` | 
| Christopher Ferris | dea6617 | 2021-09-24 00:07:53 -0700 | [diff] [blame] | 80 | 			Srcs                []string `android:"arch_variant"` | 
 | 81 | 			Header_libs         []string `android:"arch_variant"` | 
| Sasha Smundak | 61ebf8d | 2018-08-31 16:56:05 -0700 | [diff] [blame] | 82 | 		} `android:"arch_variant"` | 
| Evgenii Stepanov | 8391efa | 2016-05-12 18:04:18 -0700 | [diff] [blame] | 83 |  | 
| Evgenii Stepanov | 19ff3c9 | 2020-04-29 14:57:30 -0700 | [diff] [blame] | 84 | 		Malloc_zero_contents struct { | 
 | 85 | 			Cflags []string `android:"arch_variant"` | 
 | 86 | 		} `android:"arch_variant"` | 
 | 87 |  | 
 | 88 | 		Malloc_pattern_fill_contents struct { | 
 | 89 | 			Cflags []string `android:"arch_variant"` | 
 | 90 | 		} `android:"arch_variant"` | 
 | 91 |  | 
| Evgenii Stepanov | 8391efa | 2016-05-12 18:04:18 -0700 | [diff] [blame] | 92 | 		Safestack struct { | 
 | 93 | 			Cflags []string `android:"arch_variant"` | 
 | 94 | 		} `android:"arch_variant"` | 
| Dan Willemsen | a6f7d15 | 2016-07-12 14:57:40 -0700 | [diff] [blame] | 95 |  | 
| Dan Willemsen | 1be3538 | 2016-07-25 17:42:18 -0700 | [diff] [blame] | 96 | 		Binder32bit struct { | 
 | 97 | 			Cflags []string | 
 | 98 | 		} | 
| Dan Willemsen | fcebcd5 | 2016-09-22 14:49:10 -0700 | [diff] [blame] | 99 |  | 
| Colin Cross | 9543642 | 2017-05-04 13:57:05 -0700 | [diff] [blame] | 100 | 		Override_rs_driver struct { | 
 | 101 | 			Cflags []string | 
 | 102 | 		} | 
 | 103 |  | 
| Steven Moreland | c2b9f06 | 2017-12-13 14:06:20 -0800 | [diff] [blame] | 104 | 		// treble_linker_namespaces is true when the system/vendor linker namespace separation is | 
 | 105 | 		// enabled. | 
 | 106 | 		Treble_linker_namespaces struct { | 
 | 107 | 			Cflags []string | 
 | 108 | 		} | 
| Steven Moreland | c2b9f06 | 2017-12-13 14:06:20 -0800 | [diff] [blame] | 109 | 		// enforce_vintf_manifest is true when a device is required to have a vintf manifest. | 
 | 110 | 		Enforce_vintf_manifest struct { | 
 | 111 | 			Cflags []string | 
 | 112 | 		} | 
 | 113 |  | 
| Jihoon Kang | cbcad7c | 2023-06-01 22:31:52 +0000 | [diff] [blame] | 114 | 		Build_from_text_stub struct { | 
 | 115 | 			Static_libs         []string | 
 | 116 | 			Exclude_static_libs []string | 
 | 117 | 		} | 
 | 118 |  | 
| Colin Cross | 6bc59ef | 2016-12-08 09:46:35 -0800 | [diff] [blame] | 119 | 		// debuggable is true for eng and userdebug builds, and can be used to turn on additional | 
 | 120 | 		// debugging features that don't significantly impact runtime behavior.  userdebug builds | 
 | 121 | 		// are used for dogfooding and performance testing, and should be as similar to user builds | 
 | 122 | 		// as possible. | 
| Dan Willemsen | fcebcd5 | 2016-09-22 14:49:10 -0700 | [diff] [blame] | 123 | 		Debuggable struct { | 
| Sasha Smundak | b6d2305 | 2019-04-01 18:37:36 -0700 | [diff] [blame] | 124 | 			Cflags          []string | 
 | 125 | 			Cppflags        []string | 
 | 126 | 			Init_rc         []string | 
 | 127 | 			Required        []string | 
 | 128 | 			Host_required   []string | 
 | 129 | 			Target_required []string | 
| Philip Cuadra | 328e0bf | 2020-10-19 22:01:29 -0700 | [diff] [blame] | 130 | 			Strip           struct { | 
 | 131 | 				All                          *bool | 
 | 132 | 				Keep_symbols                 *bool | 
 | 133 | 				Keep_symbols_and_debug_frame *bool | 
 | 134 | 			} | 
| Herbert Xue | 3817832 | 2024-07-16 17:28:15 +0800 | [diff] [blame] | 135 | 			Static_libs         []string | 
 | 136 | 			Exclude_static_libs []string | 
 | 137 | 			Whole_static_libs   []string | 
 | 138 | 			Shared_libs         []string | 
 | 139 | 			Jni_libs            []string | 
| Jiyong Park | 16e77a9 | 2021-08-30 18:43:19 +0900 | [diff] [blame] | 140 |  | 
 | 141 | 			Cmdline []string | 
| Inseob Kim | f5ed300 | 2022-01-07 19:17:29 +0900 | [diff] [blame] | 142 |  | 
| Jay Aliomer | 2599d1d | 2021-09-23 15:49:54 -0400 | [diff] [blame] | 143 | 			Srcs         []string | 
 | 144 | 			Exclude_srcs []string | 
| Cole Faust | ed94000 | 2023-08-15 11:59:24 -0700 | [diff] [blame] | 145 | 			Cmd          *string | 
| Jiyong Park | 62532d7 | 2024-04-12 16:16:28 +0900 | [diff] [blame] | 146 |  | 
 | 147 | 			Deps []string | 
| Dan Willemsen | fcebcd5 | 2016-09-22 14:49:10 -0700 | [diff] [blame] | 148 | 		} | 
| Colin Cross | 6bc59ef | 2016-12-08 09:46:35 -0800 | [diff] [blame] | 149 |  | 
| Usta Shrestha | c725f47 | 2022-01-11 02:44:21 -0500 | [diff] [blame] | 150 | 		// 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] | 151 | 		// features. | 
 | 152 | 		Eng struct { | 
 | 153 | 			Cflags   []string | 
 | 154 | 			Cppflags []string | 
| John Reck | 1d2b7ee | 2018-07-11 11:01:59 -0700 | [diff] [blame] | 155 | 			Lto      struct { | 
 | 156 | 				Never *bool | 
 | 157 | 			} | 
| Colin Cross | 3273cc2 | 2018-10-26 23:58:42 -0700 | [diff] [blame] | 158 | 			Sanitize struct { | 
 | 159 | 				Address *bool | 
 | 160 | 			} | 
| Felka Chang | f13642e | 2019-06-21 20:58:27 +0800 | [diff] [blame] | 161 | 			Optimize struct { | 
 | 162 | 				Enabled *bool | 
 | 163 | 			} | 
| Colin Cross | 6bc59ef | 2016-12-08 09:46:35 -0800 | [diff] [blame] | 164 | 		} | 
| Colin Cross | b2123aa | 2017-05-05 13:37:11 -0700 | [diff] [blame] | 165 |  | 
| Dmitry Shmidt | dba5419 | 2017-08-23 14:58:37 -0700 | [diff] [blame] | 166 | 		Uml struct { | 
 | 167 | 			Cppflags []string | 
 | 168 | 		} | 
| Risan | ea004dd | 2017-11-27 18:14:46 +0900 | [diff] [blame] | 169 |  | 
 | 170 | 		Arc struct { | 
| Satoshi Niwa | 54f4826 | 2020-12-18 09:53:26 +0900 | [diff] [blame] | 171 | 			Cflags            []string `android:"arch_variant"` | 
 | 172 | 			Exclude_srcs      []string `android:"arch_variant"` | 
| Jasmine Chen | acace42 | 2021-03-05 00:56:40 +0800 | [diff] [blame] | 173 | 			Header_libs       []string `android:"arch_variant"` | 
| Satoshi Niwa | 54f4826 | 2020-12-18 09:53:26 +0900 | [diff] [blame] | 174 | 			Include_dirs      []string `android:"arch_variant"` | 
 | 175 | 			Shared_libs       []string `android:"arch_variant"` | 
 | 176 | 			Static_libs       []string `android:"arch_variant"` | 
 | 177 | 			Srcs              []string `android:"arch_variant"` | 
 | 178 | 			Whole_static_libs []string `android:"arch_variant"` | 
 | 179 | 		} `android:"arch_variant"` | 
| Roland Levillain | 2879d41 | 2019-08-13 15:00:18 +0100 | [diff] [blame] | 180 |  | 
| Colin Cross | d9a121b | 2020-01-27 13:26:42 -0800 | [diff] [blame] | 181 | 		Native_coverage struct { | 
| Colin Cross | 2b10ba0 | 2020-02-05 16:23:21 -0800 | [diff] [blame] | 182 | 			Src          *string  `android:"arch_variant"` | 
| Colin Cross | d9a121b | 2020-01-27 13:26:42 -0800 | [diff] [blame] | 183 | 			Srcs         []string `android:"arch_variant"` | 
 | 184 | 			Exclude_srcs []string `android:"arch_variant"` | 
 | 185 | 		} `android:"arch_variant"` | 
| Devin Moore | c381e10 | 2023-07-06 22:03:58 +0000 | [diff] [blame] | 186 |  | 
 | 187 | 		// release_aidl_use_unfrozen is "true" when a device can | 
 | 188 | 		// use the unfrozen versions of AIDL interfaces. | 
 | 189 | 		Release_aidl_use_unfrozen struct { | 
| Kiyoung Kim | a0523da | 2024-08-19 10:15:30 +0900 | [diff] [blame] | 190 | 			Cflags                 []string | 
 | 191 | 			Cmd                    *string | 
 | 192 | 			Required               []string | 
 | 193 | 			Vintf_fragment_modules []string | 
| Devin Moore | c381e10 | 2023-07-06 22:03:58 +0000 | [diff] [blame] | 194 | 		} | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 195 | 	} `android:"arch_variant"` | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 196 | } | 
 | 197 |  | 
| Colin Cross | 6961a49 | 2020-02-06 16:57:45 -0800 | [diff] [blame] | 198 | var defaultProductVariables interface{} = variableProperties{} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 199 |  | 
| Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 200 | type ProductVariables struct { | 
| Dan Willemsen | 174978c | 2016-05-11 00:27:49 -0700 | [diff] [blame] | 201 | 	// Suffix to add to generated Makefiles | 
 | 202 | 	Make_suffix *string `json:",omitempty"` | 
 | 203 |  | 
| Inseob Kim | 2da72af | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 204 | 	BuildId              *string `json:",omitempty"` | 
 | 205 | 	BuildFingerprintFile *string `json:",omitempty"` | 
 | 206 | 	BuildNumberFile      *string `json:",omitempty"` | 
 | 207 | 	BuildHostnameFile    *string `json:",omitempty"` | 
 | 208 | 	BuildThumbprintFile  *string `json:",omitempty"` | 
 | 209 | 	DisplayBuildNumber   *bool   `json:",omitempty"` | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 210 |  | 
| Linus Tufvesson | ba270c5 | 2024-04-12 13:06:22 +0200 | [diff] [blame] | 211 | 	Platform_display_version_name          *string  `json:",omitempty"` | 
 | 212 | 	Platform_version_name                  *string  `json:",omitempty"` | 
 | 213 | 	Platform_sdk_version                   *int     `json:",omitempty"` | 
 | 214 | 	Platform_sdk_codename                  *string  `json:",omitempty"` | 
 | 215 | 	Platform_sdk_version_or_codename       *string  `json:",omitempty"` | 
 | 216 | 	Platform_sdk_final                     *bool    `json:",omitempty"` | 
 | 217 | 	Platform_sdk_extension_version         *int     `json:",omitempty"` | 
 | 218 | 	Platform_base_sdk_extension_version    *int     `json:",omitempty"` | 
 | 219 | 	Platform_version_active_codenames      []string `json:",omitempty"` | 
 | 220 | 	Platform_version_all_preview_codenames []string `json:",omitempty"` | 
 | 221 | 	Platform_systemsdk_versions            []string `json:",omitempty"` | 
 | 222 | 	Platform_security_patch                *string  `json:",omitempty"` | 
 | 223 | 	Platform_preview_sdk_version           *string  `json:",omitempty"` | 
 | 224 | 	Platform_base_os                       *string  `json:",omitempty"` | 
 | 225 | 	Platform_version_last_stable           *string  `json:",omitempty"` | 
 | 226 | 	Platform_version_known_codenames       *string  `json:",omitempty"` | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 227 |  | 
| Jeongik Cha | 219141c | 2020-08-06 23:00:37 +0900 | [diff] [blame] | 228 | 	DeviceName                            *string  `json:",omitempty"` | 
| Trevor Radcliffe | 90727f4 | 2022-03-21 19:34:02 +0000 | [diff] [blame] | 229 | 	DeviceProduct                         *string  `json:",omitempty"` | 
| Jeongik Cha | 219141c | 2020-08-06 23:00:37 +0900 | [diff] [blame] | 230 | 	DeviceArch                            *string  `json:",omitempty"` | 
 | 231 | 	DeviceArchVariant                     *string  `json:",omitempty"` | 
 | 232 | 	DeviceCpuVariant                      *string  `json:",omitempty"` | 
 | 233 | 	DeviceAbi                             []string `json:",omitempty"` | 
 | 234 | 	DeviceVndkVersion                     *string  `json:",omitempty"` | 
 | 235 | 	DeviceCurrentApiLevelForVendorModules *string  `json:",omitempty"` | 
 | 236 | 	DeviceSystemSdkVersions               []string `json:",omitempty"` | 
| Juan Yescas | 05d4d90 | 2023-04-07 10:35:35 -0700 | [diff] [blame] | 237 | 	DeviceMaxPageSizeSupported            *string  `json:",omitempty"` | 
| Vilas Bhat | b3d2d22 | 2023-12-04 22:51:20 +0000 | [diff] [blame] | 238 | 	DeviceNoBionicPageSizeMacro           *bool    `json:",omitempty"` | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 239 |  | 
| Justin Yun | 41cbb5e | 2023-11-29 17:58:16 +0900 | [diff] [blame] | 240 | 	VendorApiLevel *string `json:",omitempty"` | 
 | 241 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 242 | 	DeviceSecondaryArch        *string  `json:",omitempty"` | 
 | 243 | 	DeviceSecondaryArchVariant *string  `json:",omitempty"` | 
 | 244 | 	DeviceSecondaryCpuVariant  *string  `json:",omitempty"` | 
 | 245 | 	DeviceSecondaryAbi         []string `json:",omitempty"` | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 246 |  | 
| dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 247 | 	NativeBridgeArch         *string  `json:",omitempty"` | 
 | 248 | 	NativeBridgeArchVariant  *string  `json:",omitempty"` | 
 | 249 | 	NativeBridgeCpuVariant   *string  `json:",omitempty"` | 
 | 250 | 	NativeBridgeAbi          []string `json:",omitempty"` | 
 | 251 | 	NativeBridgeRelativePath *string  `json:",omitempty"` | 
| dimitry | 1f33e40 | 2019-03-26 12:39:31 +0100 | [diff] [blame] | 252 |  | 
| dimitry | 8d6dde8 | 2019-07-11 10:23:53 +0200 | [diff] [blame] | 253 | 	NativeBridgeSecondaryArch         *string  `json:",omitempty"` | 
 | 254 | 	NativeBridgeSecondaryArchVariant  *string  `json:",omitempty"` | 
 | 255 | 	NativeBridgeSecondaryCpuVariant   *string  `json:",omitempty"` | 
 | 256 | 	NativeBridgeSecondaryAbi          []string `json:",omitempty"` | 
 | 257 | 	NativeBridgeSecondaryRelativePath *string  `json:",omitempty"` | 
| dimitry | 1f33e40 | 2019-03-26 12:39:31 +0100 | [diff] [blame] | 258 |  | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 259 | 	HostArch          *string `json:",omitempty"` | 
 | 260 | 	HostSecondaryArch *string `json:",omitempty"` | 
| Colin Cross | 528d67e | 2021-07-23 22:23:07 +0000 | [diff] [blame] | 261 | 	HostMusl          *bool   `json:",omitempty"` | 
| Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 262 |  | 
 | 263 | 	CrossHost              *string `json:",omitempty"` | 
 | 264 | 	CrossHostArch          *string `json:",omitempty"` | 
 | 265 | 	CrossHostSecondaryArch *string `json:",omitempty"` | 
| Colin Cross | 8316319 | 2015-12-01 16:31:16 -0800 | [diff] [blame] | 266 |  | 
| Jeongik Cha | cee5ba9 | 2021-02-19 12:11:51 +0900 | [diff] [blame] | 267 | 	DeviceResourceOverlays     []string `json:",omitempty"` | 
 | 268 | 	ProductResourceOverlays    []string `json:",omitempty"` | 
 | 269 | 	EnforceRROTargets          []string `json:",omitempty"` | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 270 | 	EnforceRROExcludedOverlays []string `json:",omitempty"` | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 271 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 272 | 	AAPTCharacteristics *string  `json:",omitempty"` | 
 | 273 | 	AAPTConfig          []string `json:",omitempty"` | 
 | 274 | 	AAPTPreferredConfig *string  `json:",omitempty"` | 
 | 275 | 	AAPTPrebuiltDPI     []string `json:",omitempty"` | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 276 |  | 
| Justin Yun | 635e788 | 2024-07-04 14:50:57 +0900 | [diff] [blame] | 277 | 	DefaultAppCertificate           *string  `json:",omitempty"` | 
 | 278 | 	ExtraOtaKeys                    []string `json:",omitempty"` | 
 | 279 | 	ExtraOtaRecoveryKeys            []string `json:",omitempty"` | 
 | 280 | 	MainlineSepolicyDevCertificates *string  `json:",omitempty"` | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 281 |  | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 282 | 	AppsDefaultVersionName *string `json:",omitempty"` | 
 | 283 |  | 
| Cole Faust | 701ca25 | 2021-11-23 19:02:08 -0800 | [diff] [blame] | 284 | 	Allow_missing_dependencies   *bool    `json:",omitempty"` | 
 | 285 | 	Unbundled_build              *bool    `json:",omitempty"` | 
 | 286 | 	Unbundled_build_apps         []string `json:",omitempty"` | 
 | 287 | 	Unbundled_build_image        *bool    `json:",omitempty"` | 
 | 288 | 	Always_use_prebuilt_sdks     *bool    `json:",omitempty"` | 
 | 289 | 	Skip_boot_jars_check         *bool    `json:",omitempty"` | 
| Christopher Ferris | a5a6b9c | 2024-04-23 17:17:49 -0700 | [diff] [blame] | 290 | 	Malloc_low_memory            *bool    `json:",omitempty"` | 
| Cole Faust | 701ca25 | 2021-11-23 19:02:08 -0800 | [diff] [blame] | 291 | 	Malloc_zero_contents         *bool    `json:",omitempty"` | 
 | 292 | 	Malloc_pattern_fill_contents *bool    `json:",omitempty"` | 
 | 293 | 	Safestack                    *bool    `json:",omitempty"` | 
 | 294 | 	HostStaticBinaries           *bool    `json:",omitempty"` | 
 | 295 | 	Binder32bit                  *bool    `json:",omitempty"` | 
 | 296 | 	UseGoma                      *bool    `json:",omitempty"` | 
| Taylor Santiago | 3c16e61 | 2024-05-30 14:41:31 -0700 | [diff] [blame] | 297 | 	UseABFS                      *bool    `json:",omitempty"` | 
| Cole Faust | 701ca25 | 2021-11-23 19:02:08 -0800 | [diff] [blame] | 298 | 	UseRBE                       *bool    `json:",omitempty"` | 
 | 299 | 	UseRBEJAVAC                  *bool    `json:",omitempty"` | 
 | 300 | 	UseRBER8                     *bool    `json:",omitempty"` | 
 | 301 | 	UseRBED8                     *bool    `json:",omitempty"` | 
 | 302 | 	Debuggable                   *bool    `json:",omitempty"` | 
 | 303 | 	Eng                          *bool    `json:",omitempty"` | 
 | 304 | 	Treble_linker_namespaces     *bool    `json:",omitempty"` | 
 | 305 | 	Enforce_vintf_manifest       *bool    `json:",omitempty"` | 
 | 306 | 	Uml                          *bool    `json:",omitempty"` | 
 | 307 | 	Arc                          *bool    `json:",omitempty"` | 
 | 308 | 	MinimizeJavaDebugInfo        *bool    `json:",omitempty"` | 
| Jihoon Kang | cbcad7c | 2023-06-01 22:31:52 +0000 | [diff] [blame] | 309 | 	Build_from_text_stub         *bool    `json:",omitempty"` | 
| Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 310 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 311 | 	BuildType *string `json:",omitempty"` | 
 | 312 |  | 
| Logan Chien | 4fcea3d | 2018-11-20 11:59:08 +0800 | [diff] [blame] | 313 | 	Check_elf_files *bool `json:",omitempty"` | 
 | 314 |  | 
| Colin Cross | 5a0dcd5 | 2018-10-05 14:20:06 -0700 | [diff] [blame] | 315 | 	UncompressPrivAppDex             *bool    `json:",omitempty"` | 
 | 316 | 	ModulesLoadedByPrivilegedModules []string `json:",omitempty"` | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 317 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 318 | 	BootJars     ConfiguredJarList `json:",omitempty"` | 
 | 319 | 	ApexBootJars ConfiguredJarList `json:",omitempty"` | 
| Vladimir Marko | e8b00d6 | 2018-12-21 15:54:16 +0000 | [diff] [blame] | 320 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 321 | 	IntegerOverflowExcludePaths []string `json:",omitempty"` | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 322 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 323 | 	EnableCFI       *bool    `json:",omitempty"` | 
 | 324 | 	CFIExcludePaths []string `json:",omitempty"` | 
 | 325 | 	CFIIncludePaths []string `json:",omitempty"` | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 326 |  | 
| Kostya Kortchinsky | d5275c8 | 2019-02-01 08:42:56 -0800 | [diff] [blame] | 327 | 	DisableScudo *bool `json:",omitempty"` | 
 | 328 |  | 
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 329 | 	MemtagHeapExcludePaths      []string `json:",omitempty"` | 
 | 330 | 	MemtagHeapAsyncIncludePaths []string `json:",omitempty"` | 
 | 331 | 	MemtagHeapSyncIncludePaths  []string `json:",omitempty"` | 
 | 332 |  | 
| Hang Lu | a98aab9 | 2023-03-17 13:17:22 +0800 | [diff] [blame] | 333 | 	HWASanIncludePaths []string `json:",omitempty"` | 
| Tomislav Novak | f734f00 | 2023-08-22 10:51:44 -0700 | [diff] [blame] | 334 | 	HWASanExcludePaths []string `json:",omitempty"` | 
| Hang Lu | a98aab9 | 2023-03-17 13:17:22 +0800 | [diff] [blame] | 335 |  | 
| Justin Yun | d5f6c82 | 2019-06-25 16:47:17 +0900 | [diff] [blame] | 336 | 	VendorPath    *string `json:",omitempty"` | 
 | 337 | 	OdmPath       *string `json:",omitempty"` | 
 | 338 | 	ProductPath   *string `json:",omitempty"` | 
 | 339 | 	SystemExtPath *string `json:",omitempty"` | 
| Dan Willemsen | 4353bc4 | 2016-12-05 17:16:02 -0800 | [diff] [blame] | 340 |  | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 341 | 	ClangTidy  *bool   `json:",omitempty"` | 
 | 342 | 	TidyChecks *string `json:",omitempty"` | 
 | 343 |  | 
| Roland Levillain | ada1270 | 2020-06-09 13:07:36 +0100 | [diff] [blame] | 344 | 	JavaCoveragePaths        []string `json:",omitempty"` | 
 | 345 | 	JavaCoverageExcludePaths []string `json:",omitempty"` | 
 | 346 |  | 
| Pirama Arumuga Nainar | b37ae58 | 2022-01-26 22:14:32 -0800 | [diff] [blame] | 347 | 	GcovCoverage                *bool    `json:",omitempty"` | 
 | 348 | 	ClangCoverage               *bool    `json:",omitempty"` | 
 | 349 | 	NativeCoveragePaths         []string `json:",omitempty"` | 
 | 350 | 	NativeCoverageExcludePaths  []string `json:",omitempty"` | 
 | 351 | 	ClangCoverageContinuousMode *bool    `json:",omitempty"` | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 352 |  | 
| Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 353 | 	// Set by NewConfig | 
| Liz Kammer | 09f947d | 2021-05-12 14:51:49 -0400 | [diff] [blame] | 354 | 	Native_coverage *bool `json:",omitempty"` | 
| Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 355 |  | 
| Colin Cross | 23ae82a | 2016-11-02 14:34:39 -0700 | [diff] [blame] | 356 | 	SanitizeHost       []string `json:",omitempty"` | 
 | 357 | 	SanitizeDevice     []string `json:",omitempty"` | 
| Ivan Lozano | 0c3a1ef | 2017-06-28 09:10:48 -0700 | [diff] [blame] | 358 | 	SanitizeDeviceDiag []string `json:",omitempty"` | 
| Colin Cross | 23ae82a | 2016-11-02 14:34:39 -0700 | [diff] [blame] | 359 | 	SanitizeDeviceArch []string `json:",omitempty"` | 
| Hiroshi Yamauchi | e2a1063 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 360 |  | 
 | 361 | 	ArtUseReadBarrier *bool `json:",omitempty"` | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 362 |  | 
 | 363 | 	BtConfigIncludeDir *string `json:",omitempty"` | 
| Colin Cross | 9543642 | 2017-05-04 13:57:05 -0700 | [diff] [blame] | 364 |  | 
 | 365 | 	Override_rs_driver *string `json:",omitempty"` | 
| Jiyong Park | d773eb3 | 2017-07-03 13:18:12 +0900 | [diff] [blame] | 366 |  | 
 | 367 | 	DeviceKernelHeaders []string `json:",omitempty"` | 
| Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 368 |  | 
 | 369 | 	ExtraVndkVersions []string `json:",omitempty"` | 
| Jeff Gaston | 088e29e | 2017-11-29 16:47:17 -0800 | [diff] [blame] | 370 |  | 
 | 371 | 	NamespacesToExport []string `json:",omitempty"` | 
| Pirama Arumuga Nainar | 4954080 | 2018-01-29 23:11:42 -0800 | [diff] [blame] | 372 |  | 
| Vinh Tran | 7a8362c | 2022-11-01 15:33:51 -0400 | [diff] [blame] | 373 | 	PgoAdditionalProfileDirs []string `json:",omitempty"` | 
| Dan Willemsen | 0fe7866 | 2018-03-26 12:41:18 -0700 | [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 |  | 
| Herbert Xue | 0fc8abe | 2024-08-21 13:03:01 +0800 | [diff] [blame] | 383 | 	BoardPlatform           *string `json:",omitempty"` | 
| Inseob Kim | 16ebd5a | 2020-12-09 23:08:17 +0900 | [diff] [blame] | 384 | 	BoardSepolicyVers       *string `json:",omitempty"` | 
 | 385 | 	PlatformSepolicyVersion *string `json:",omitempty"` | 
 | 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 |  | 
| Cole Faust | 46f6e2f | 2024-06-20 12:57:43 -0700 | [diff] [blame] | 392 | 	VendorVars     map[string]map[string]string `json:",omitempty"` | 
 | 393 | 	VendorVarTypes map[string]map[string]string `json:",omitempty"` | 
| Colin Cross | 395f2cf | 2018-10-24 16:10:32 -0700 | [diff] [blame] | 394 |  | 
| Dan Albert | d05ba00 | 2021-04-13 15:55:47 -0700 | [diff] [blame] | 395 | 	Ndk_abis *bool `json:",omitempty"` | 
| Jiyong Park | 8fd6192 | 2018-11-08 02:50:25 +0900 | [diff] [blame] | 396 |  | 
| Dennis Shen | e2ed70c | 2023-01-11 14:15:43 +0000 | [diff] [blame] | 397 | 	TrimmedApex                  *bool `json:",omitempty"` | 
| Jiyong Park | 4da0797 | 2021-01-05 21:01:11 +0900 | [diff] [blame] | 398 | 	ForceApexSymlinkOptimization *bool `json:",omitempty"` | 
 | 399 | 	CompressedApex               *bool `json:",omitempty"` | 
 | 400 | 	Aml_abis                     *bool `json:",omitempty"` | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 401 |  | 
 | 402 | 	DexpreoptGlobalConfig *string `json:",omitempty"` | 
| Jiyong Park | 7f67f48 | 2019-01-05 12:57:48 +0900 | [diff] [blame] | 403 |  | 
| Inseob Kim | 7b85eeb | 2021-03-23 20:52:24 +0900 | [diff] [blame] | 404 | 	WithDexpreopt bool `json:",omitempty"` | 
 | 405 |  | 
| Jiakai Zhang | 4d90da2 | 2023-07-12 16:51:48 +0100 | [diff] [blame] | 406 | 	ManifestPackageNameOverrides   []string `json:",omitempty"` | 
 | 407 | 	CertificateOverrides           []string `json:",omitempty"` | 
 | 408 | 	PackageNameOverrides           []string `json:",omitempty"` | 
 | 409 | 	ConfiguredJarLocationOverrides []string `json:",omitempty"` | 
| Jeongik Cha | c946414 | 2019-01-07 12:07:27 +0900 | [diff] [blame] | 410 |  | 
| Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 411 | 	ApexGlobalMinSdkVersionOverride *string `json:",omitempty"` | 
 | 412 |  | 
| Jeongik Cha | c946414 | 2019-01-07 12:07:27 +0900 | [diff] [blame] | 413 | 	EnforceSystemCertificate          *bool    `json:",omitempty"` | 
| Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 414 | 	EnforceSystemCertificateAllowList []string `json:",omitempty"` | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 415 |  | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 416 | 	ProductHiddenAPIStubs       []string `json:",omitempty"` | 
 | 417 | 	ProductHiddenAPIStubsSystem []string `json:",omitempty"` | 
 | 418 | 	ProductHiddenAPIStubsTest   []string `json:",omitempty"` | 
| Dan Willemsen | 71c7460 | 2019-04-10 12:27:35 -0700 | [diff] [blame] | 419 |  | 
| Inseob Kim | 0866b00 | 2019-04-15 20:21:29 +0900 | [diff] [blame] | 420 | 	ProductPublicSepolicyDirs  []string `json:",omitempty"` | 
 | 421 | 	ProductPrivateSepolicyDirs []string `json:",omitempty"` | 
| Inseob Kim | 0866b00 | 2019-04-15 20:21:29 +0900 | [diff] [blame] | 422 |  | 
| Dan Willemsen | 54879d1 | 2019-04-18 10:08:46 -0700 | [diff] [blame] | 423 | 	TargetFSConfigGen []string `json:",omitempty"` | 
| Colin Cross | 50ddcc4 | 2019-05-16 12:28:22 -0700 | [diff] [blame] | 424 |  | 
| Jeongik Cha | 2cc570d | 2019-10-29 15:44:45 +0900 | [diff] [blame] | 425 | 	EnforceProductPartitionInterface *bool `json:",omitempty"` | 
| Jooyung Han | 3ab2c3e | 2019-12-05 16:27:44 +0900 | [diff] [blame] | 426 |  | 
| JaeMan Park | ff71556 | 2020-10-19 17:25:58 +0900 | [diff] [blame] | 427 | 	EnforceInterPartitionJavaSdkLibrary *bool    `json:",omitempty"` | 
 | 428 | 	InterPartitionJavaLibraryAllowList  []string `json:",omitempty"` | 
 | 429 |  | 
| Yifan Hong | 82db735 | 2020-01-21 16:12:26 -0800 | [diff] [blame] | 430 | 	BoardUsesRecoveryAsBoot *bool `json:",omitempty"` | 
| Yifan Hong | 97365ee | 2020-07-29 09:51:57 -0700 | [diff] [blame] | 431 |  | 
| Yifan Hong | 42bef8d | 2020-08-05 14:36:09 -0700 | [diff] [blame] | 432 | 	BoardKernelBinaries                []string `json:",omitempty"` | 
 | 433 | 	BoardKernelModuleInterfaceVersions []string `json:",omitempty"` | 
| Yifan Hong | dd8dacc | 2020-10-21 15:40:17 -0700 | [diff] [blame] | 434 |  | 
 | 435 | 	BoardMoveRecoveryResourcesToVendorBoot *bool `json:",omitempty"` | 
| Bill Peckham | bae4749 | 2021-01-08 09:34:44 -0800 | [diff] [blame] | 436 |  | 
 | 437 | 	PrebuiltHiddenApiDir *string `json:",omitempty"` | 
| Inseob Kim | 60c32f0 | 2020-12-21 22:53:05 +0900 | [diff] [blame] | 438 |  | 
| Steven Moreland | a48df2b | 2024-06-03 22:29:38 +0000 | [diff] [blame] | 439 | 	Shipping_api_level *string `json:",omitempty"` | 
| Inseob Kim | 0cac7b4 | 2021-02-03 18:16:46 +0900 | [diff] [blame] | 440 |  | 
| Cole Faust | ded7960 | 2023-09-05 17:48:11 -0700 | [diff] [blame] | 441 | 	BuildBrokenPluginValidation         []string `json:",omitempty"` | 
 | 442 | 	BuildBrokenClangAsFlags             bool     `json:",omitempty"` | 
 | 443 | 	BuildBrokenClangCFlags              bool     `json:",omitempty"` | 
 | 444 | 	BuildBrokenClangProperty            bool     `json:",omitempty"` | 
 | 445 | 	GenruleSandboxing                   *bool    `json:",omitempty"` | 
 | 446 | 	BuildBrokenEnforceSyspropOwner      bool     `json:",omitempty"` | 
 | 447 | 	BuildBrokenTrebleSyspropNeverallow  bool     `json:",omitempty"` | 
 | 448 | 	BuildBrokenUsesSoongPython2Modules  bool     `json:",omitempty"` | 
 | 449 | 	BuildBrokenVendorPropertyNamespace  bool     `json:",omitempty"` | 
 | 450 | 	BuildBrokenIncorrectPartitionImages bool     `json:",omitempty"` | 
 | 451 | 	BuildBrokenInputDirModules          []string `json:",omitempty"` | 
| Jiyong Park | 3bb9924 | 2024-01-04 23:21:26 +0000 | [diff] [blame] | 452 | 	BuildBrokenDontCheckSystemSdk       bool     `json:",omitempty"` | 
| Inseob Kim | 2da72af | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 453 | 	BuildBrokenDupSysprop               bool     `json:",omitempty"` | 
| Inseob Kim | 67e5add19 | 2021-03-17 18:05:33 +0900 | [diff] [blame] | 454 |  | 
| Jiakai Zhang | 48203e3 | 2023-06-02 23:42:21 +0100 | [diff] [blame] | 455 | 	BuildWarningBadOptionalUsesLibsAllowlist []string `json:",omitempty"` | 
 | 456 |  | 
| Hridya Valsaraju | 5a5c7d5 | 2021-04-02 16:45:24 -0700 | [diff] [blame] | 457 | 	BuildDebugfsRestrictionsEnabled bool `json:",omitempty"` | 
 | 458 |  | 
| Inseob Kim | 67e5add19 | 2021-03-17 18:05:33 +0900 | [diff] [blame] | 459 | 	RequiresInsecureExecmemForSwiftshader bool `json:",omitempty"` | 
 | 460 |  | 
 | 461 | 	SelinuxIgnoreNeverallows bool `json:",omitempty"` | 
 | 462 |  | 
| Devin Moore | c381e10 | 2023-07-06 22:03:58 +0000 | [diff] [blame] | 463 | 	Release_aidl_use_unfrozen *bool `json:",omitempty"` | 
 | 464 |  | 
| Inseob Kim | a10ef27 | 2021-09-15 03:04:53 +0000 | [diff] [blame] | 465 | 	SepolicyFreezeTestExtraDirs         []string `json:",omitempty"` | 
 | 466 | 	SepolicyFreezeTestExtraPrebuiltDirs []string `json:",omitempty"` | 
| Jiyong Park | d163d4d | 2021-10-12 16:47:43 +0900 | [diff] [blame] | 467 |  | 
 | 468 | 	GenerateAidlNdkPlatformBackend bool `json:",omitempty"` | 
| Christopher Ferris | 98f1022 | 2022-07-13 23:16:52 -0700 | [diff] [blame] | 469 |  | 
 | 470 | 	IgnorePrefer32OnDevice bool `json:",omitempty"` | 
| Spandan Das | c576383 | 2022-11-08 18:42:16 +0000 | [diff] [blame] | 471 |  | 
| Sam Delmerico | 98a7329 | 2023-02-21 11:50:29 -0500 | [diff] [blame] | 472 | 	SourceRootDirs []string `json:",omitempty"` | 
| Vinh Tran | 44cb78c | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 473 |  | 
 | 474 | 	AfdoProfiles []string `json:",omitempty"` | 
| Wei Li | c642d68 | 2023-05-04 09:06:06 -0700 | [diff] [blame] | 475 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 476 | 	ProductManufacturer string `json:",omitempty"` | 
 | 477 | 	ProductBrand        string `json:",omitempty"` | 
| Joe Onorato | fee845a | 2023-05-09 08:14:14 -0700 | [diff] [blame] | 478 |  | 
| Yu Liu | eebb259 | 2023-10-12 20:31:27 -0700 | [diff] [blame] | 479 | 	ReleaseVersion          string   `json:",omitempty"` | 
 | 480 | 	ReleaseAconfigValueSets []string `json:",omitempty"` | 
| Kiyoung Kim | e623c58 | 2023-07-06 16:43:44 +0900 | [diff] [blame] | 481 |  | 
| Zhi Dou | 3f65a41 | 2023-08-10 21:47:40 +0000 | [diff] [blame] | 482 | 	ReleaseAconfigFlagDefaultPermission string `json:",omitempty"` | 
 | 483 |  | 
| Alyssa Ketpreechasawat | 34ab879 | 2023-10-06 07:01:22 +0000 | [diff] [blame] | 484 | 	ReleaseDefaultModuleBuildFromSource *bool `json:",omitempty"` | 
 | 485 |  | 
| Inseob Kim | 5bac3b6 | 2023-08-25 21:29:46 +0900 | [diff] [blame] | 486 | 	CheckVendorSeappViolations *bool `json:",omitempty"` | 
| Cole Faust | b4cb0c8 | 2023-09-14 15:16:58 -0700 | [diff] [blame] | 487 |  | 
| Inseob Kim | e4e85d5 | 2023-10-25 23:53:58 +0900 | [diff] [blame] | 488 | 	BuildFlags map[string]string `json:",omitempty"` | 
| Jihoon Kang | c1b04d6 | 2023-11-16 19:07:04 +0000 | [diff] [blame] | 489 |  | 
| Cole Faust | 751a4a5 | 2024-05-21 16:51:59 -0700 | [diff] [blame] | 490 | 	BuildFlagTypes map[string]string `json:",omitempty"` | 
 | 491 |  | 
| Jihoon Kang | c1b04d6 | 2023-11-16 19:07:04 +0000 | [diff] [blame] | 492 | 	BuildFromSourceStub *bool `json:",omitempty"` | 
| Spandan Das | 8ab28dd | 2024-02-17 03:31:45 +0000 | [diff] [blame] | 493 |  | 
| Spandan Das | 0d24ade | 2024-03-08 04:20:15 +0000 | [diff] [blame] | 494 | 	BuildIgnoreApexContributionContents *bool `json:",omitempty"` | 
| Jihoon Kang | b36fc54 | 2024-02-22 19:35:26 +0000 | [diff] [blame] | 495 |  | 
 | 496 | 	HiddenapiExportableStubs *bool `json:",omitempty"` | 
| Jihoon Kang | 3534946 | 2024-02-22 19:52:46 +0000 | [diff] [blame] | 497 |  | 
 | 498 | 	ExportRuntimeApis *bool `json:",omitempty"` | 
| Yu Liu | 67a2842 | 2024-03-05 00:36:31 +0000 | [diff] [blame] | 499 |  | 
 | 500 | 	AconfigContainerValidation string `json:",omitempty"` | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 501 |  | 
 | 502 | 	ProductLocales []string `json:",omitempty"` | 
 | 503 |  | 
 | 504 | 	ProductDefaultWifiChannels []string `json:",omitempty"` | 
 | 505 |  | 
 | 506 | 	BoardUseVbmetaDigestInFingerprint *bool `json:",omitempty"` | 
 | 507 |  | 
 | 508 | 	OemProperties []string `json:",omitempty"` | 
| Kiyoung Kim | 881e465 | 2024-07-08 11:02:23 +0900 | [diff] [blame] | 509 |  | 
 | 510 | 	ArtTargetIncludeDebugBuild *bool `json:",omitempty"` | 
| Inseob Kim | d8538e5 | 2024-07-31 02:00:41 +0000 | [diff] [blame] | 511 |  | 
| Inseob Kim | acf9174 | 2024-08-05 12:51:05 +0900 | [diff] [blame] | 512 | 	SystemPropFiles    []string `json:",omitempty"` | 
 | 513 | 	SystemExtPropFiles []string `json:",omitempty"` | 
| Inseob Kim | 01d4f8b | 2024-08-08 17:47:14 +0900 | [diff] [blame] | 514 | 	ProductPropFiles   []string `json:",omitempty"` | 
| Inseob Kim | 6bd92d5 | 2024-07-31 02:01:03 +0000 | [diff] [blame] | 515 |  | 
 | 516 | 	EnableUffdGc *string `json:",omitempty"` | 
| yangbill | 66e555c | 2024-07-29 03:37:12 +0000 | [diff] [blame] | 517 |  | 
 | 518 | 	BoardAvbEnable                         *bool    `json:",omitempty"` | 
 | 519 | 	BoardAvbSystemAddHashtreeFooterArgs    []string `json:",omitempty"` | 
 | 520 | 	DeviceFrameworkCompatibilityMatrixFile []string `json:",omitempty"` | 
 | 521 | 	DeviceProductCompatibilityMatrixFile   []string `json:",omitempty"` | 
| Cole Faust | cb193ec | 2023-09-20 16:01:18 -0700 | [diff] [blame] | 522 | } | 
 | 523 |  | 
| Cole Faust | 11edf55 | 2023-10-13 11:32:14 -0700 | [diff] [blame] | 524 | type PartitionQualifiedVariablesType struct { | 
 | 525 | 	BuildingImage               bool   `json:",omitempty"` | 
 | 526 | 	BoardErofsCompressor        string `json:",omitempty"` | 
 | 527 | 	BoardErofsCompressHints     string `json:",omitempty"` | 
 | 528 | 	BoardErofsPclusterSize      string `json:",omitempty"` | 
 | 529 | 	BoardExtfsInodeCount        string `json:",omitempty"` | 
 | 530 | 	BoardExtfsRsvPct            string `json:",omitempty"` | 
 | 531 | 	BoardF2fsSloadCompressFlags string `json:",omitempty"` | 
 | 532 | 	BoardFileSystemCompress     string `json:",omitempty"` | 
 | 533 | 	BoardFileSystemType         string `json:",omitempty"` | 
 | 534 | 	BoardJournalSize            string `json:",omitempty"` | 
 | 535 | 	BoardPartitionReservedSize  string `json:",omitempty"` | 
 | 536 | 	BoardPartitionSize          string `json:",omitempty"` | 
 | 537 | 	BoardSquashfsBlockSize      string `json:",omitempty"` | 
 | 538 | 	BoardSquashfsCompressor     string `json:",omitempty"` | 
 | 539 | 	BoardSquashfsCompressorOpt  string `json:",omitempty"` | 
 | 540 | 	BoardSquashfsDisable4kAlign string `json:",omitempty"` | 
 | 541 | 	ProductBaseFsPath           string `json:",omitempty"` | 
 | 542 | 	ProductHeadroom             string `json:",omitempty"` | 
 | 543 | 	ProductVerityPartition      string `json:",omitempty"` | 
 | 544 |  | 
 | 545 | 	BoardAvbAddHashtreeFooterArgs string `json:",omitempty"` | 
 | 546 | 	BoardAvbKeyPath               string `json:",omitempty"` | 
 | 547 | 	BoardAvbAlgorithm             string `json:",omitempty"` | 
 | 548 | 	BoardAvbRollbackIndex         string `json:",omitempty"` | 
 | 549 | 	BoardAvbRollbackIndexLocation string `json:",omitempty"` | 
 | 550 | } | 
 | 551 |  | 
| Cole Faust | cb193ec | 2023-09-20 16:01:18 -0700 | [diff] [blame] | 552 | type PartitionVariables struct { | 
 | 553 | 	ProductDirectory            string `json:",omitempty"` | 
| Cole Faust | 11edf55 | 2023-10-13 11:32:14 -0700 | [diff] [blame] | 554 | 	PartitionQualifiedVariables map[string]PartitionQualifiedVariablesType | 
 | 555 | 	TargetUserimagesUseExt2     bool `json:",omitempty"` | 
 | 556 | 	TargetUserimagesUseExt3     bool `json:",omitempty"` | 
 | 557 | 	TargetUserimagesUseExt4     bool `json:",omitempty"` | 
| Cole Faust | cb193ec | 2023-09-20 16:01:18 -0700 | [diff] [blame] | 558 |  | 
 | 559 | 	TargetUserimagesSparseExtDisabled      bool `json:",omitempty"` | 
 | 560 | 	TargetUserimagesSparseErofsDisabled    bool `json:",omitempty"` | 
 | 561 | 	TargetUserimagesSparseSquashfsDisabled bool `json:",omitempty"` | 
 | 562 | 	TargetUserimagesSparseF2fsDisabled     bool `json:",omitempty"` | 
 | 563 |  | 
| Yi-Yo Chiang | 939fe1a | 2023-11-24 14:58:50 +0800 | [diff] [blame] | 564 | 	BoardErofsCompressor           string `json:",omitempty"` | 
 | 565 | 	BoardErofsCompressorHints      string `json:",omitempty"` | 
 | 566 | 	BoardErofsPclusterSize         string `json:",omitempty"` | 
 | 567 | 	BoardErofsShareDupBlocks       string `json:",omitempty"` | 
 | 568 | 	BoardErofsUseLegacyCompression string `json:",omitempty"` | 
 | 569 | 	BoardExt4ShareDupBlocks        string `json:",omitempty"` | 
 | 570 | 	BoardFlashLogicalBlockSize     string `json:",omitempty"` | 
 | 571 | 	BoardFlashEraseBlockSize       string `json:",omitempty"` | 
 | 572 | 	BoardUsesRecoveryAsBoot        bool   `json:",omitempty"` | 
 | 573 | 	ProductUseDynamicPartitionSize bool   `json:",omitempty"` | 
 | 574 | 	CopyImagesForTargetFilesZip    bool   `json:",omitempty"` | 
| Cole Faust | b505539 | 2023-09-27 13:44:40 -0700 | [diff] [blame] | 575 |  | 
 | 576 | 	BoardAvbEnable bool `json:",omitempty"` | 
| Cole Faust | 11edf55 | 2023-10-13 11:32:14 -0700 | [diff] [blame] | 577 |  | 
 | 578 | 	ProductPackages []string `json:",omitempty"` | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 579 | } | 
 | 580 |  | 
 | 581 | func boolPtr(v bool) *bool { | 
 | 582 | 	return &v | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 583 | } | 
 | 584 |  | 
| Dan Willemsen | 47cf66b | 2015-09-16 16:48:54 -0700 | [diff] [blame] | 585 | func intPtr(v int) *int { | 
 | 586 | 	return &v | 
 | 587 | } | 
 | 588 |  | 
| Colin Cross | 4225f65 | 2015-09-17 14:33:42 -0700 | [diff] [blame] | 589 | func stringPtr(v string) *string { | 
 | 590 | 	return &v | 
 | 591 | } | 
 | 592 |  | 
| Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 593 | func (v *ProductVariables) SetDefaultConfig() { | 
 | 594 | 	*v = ProductVariables{ | 
| Colin Cross | 2a2e0db | 2020-02-21 16:55:46 -0800 | [diff] [blame] | 595 | 		BuildNumberFile: stringPtr("build_number.txt"), | 
| Dan Willemsen | b6d171b | 2019-04-07 09:41:44 -0700 | [diff] [blame] | 596 |  | 
| Dan Albert | 8c7a994 | 2023-03-27 20:34:01 +0000 | [diff] [blame] | 597 | 		Platform_version_name:                  stringPtr("S"), | 
 | 598 | 		Platform_base_sdk_extension_version:    intPtr(30), | 
 | 599 | 		Platform_sdk_version:                   intPtr(30), | 
 | 600 | 		Platform_sdk_codename:                  stringPtr("S"), | 
 | 601 | 		Platform_sdk_final:                     boolPtr(false), | 
 | 602 | 		Platform_version_active_codenames:      []string{"S"}, | 
 | 603 | 		Platform_version_all_preview_codenames: []string{"S"}, | 
| Dan Willemsen | cbf9e82 | 2017-11-13 14:34:56 -0800 | [diff] [blame] | 604 |  | 
| Vilas Bhat | b3d2d22 | 2023-12-04 22:51:20 +0000 | [diff] [blame] | 605 | 		HostArch:                    stringPtr("x86_64"), | 
 | 606 | 		HostSecondaryArch:           stringPtr("x86"), | 
 | 607 | 		DeviceName:                  stringPtr("generic_arm64"), | 
 | 608 | 		DeviceProduct:               stringPtr("aosp_arm-eng"), | 
 | 609 | 		DeviceArch:                  stringPtr("arm64"), | 
 | 610 | 		DeviceArchVariant:           stringPtr("armv8-a"), | 
 | 611 | 		DeviceCpuVariant:            stringPtr("generic"), | 
 | 612 | 		DeviceAbi:                   []string{"arm64-v8a"}, | 
 | 613 | 		DeviceSecondaryArch:         stringPtr("arm"), | 
 | 614 | 		DeviceSecondaryArchVariant:  stringPtr("armv8-a"), | 
 | 615 | 		DeviceSecondaryCpuVariant:   stringPtr("generic"), | 
 | 616 | 		DeviceSecondaryAbi:          []string{"armeabi-v7a", "armeabi"}, | 
 | 617 | 		DeviceMaxPageSizeSupported:  stringPtr("4096"), | 
 | 618 | 		DeviceNoBionicPageSizeMacro: boolPtr(false), | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 619 |  | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 620 | 		AAPTConfig:          []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"}, | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 621 | 		AAPTPreferredConfig: stringPtr("xhdpi"), | 
 | 622 | 		AAPTCharacteristics: stringPtr("nosdcard"), | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 623 | 		AAPTPrebuiltDPI:     []string{"xhdpi", "xxhdpi"}, | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 624 |  | 
| Christopher Ferris | a5a6b9c | 2024-04-23 17:17:49 -0700 | [diff] [blame] | 625 | 		Malloc_low_memory:            boolPtr(false), | 
| Steven Moreland | d134201 | 2020-07-30 20:38:49 +0000 | [diff] [blame] | 626 | 		Malloc_zero_contents:         boolPtr(true), | 
| Evgenii Stepanov | 19ff3c9 | 2020-04-29 14:57:30 -0700 | [diff] [blame] | 627 | 		Malloc_pattern_fill_contents: boolPtr(false), | 
 | 628 | 		Safestack:                    boolPtr(false), | 
| Dennis Shen | e2ed70c | 2023-01-11 14:15:43 +0000 | [diff] [blame] | 629 | 		TrimmedApex:                  boolPtr(false), | 
| Jihoon Kang | cbcad7c | 2023-06-01 22:31:52 +0000 | [diff] [blame] | 630 | 		Build_from_text_stub:         boolPtr(false), | 
| Lukacs T. Berki | 720b396 | 2021-03-17 13:34:30 +0100 | [diff] [blame] | 631 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 632 | 		BootJars:     ConfiguredJarList{apexes: []string{}, jars: []string{}}, | 
 | 633 | 		ApexBootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}}, | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 634 | 	} | 
| Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 635 |  | 
 | 636 | 	if runtime.GOOS == "linux" { | 
 | 637 | 		v.CrossHost = stringPtr("windows") | 
 | 638 | 		v.CrossHostArch = stringPtr("x86") | 
| Dan Willemsen | 07cd051 | 2016-02-03 23:16:33 -0800 | [diff] [blame] | 639 | 		v.CrossHostSecondaryArch = stringPtr("x86_64") | 
| Dan Willemsen | 490fd49 | 2015-11-24 17:53:15 -0800 | [diff] [blame] | 640 | 	} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 641 | } | 
 | 642 |  | 
| Joe Onorato | 3fefc23 | 2023-12-04 17:35:15 +0000 | [diff] [blame] | 643 | func (this *ProductVariables) GetBuildFlagBool(flag string) bool { | 
 | 644 | 	val, ok := this.BuildFlags[flag] | 
 | 645 | 	if !ok { | 
 | 646 | 		return false | 
 | 647 | 	} | 
 | 648 | 	return val == "true" | 
 | 649 | } | 
 | 650 |  | 
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 651 | func VariableMutator(mctx BottomUpMutatorContext) { | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 652 | 	var module Module | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 653 | 	var ok bool | 
| Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 654 | 	if module, ok = mctx.Module().(Module); !ok { | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 655 | 		return | 
 | 656 | 	} | 
 | 657 |  | 
 | 658 | 	// TODO: depend on config variable, create variants, propagate variants up tree | 
 | 659 | 	a := module.base() | 
| Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 660 |  | 
 | 661 | 	if a.variableProperties == nil { | 
 | 662 | 		return | 
 | 663 | 	} | 
 | 664 |  | 
 | 665 | 	variableValues := reflect.ValueOf(a.variableProperties).Elem().FieldByName("Product_variables") | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 666 |  | 
| Colin Cross | 0cec312 | 2021-01-20 11:27:32 -0800 | [diff] [blame] | 667 | 	productVariables := reflect.ValueOf(mctx.Config().productVariables) | 
 | 668 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 669 | 	for i := 0; i < variableValues.NumField(); i++ { | 
 | 670 | 		variableValue := variableValues.Field(i) | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 671 | 		name := variableValues.Type().Field(i).Name | 
 | 672 | 		property := "product_variables." + proptools.PropertyNameForField(name) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 673 |  | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 674 | 		// Check that the variable was set for the product | 
| Colin Cross | 0cec312 | 2021-01-20 11:27:32 -0800 | [diff] [blame] | 675 | 		val := productVariables.FieldByName(name) | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 676 | 		if !val.IsValid() || val.Kind() != reflect.Ptr || val.IsNil() { | 
 | 677 | 			continue | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 678 | 		} | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 679 |  | 
 | 680 | 		val = val.Elem() | 
 | 681 |  | 
 | 682 | 		// For bools, check that the value is true | 
 | 683 | 		if val.Kind() == reflect.Bool && val.Bool() == false { | 
 | 684 | 			continue | 
 | 685 | 		} | 
 | 686 |  | 
 | 687 | 		// Check if any properties were set for the module | 
| Colin Cross | 6961a49 | 2020-02-06 16:57:45 -0800 | [diff] [blame] | 688 | 		if variableValue.IsZero() { | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 689 | 			continue | 
 | 690 | 		} | 
| Colin Cross | a6bc19e | 2015-09-16 13:53:42 -0700 | [diff] [blame] | 691 | 		a.setVariableProperties(mctx, property, variableValue, val.Interface()) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 692 | 	} | 
 | 693 | } | 
 | 694 |  | 
| Colin Cross | 4157e88 | 2019-06-06 16:57:04 -0700 | [diff] [blame] | 695 | func (m *ModuleBase) setVariableProperties(ctx BottomUpMutatorContext, | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 696 | 	prefix string, productVariablePropertyValue reflect.Value, variableValue interface{}) { | 
 | 697 |  | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 698 | 	printfIntoProperties(ctx, prefix, productVariablePropertyValue, variableValue) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 699 |  | 
| Usta | 851a327 | 2022-01-05 23:42:33 -0500 | [diff] [blame] | 700 | 	err := proptools.AppendMatchingProperties(m.GetProperties(), | 
| Colin Cross | 06a931b | 2015-10-28 17:23:31 -0700 | [diff] [blame] | 701 | 		productVariablePropertyValue.Addr().Interface(), nil) | 
 | 702 | 	if err != nil { | 
 | 703 | 		if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok { | 
 | 704 | 			ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error()) | 
 | 705 | 		} else { | 
 | 706 | 			panic(err) | 
 | 707 | 		} | 
 | 708 | 	} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 709 | } | 
 | 710 |  | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 711 | func printfIntoPropertiesError(ctx BottomUpMutatorContext, prefix string, | 
 | 712 | 	productVariablePropertyValue reflect.Value, i int, err error) { | 
 | 713 |  | 
 | 714 | 	field := productVariablePropertyValue.Type().Field(i).Name | 
 | 715 | 	property := prefix + "." + proptools.PropertyNameForField(field) | 
 | 716 | 	ctx.PropertyErrorf(property, "%s", err) | 
 | 717 | } | 
 | 718 |  | 
 | 719 | func printfIntoProperties(ctx BottomUpMutatorContext, prefix string, | 
 | 720 | 	productVariablePropertyValue reflect.Value, variableValue interface{}) { | 
 | 721 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 722 | 	for i := 0; i < productVariablePropertyValue.NumField(); i++ { | 
 | 723 | 		propertyValue := productVariablePropertyValue.Field(i) | 
| Colin Cross | dd0dbe6 | 2015-12-02 15:24:38 -0800 | [diff] [blame] | 724 | 		kind := propertyValue.Kind() | 
 | 725 | 		if kind == reflect.Ptr { | 
 | 726 | 			if propertyValue.IsNil() { | 
 | 727 | 				continue | 
 | 728 | 			} | 
 | 729 | 			propertyValue = propertyValue.Elem() | 
 | 730 | 		} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 731 | 		switch propertyValue.Kind() { | 
 | 732 | 		case reflect.String: | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 733 | 			err := printfIntoProperty(propertyValue, variableValue) | 
 | 734 | 			if err != nil { | 
 | 735 | 				printfIntoPropertiesError(ctx, prefix, productVariablePropertyValue, i, err) | 
 | 736 | 			} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 737 | 		case reflect.Slice: | 
 | 738 | 			for j := 0; j < propertyValue.Len(); j++ { | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 739 | 				err := printfIntoProperty(propertyValue.Index(j), variableValue) | 
 | 740 | 				if err != nil { | 
 | 741 | 					printfIntoPropertiesError(ctx, prefix, productVariablePropertyValue, i, err) | 
 | 742 | 				} | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 743 | 			} | 
| Colin Cross | dd0dbe6 | 2015-12-02 15:24:38 -0800 | [diff] [blame] | 744 | 		case reflect.Bool: | 
 | 745 | 			// Nothing | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 746 | 		case reflect.Struct: | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 747 | 			printfIntoProperties(ctx, prefix, propertyValue, variableValue) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 748 | 		default: | 
 | 749 | 			panic(fmt.Errorf("unsupported field kind %q", propertyValue.Kind())) | 
 | 750 | 		} | 
 | 751 | 	} | 
 | 752 | } | 
 | 753 |  | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 754 | func printfIntoProperty(propertyValue reflect.Value, variableValue interface{}) error { | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 755 | 	s := propertyValue.String() | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 756 |  | 
 | 757 | 	count := strings.Count(s, "%") | 
 | 758 | 	if count == 0 { | 
 | 759 | 		return nil | 
 | 760 | 	} | 
 | 761 |  | 
 | 762 | 	if count > 1 { | 
 | 763 | 		return fmt.Errorf("product variable properties only support a single '%%'") | 
 | 764 | 	} | 
 | 765 |  | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 766 | 	if strings.Contains(s, "%d") { | 
 | 767 | 		switch v := variableValue.(type) { | 
 | 768 | 		case int: | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 769 | 			// Nothing | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 770 | 		case bool: | 
 | 771 | 			if v { | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 772 | 				variableValue = 1 | 
 | 773 | 			} else { | 
 | 774 | 				variableValue = 0 | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 775 | 			} | 
 | 776 | 		default: | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 777 | 			return fmt.Errorf("unsupported type %T for %%d", variableValue) | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 778 | 		} | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 779 | 	} else if strings.Contains(s, "%s") { | 
 | 780 | 		switch variableValue.(type) { | 
 | 781 | 		case string: | 
 | 782 | 			// Nothing | 
 | 783 | 		default: | 
 | 784 | 			return fmt.Errorf("unsupported type %T for %%s", variableValue) | 
 | 785 | 		} | 
 | 786 | 	} else { | 
 | 787 | 		return fmt.Errorf("unsupported %% in product variable property") | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 788 | 	} | 
| Colin Cross | 7e0eaf1 | 2017-05-05 16:16:24 -0700 | [diff] [blame] | 789 |  | 
 | 790 | 	propertyValue.Set(reflect.ValueOf(fmt.Sprintf(s, variableValue))) | 
 | 791 |  | 
 | 792 | 	return nil | 
| Colin Cross | 7f64b6d | 2015-07-09 13:57:48 -0700 | [diff] [blame] | 793 | } | 
| Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 794 |  | 
 | 795 | var variablePropTypeMap OncePer | 
 | 796 |  | 
 | 797 | // sliceToTypeArray takes a slice of property structs and returns a reflection created array containing the | 
 | 798 | // reflect.Types of each property struct.  The result can be used as a key in a map. | 
 | 799 | func sliceToTypeArray(s []interface{}) interface{} { | 
 | 800 | 	// Create an array using reflection whose length is the length of the input slice | 
 | 801 | 	ret := reflect.New(reflect.ArrayOf(len(s), reflect.TypeOf(reflect.TypeOf(0)))).Elem() | 
 | 802 | 	for i, e := range s { | 
 | 803 | 		ret.Index(i).Set(reflect.ValueOf(reflect.TypeOf(e))) | 
 | 804 | 	} | 
 | 805 | 	return ret.Interface() | 
 | 806 | } | 
 | 807 |  | 
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 808 | func initProductVariableModule(m Module) { | 
 | 809 | 	base := m.base() | 
 | 810 |  | 
 | 811 | 	// Allow tests to override the default product variables | 
 | 812 | 	if base.variableProperties == nil { | 
 | 813 | 		base.variableProperties = defaultProductVariables | 
 | 814 | 	} | 
 | 815 | 	// Filter the product variables properties to the ones that exist on this module | 
 | 816 | 	base.variableProperties = createVariableProperties(m.GetProperties(), base.variableProperties) | 
 | 817 | 	if base.variableProperties != nil { | 
 | 818 | 		m.AddProperties(base.variableProperties) | 
 | 819 | 	} | 
 | 820 | } | 
 | 821 |  | 
| Colin Cross | 18c4680 | 2019-09-24 22:19:02 -0700 | [diff] [blame] | 822 | // createVariableProperties takes the list of property structs for a module and returns a property struct that | 
 | 823 | // contains the product variable properties that exist in the property structs, or nil if there are none.  It | 
 | 824 | // caches the result. | 
 | 825 | func createVariableProperties(moduleTypeProps []interface{}, productVariables interface{}) interface{} { | 
 | 826 | 	// Convert the moduleTypeProps to an array of reflect.Types that can be used as a key in the OncePer. | 
 | 827 | 	key := sliceToTypeArray(moduleTypeProps) | 
 | 828 |  | 
 | 829 | 	// Use the variablePropTypeMap OncePer to cache the result for each set of property struct types. | 
 | 830 | 	typ, _ := variablePropTypeMap.Once(NewCustomOnceKey(key), func() interface{} { | 
 | 831 | 		// Compute the filtered property struct type. | 
 | 832 | 		return createVariablePropertiesType(moduleTypeProps, productVariables) | 
 | 833 | 	}).(reflect.Type) | 
 | 834 |  | 
 | 835 | 	if typ == nil { | 
 | 836 | 		return nil | 
 | 837 | 	} | 
 | 838 |  | 
 | 839 | 	// Create a new pointer to a filtered property struct. | 
 | 840 | 	return reflect.New(typ).Interface() | 
 | 841 | } | 
 | 842 |  | 
 | 843 | // createVariablePropertiesType creates a new type that contains only the product variable properties that exist in | 
 | 844 | // a list of property structs. | 
 | 845 | func createVariablePropertiesType(moduleTypeProps []interface{}, productVariables interface{}) reflect.Type { | 
 | 846 | 	typ, _ := proptools.FilterPropertyStruct(reflect.TypeOf(productVariables), | 
 | 847 | 		func(field reflect.StructField, prefix string) (bool, reflect.StructField) { | 
 | 848 | 			// Filter function, returns true if the field should be in the resulting struct | 
 | 849 | 			if prefix == "" { | 
 | 850 | 				// Keep the top level Product_variables field | 
 | 851 | 				return true, field | 
 | 852 | 			} | 
 | 853 | 			_, rest := splitPrefix(prefix) | 
 | 854 | 			if rest == "" { | 
 | 855 | 				// Keep the 2nd level field (i.e. Product_variables.Eng) | 
 | 856 | 				return true, field | 
 | 857 | 			} | 
 | 858 |  | 
 | 859 | 			// Strip off the first 2 levels of the prefix | 
 | 860 | 			_, prefix = splitPrefix(rest) | 
 | 861 |  | 
 | 862 | 			for _, p := range moduleTypeProps { | 
 | 863 | 				if fieldExistsByNameRecursive(reflect.TypeOf(p).Elem(), prefix, field.Name) { | 
 | 864 | 					// Keep any fields that exist in one of the property structs | 
 | 865 | 					return true, field | 
 | 866 | 				} | 
 | 867 | 			} | 
 | 868 |  | 
 | 869 | 			return false, field | 
 | 870 | 		}) | 
 | 871 | 	return typ | 
 | 872 | } | 
 | 873 |  | 
 | 874 | func splitPrefix(prefix string) (first, rest string) { | 
 | 875 | 	index := strings.IndexByte(prefix, '.') | 
 | 876 | 	if index == -1 { | 
 | 877 | 		return prefix, "" | 
 | 878 | 	} | 
 | 879 | 	return prefix[:index], prefix[index+1:] | 
 | 880 | } | 
 | 881 |  | 
 | 882 | func fieldExistsByNameRecursive(t reflect.Type, prefix, name string) bool { | 
 | 883 | 	if t.Kind() != reflect.Struct { | 
 | 884 | 		panic(fmt.Errorf("fieldExistsByNameRecursive can only be called on a reflect.Struct")) | 
 | 885 | 	} | 
 | 886 |  | 
 | 887 | 	if prefix != "" { | 
 | 888 | 		split := strings.SplitN(prefix, ".", 2) | 
 | 889 | 		firstPrefix := split[0] | 
 | 890 | 		rest := "" | 
 | 891 | 		if len(split) > 1 { | 
 | 892 | 			rest = split[1] | 
 | 893 | 		} | 
 | 894 | 		f, exists := t.FieldByName(firstPrefix) | 
 | 895 | 		if !exists { | 
 | 896 | 			return false | 
 | 897 | 		} | 
 | 898 | 		ft := f.Type | 
 | 899 | 		if ft.Kind() == reflect.Ptr { | 
 | 900 | 			ft = ft.Elem() | 
 | 901 | 		} | 
 | 902 | 		if ft.Kind() != reflect.Struct { | 
 | 903 | 			panic(fmt.Errorf("field %q in %q is not a struct", firstPrefix, t)) | 
 | 904 | 		} | 
 | 905 | 		return fieldExistsByNameRecursive(ft, rest, name) | 
 | 906 | 	} else { | 
 | 907 | 		_, exists := t.FieldByName(name) | 
 | 908 | 		return exists | 
 | 909 | 	} | 
 | 910 | } |