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