| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [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 | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 16 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 17 | // This is the primary location to write and read all configuration values and | 
|  | 18 | // product variables necessary for soong_build's operation. | 
|  | 19 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 20 | import ( | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 21 | "encoding/json" | 
|  | 22 | "fmt" | 
|  | 23 | "os" | 
| Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 24 | "path/filepath" | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 25 | "runtime" | 
| Inseob Kim | 60c32f0 | 2020-12-21 22:53:05 +0900 | [diff] [blame] | 26 | "strconv" | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 27 | "strings" | 
| Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 28 | "sync" | 
| Cole Faust | d92430e | 2024-02-07 01:02:04 +0000 | [diff] [blame] | 29 | "unicode" | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 30 |  | 
| Yu Liu | 67a2842 | 2024-03-05 00:36:31 +0000 | [diff] [blame] | 31 | "android/soong/shared" | 
|  | 32 |  | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 33 | "github.com/google/blueprint" | 
| Colin Cross | e87040b | 2017-12-11 15:52:26 -0800 | [diff] [blame] | 34 | "github.com/google/blueprint/bootstrap" | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 35 | "github.com/google/blueprint/pathtools" | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 36 | "github.com/google/blueprint/proptools" | 
| Colin Cross | 9d34f35 | 2019-11-22 16:03:51 -0800 | [diff] [blame] | 37 |  | 
|  | 38 | "android/soong/android/soongconfig" | 
| Colin Cross | 77cdcfd | 2021-03-12 11:28:25 -0800 | [diff] [blame] | 39 | "android/soong/remoteexec" | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 40 | ) | 
|  | 41 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 42 | // Bool re-exports proptools.Bool for the android package. | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 43 | var Bool = proptools.Bool | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 44 |  | 
|  | 45 | // String re-exports proptools.String for the android package. | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 46 | var String = proptools.String | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 47 |  | 
|  | 48 | // StringDefault re-exports proptools.StringDefault for the android package. | 
| Jeongik Cha | 219141c | 2020-08-06 23:00:37 +0900 | [diff] [blame] | 49 | var StringDefault = proptools.StringDefault | 
| Jiyong Park | 6a927c4 | 2020-01-21 02:03:43 +0900 | [diff] [blame] | 50 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 51 | // FutureApiLevelInt is a placeholder constant for unreleased API levels. | 
| Dan Albert | 0b176c8 | 2020-07-23 16:43:25 -0700 | [diff] [blame] | 52 | const FutureApiLevelInt = 10000 | 
|  | 53 |  | 
| Spandan Das | 15da588 | 2023-03-02 23:36:39 +0000 | [diff] [blame] | 54 | // PrivateApiLevel represents the api level of SdkSpecPrivate (sdk_version: "") | 
|  | 55 | // This api_level exists to differentiate user-provided "" from "current" sdk_version | 
|  | 56 | // The differentiation is necessary to enable different validation rules for these two possible values. | 
|  | 57 | var PrivateApiLevel = ApiLevel{ | 
|  | 58 | value:     "current",             // The value is current since aidl expects `current` as the default (TestAidlFlagsWithMinSdkVersion) | 
|  | 59 | number:    FutureApiLevelInt + 1, // This is used to differentiate it from FutureApiLevel | 
|  | 60 | isPreview: true, | 
|  | 61 | } | 
|  | 62 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 63 | // FutureApiLevel represents unreleased API levels. | 
| Dan Albert | 0b176c8 | 2020-07-23 16:43:25 -0700 | [diff] [blame] | 64 | var FutureApiLevel = ApiLevel{ | 
|  | 65 | value:     "current", | 
|  | 66 | number:    FutureApiLevelInt, | 
|  | 67 | isPreview: true, | 
|  | 68 | } | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 69 |  | 
| Jingwen Chen | c4d91bc | 2020-11-24 22:59:26 -0500 | [diff] [blame] | 70 | // The product variables file name, containing product config from Kati. | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 71 | const productVariablesFileName = "soong.variables" | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 72 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 73 | // A Config object represents the entire build configuration for Android. | 
| Colin Cross | c3c0a49 | 2015-04-10 15:43:55 -0700 | [diff] [blame] | 74 | type Config struct { | 
|  | 75 | *config | 
|  | 76 | } | 
|  | 77 |  | 
| Chris Parsons | ad87601 | 2022-08-20 14:48:32 -0400 | [diff] [blame] | 78 | type SoongBuildMode int | 
|  | 79 |  | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 80 | type CmdArgs struct { | 
|  | 81 | bootstrap.Args | 
| Kiyoung Kim | a37d9ba | 2023-04-19 13:13:45 +0900 | [diff] [blame] | 82 | RunGoTests     bool | 
|  | 83 | OutDir         string | 
|  | 84 | SoongOutDir    string | 
|  | 85 | SoongVariables string | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 86 |  | 
| Colin Cross | b63d7b3 | 2023-12-07 16:54:51 -0800 | [diff] [blame] | 87 | BazelQueryViewDir string | 
|  | 88 | ModuleGraphFile   string | 
|  | 89 | ModuleActionsFile string | 
|  | 90 | DocFile           string | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 91 |  | 
| Jihoon Kang | 2a929ad | 2023-06-08 19:02:07 +0000 | [diff] [blame] | 92 | BuildFromSourceStub bool | 
| MarkDacek | f47e142 | 2023-04-19 16:47:36 +0000 | [diff] [blame] | 93 |  | 
|  | 94 | EnsureAllowlistIntegrity bool | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 95 | } | 
|  | 96 |  | 
| Chris Parsons | ad87601 | 2022-08-20 14:48:32 -0400 | [diff] [blame] | 97 | // Build modes that soong_build can run as. | 
|  | 98 | const ( | 
|  | 99 | // Don't use bazel at all during module analysis. | 
|  | 100 | AnalysisNoBazel SoongBuildMode = iota | 
|  | 101 |  | 
| Chris Parsons | ad87601 | 2022-08-20 14:48:32 -0400 | [diff] [blame] | 102 | // Generate BUILD files which faithfully represent the dependency graph of | 
|  | 103 | // blueprint modules. Individual BUILD targets will not, however, faitfhully | 
|  | 104 | // express build semantics. | 
|  | 105 | GenerateQueryView | 
|  | 106 |  | 
|  | 107 | // Create a JSON representation of the module graph and exit. | 
|  | 108 | GenerateModuleGraph | 
|  | 109 |  | 
|  | 110 | // Generate a documentation file for module type definitions and exit. | 
|  | 111 | GenerateDocFile | 
| Chris Parsons | ad87601 | 2022-08-20 14:48:32 -0400 | [diff] [blame] | 112 | ) | 
|  | 113 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 114 | const testKeyDir = "build/make/target/product/security" | 
|  | 115 |  | 
| Lukacs T. Berki | b078ade | 2021-08-31 10:42:08 +0200 | [diff] [blame] | 116 | // SoongOutDir returns the build output directory for the configuration. | 
| Lukacs T. Berki | 9f6c24a | 2021-08-26 15:07:24 +0200 | [diff] [blame] | 117 | func (c Config) SoongOutDir() string { | 
|  | 118 | return c.soongOutDir | 
| Jeff Gaston | efc1b41 | 2017-03-29 17:29:06 -0700 | [diff] [blame] | 119 | } | 
|  | 120 |  | 
| Colin Cross | 31a6745 | 2023-11-02 16:57:08 -0700 | [diff] [blame] | 121 | // tempDir returns the path to out/soong/.temp, which is cleared at the beginning of every build. | 
|  | 122 | func (c Config) tempDir() string { | 
|  | 123 | return shared.TempDirForOutDir(c.soongOutDir) | 
|  | 124 | } | 
|  | 125 |  | 
| Lukacs T. Berki | 9f6c24a | 2021-08-26 15:07:24 +0200 | [diff] [blame] | 126 | func (c Config) OutDir() string { | 
| Lukacs T. Berki | d6cee7e | 2021-09-01 16:25:51 +0200 | [diff] [blame] | 127 | return c.outDir | 
| Lukacs T. Berki | 89e9a16 | 2021-03-12 08:31:32 +0100 | [diff] [blame] | 128 | } | 
|  | 129 |  | 
| Lukacs T. Berki | ea1a31c | 2021-09-02 09:58:09 +0200 | [diff] [blame] | 130 | func (c Config) RunGoTests() bool { | 
|  | 131 | return c.runGoTests | 
|  | 132 | } | 
|  | 133 |  | 
| Lukacs T. Berki | 5f6cb1d | 2021-03-17 15:03:14 +0100 | [diff] [blame] | 134 | func (c Config) DebugCompilation() bool { | 
|  | 135 | return false // Never compile Go code in the main build for debugging | 
|  | 136 | } | 
|  | 137 |  | 
| Lukacs T. Berki | ea1a31c | 2021-09-02 09:58:09 +0200 | [diff] [blame] | 138 | func (c Config) Subninjas() []string { | 
|  | 139 | return []string{} | 
|  | 140 | } | 
|  | 141 |  | 
|  | 142 | func (c Config) PrimaryBuilderInvocations() []bootstrap.PrimaryBuilderInvocation { | 
|  | 143 | return []bootstrap.PrimaryBuilderInvocation{} | 
|  | 144 | } | 
|  | 145 |  | 
| Paul Duffin | 7413558 | 2022-10-06 11:01:59 +0100 | [diff] [blame] | 146 | // RunningInsideUnitTest returns true if this code is being run as part of a Soong unit test. | 
|  | 147 | func (c Config) RunningInsideUnitTest() bool { | 
|  | 148 | return c.config.TestProductVariables != nil | 
|  | 149 | } | 
|  | 150 |  | 
| Pratyush | faec4db | 2023-07-20 11:19:04 +0000 | [diff] [blame] | 151 | // DisableHiddenApiChecks returns true if hiddenapi checks have been disabled. | 
| Alyssa Ketpreechasawat | 7daf278 | 2023-11-01 13:58:39 +0000 | [diff] [blame] | 152 | // For 'eng' target variant hiddenapi checks are disabled by default for performance optimisation, | 
| Pratyush | faec4db | 2023-07-20 11:19:04 +0000 | [diff] [blame] | 153 | // but can be enabled by setting environment variable ENABLE_HIDDENAPI_FLAGS=true. | 
|  | 154 | // For other target variants hiddenapi check are enabled by default but can be disabled by | 
|  | 155 | // setting environment variable UNSAFE_DISABLE_HIDDENAPI_FLAGS=true. | 
|  | 156 | // If both ENABLE_HIDDENAPI_FLAGS=true and UNSAFE_DISABLE_HIDDENAPI_FLAGS=true, then | 
|  | 157 | // ENABLE_HIDDENAPI_FLAGS=true will be triggered and hiddenapi checks will be considered enabled. | 
|  | 158 | func (c Config) DisableHiddenApiChecks() bool { | 
|  | 159 | return !c.IsEnvTrue("ENABLE_HIDDENAPI_FLAGS") && | 
|  | 160 | (c.IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") || | 
| Alyssa Ketpreechasawat | 7daf278 | 2023-11-01 13:58:39 +0000 | [diff] [blame] | 161 | Bool(c.productVariables.Eng)) | 
|  | 162 | } | 
|  | 163 |  | 
|  | 164 | // DisableVerifyOverlaps returns true if verify_overlaps is skipped. | 
|  | 165 | // Mismatch in version of apexes and module SDK is required for mainline prebuilts to work in | 
|  | 166 | // trunk stable. | 
|  | 167 | // Thus, verify_overlaps is disabled when RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE is set to false. | 
|  | 168 | // TODO(b/308174018): Re-enable verify_overlaps for both builr from source/mainline prebuilts. | 
|  | 169 | func (c Config) DisableVerifyOverlaps() bool { | 
| Spandan Das | 0714510 | 2024-03-18 23:25:30 +0000 | [diff] [blame] | 170 | if c.IsEnvFalse("DISABLE_VERIFY_OVERLAPS") && c.ReleaseDisableVerifyOverlaps() { | 
|  | 171 | panic("The current release configuration does not support verify_overlaps. DISABLE_VERIFY_OVERLAPS cannot be set to false") | 
|  | 172 | } | 
|  | 173 | return c.IsEnvTrue("DISABLE_VERIFY_OVERLAPS") || c.ReleaseDisableVerifyOverlaps() || !c.ReleaseDefaultModuleBuildFromSource() | 
| Pratyush | faec4db | 2023-07-20 11:19:04 +0000 | [diff] [blame] | 174 | } | 
|  | 175 |  | 
| Juan Yescas | 05d4d90 | 2023-04-07 10:35:35 -0700 | [diff] [blame] | 176 | // MaxPageSizeSupported returns the max page size supported by the device. This | 
|  | 177 | // value will define the ELF segment alignment for binaries (executables and | 
|  | 178 | // shared libraries). | 
|  | 179 | func (c Config) MaxPageSizeSupported() string { | 
|  | 180 | return String(c.config.productVariables.DeviceMaxPageSizeSupported) | 
|  | 181 | } | 
|  | 182 |  | 
| Vilas Bhat | b3d2d22 | 2023-12-04 22:51:20 +0000 | [diff] [blame] | 183 | // NoBionicPageSizeMacro returns true when AOSP is page size agnostic. | 
|  | 184 | // This means that the bionic's macro PAGE_SIZE won't be defined. | 
|  | 185 | // Returns false when AOSP is NOT page size agnostic. | 
|  | 186 | // This means that bionic's macro PAGE_SIZE is defined. | 
|  | 187 | func (c Config) NoBionicPageSizeMacro() bool { | 
|  | 188 | return Bool(c.config.productVariables.DeviceNoBionicPageSizeMacro) | 
| Juan Yescas | 0106560 | 2023-08-09 08:34:37 -0700 | [diff] [blame] | 189 | } | 
|  | 190 |  | 
| Joe Onorato | fee845a | 2023-05-09 08:14:14 -0700 | [diff] [blame] | 191 | // The release version passed to aconfig, derived from RELEASE_VERSION | 
|  | 192 | func (c Config) ReleaseVersion() string { | 
|  | 193 | return c.config.productVariables.ReleaseVersion | 
|  | 194 | } | 
|  | 195 |  | 
| Yu Liu | 2cc802a | 2023-09-05 17:19:45 -0700 | [diff] [blame] | 196 | // The aconfig value set passed to aconfig, derived from RELEASE_VERSION | 
| Yu Liu | eebb259 | 2023-10-12 20:31:27 -0700 | [diff] [blame] | 197 | func (c Config) ReleaseAconfigValueSets() []string { | 
| Yu Liu | 95572ff | 2023-12-07 16:38:45 -0800 | [diff] [blame] | 198 | return c.config.productVariables.ReleaseAconfigValueSets | 
| Joe Onorato | fee845a | 2023-05-09 08:14:14 -0700 | [diff] [blame] | 199 | } | 
|  | 200 |  | 
| LaMont Jones | 21d04d9 | 2024-06-11 11:28:54 -0700 | [diff] [blame] | 201 | func (c Config) ReleaseAconfigExtraReleaseConfigs() []string { | 
|  | 202 | result := []string{} | 
|  | 203 | if val, ok := c.config.productVariables.BuildFlags["RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS"]; ok { | 
|  | 204 | if len(val) > 0 { | 
|  | 205 | // Remove any duplicates from the list. | 
|  | 206 | found := make(map[string]bool) | 
|  | 207 | for _, k := range strings.Split(val, " ") { | 
|  | 208 | if !found[k] { | 
|  | 209 | found[k] = true | 
|  | 210 | result = append(result, k) | 
|  | 211 | } | 
|  | 212 | } | 
|  | 213 | } | 
|  | 214 | } | 
|  | 215 | return result | 
|  | 216 | } | 
|  | 217 |  | 
|  | 218 | func (c Config) ReleaseAconfigExtraReleaseConfigsValueSets() map[string][]string { | 
|  | 219 | result := make(map[string][]string) | 
|  | 220 | for _, rcName := range c.ReleaseAconfigExtraReleaseConfigs() { | 
|  | 221 | if value, ok := c.config.productVariables.BuildFlags["RELEASE_ACONFIG_VALUE_SETS_"+rcName]; ok { | 
|  | 222 | result[rcName] = strings.Split(value, " ") | 
|  | 223 | } | 
|  | 224 | } | 
|  | 225 | return result | 
|  | 226 | } | 
|  | 227 |  | 
| Zhi Dou | 3f65a41 | 2023-08-10 21:47:40 +0000 | [diff] [blame] | 228 | // The flag default permission value passed to aconfig | 
|  | 229 | // derived from RELEASE_ACONFIG_FLAG_DEFAULT_PERMISSION | 
|  | 230 | func (c Config) ReleaseAconfigFlagDefaultPermission() string { | 
|  | 231 | return c.config.productVariables.ReleaseAconfigFlagDefaultPermission | 
|  | 232 | } | 
|  | 233 |  | 
| Alyssa Ketpreechasawat | 34ab879 | 2023-10-06 07:01:22 +0000 | [diff] [blame] | 234 | // The flag indicating behavior for the tree wrt building modules or using prebuilts | 
|  | 235 | // derived from RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE | 
|  | 236 | func (c Config) ReleaseDefaultModuleBuildFromSource() bool { | 
|  | 237 | return c.config.productVariables.ReleaseDefaultModuleBuildFromSource == nil || | 
|  | 238 | Bool(c.config.productVariables.ReleaseDefaultModuleBuildFromSource) | 
|  | 239 | } | 
|  | 240 |  | 
| Spandan Das | 0714510 | 2024-03-18 23:25:30 +0000 | [diff] [blame] | 241 | func (c Config) ReleaseDisableVerifyOverlaps() bool { | 
|  | 242 | return c.config.productVariables.GetBuildFlagBool("RELEASE_DISABLE_VERIFY_OVERLAPS_CHECK") | 
|  | 243 | } | 
|  | 244 |  | 
| Jihoon Kang | 5919815 | 2024-02-06 22:43:18 +0000 | [diff] [blame] | 245 | // Enables flagged apis annotated with READ_WRITE aconfig flags to be included in the stubs | 
|  | 246 | // and hiddenapi flags so that they are accessible at runtime | 
|  | 247 | func (c Config) ReleaseExportRuntimeApis() bool { | 
| Jihoon Kang | 3534946 | 2024-02-22 19:52:46 +0000 | [diff] [blame] | 248 | return Bool(c.config.productVariables.ExportRuntimeApis) | 
| Jihoon Kang | 5919815 | 2024-02-06 22:43:18 +0000 | [diff] [blame] | 249 | } | 
|  | 250 |  | 
| Aleksei Vetrov | 146e982 | 2023-11-24 19:54:26 +0000 | [diff] [blame] | 251 | // Enables ABI monitoring of NDK libraries | 
|  | 252 | func (c Config) ReleaseNdkAbiMonitored() bool { | 
|  | 253 | return c.config.productVariables.GetBuildFlagBool("RELEASE_NDK_ABI_MONITORED") | 
|  | 254 | } | 
|  | 255 |  | 
| Ted Bauer | 10fff94 | 2024-04-29 19:30:23 +0000 | [diff] [blame] | 256 | // Enable read flag from new storage, for C/C++ | 
|  | 257 | func (c Config) ReleaseReadFromNewStorageCc() bool { | 
|  | 258 | return c.config.productVariables.GetBuildFlagBool("RELEASE_READ_FROM_NEW_STORAGE_CC") | 
|  | 259 | } | 
|  | 260 |  | 
| Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 261 | func (c Config) ReleaseHiddenApiExportableStubs() bool { | 
| Jihoon Kang | b36fc54 | 2024-02-22 19:35:26 +0000 | [diff] [blame] | 262 | return c.config.productVariables.GetBuildFlagBool("RELEASE_HIDDEN_API_EXPORTABLE_STUBS") || | 
|  | 263 | Bool(c.config.productVariables.HiddenapiExportableStubs) | 
| Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 264 | } | 
|  | 265 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 266 | // A DeviceConfig object represents the configuration for a particular device | 
|  | 267 | // being built. For now there will only be one of these, but in the future there | 
|  | 268 | // may be multiple devices being built. | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 269 | type DeviceConfig struct { | 
|  | 270 | *deviceConfig | 
|  | 271 | } | 
|  | 272 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 273 | // VendorConfig represents the configuration for vendor-specific behavior. | 
| Colin Cross | 9d34f35 | 2019-11-22 16:03:51 -0800 | [diff] [blame] | 274 | type VendorConfig soongconfig.SoongConfig | 
| Dan Willemsen | 0fe7866 | 2018-03-26 12:41:18 -0700 | [diff] [blame] | 275 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 276 | // Definition of general build configuration for soong_build. Some of these | 
| Jingwen Chen | c4d91bc | 2020-11-24 22:59:26 -0500 | [diff] [blame] | 277 | // product configuration values are read from Kati-generated soong.variables. | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 278 | type config struct { | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 279 | // Options configurable with soong.variables | 
| Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 280 | productVariables ProductVariables | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 281 |  | 
| Dan Willemsen | 674dc7f | 2018-03-12 18:06:05 -0700 | [diff] [blame] | 282 | // Only available on configs created by TestConfig | 
| Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 283 | TestProductVariables *ProductVariables | 
| Dan Willemsen | 674dc7f | 2018-03-12 18:06:05 -0700 | [diff] [blame] | 284 |  | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 285 | ProductVariablesFileName string | 
|  | 286 |  | 
| Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 287 | // BuildOS stores the OsType for the OS that the build is running on. | 
|  | 288 | BuildOS OsType | 
|  | 289 |  | 
|  | 290 | // BuildArch stores the ArchType for the CPU that the build is running on. | 
|  | 291 | BuildArch ArchType | 
|  | 292 |  | 
| Jaewoong Jung | 642916f | 2020-10-09 17:25:15 -0700 | [diff] [blame] | 293 | Targets                  map[OsType][]Target | 
|  | 294 | BuildOSTarget            Target // the Target for tools run on the build machine | 
|  | 295 | BuildOSCommonTarget      Target // the Target for common (java) tools run on the build machine | 
|  | 296 | AndroidCommonTarget      Target // the Target for common modules for the Android device | 
|  | 297 | AndroidFirstDeviceTarget Target // the first Target for modules for the Android device | 
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 298 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 299 | // multilibConflicts for an ArchType is true if there is earlier configured | 
|  | 300 | // device architecture with the same multilib value. | 
| Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 301 | multilibConflicts map[ArchType]bool | 
|  | 302 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 303 | deviceConfig *deviceConfig | 
|  | 304 |  | 
| Lukacs T. Berki | d6cee7e | 2021-09-01 16:25:51 +0200 | [diff] [blame] | 305 | outDir         string // The output directory (usually out/) | 
|  | 306 | soongOutDir    string | 
| Chris Parsons | 8f232a2 | 2020-06-23 17:37:05 -0400 | [diff] [blame] | 307 | moduleListFile string // the path to the file which lists blueprint files to parse. | 
| Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 308 |  | 
| Lukacs T. Berki | e1df43f | 2021-09-08 15:31:14 +0200 | [diff] [blame] | 309 | runGoTests bool | 
| Lukacs T. Berki | ea1a31c | 2021-09-02 09:58:09 +0200 | [diff] [blame] | 310 |  | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 311 | env       map[string]string | 
| Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 312 | envLock   sync.Mutex | 
|  | 313 | envDeps   map[string]string | 
|  | 314 | envFrozen bool | 
| Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 315 |  | 
| Jingwen Chen | cda22c9 | 2020-11-23 00:22:30 -0500 | [diff] [blame] | 316 | // Changes behavior based on whether Kati runs after soong_build, or if soong_build | 
|  | 317 | // runs standalone. | 
|  | 318 | katiEnabled bool | 
| Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 319 |  | 
| Colin Cross | 32616ed | 2017-09-05 21:56:44 -0700 | [diff] [blame] | 320 | captureBuild      bool // true for tests, saves build parameters for each module | 
|  | 321 | ignoreEnvironment bool // true for tests, returns empty from all Getenv calls | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 322 |  | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 323 | fs         pathtools.FileSystem | 
|  | 324 | mockBpList string | 
|  | 325 |  | 
| Colin Cross | b63d7b3 | 2023-12-07 16:54:51 -0800 | [diff] [blame] | 326 | BuildMode SoongBuildMode | 
| Jingwen Chen | 12b4c27 | 2021-03-10 02:05:59 -0500 | [diff] [blame] | 327 |  | 
| Colin Cross | 5e6a797 | 2020-06-07 16:56:32 -0700 | [diff] [blame] | 328 | // If testAllowNonExistentPaths is true then PathForSource and PathForModuleSrc won't error | 
|  | 329 | // in tests when a path doesn't exist. | 
| Pedro Loureiro | 5d190cc | 2021-02-15 15:41:33 +0000 | [diff] [blame] | 330 | TestAllowNonExistentPaths bool | 
| Colin Cross | 5e6a797 | 2020-06-07 16:56:32 -0700 | [diff] [blame] | 331 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 332 | // The list of files that when changed, must invalidate soong_build to | 
|  | 333 | // regenerate build.ninja. | 
| Colin Cross | 1212929 | 2020-10-29 18:23:58 -0700 | [diff] [blame] | 334 | ninjaFileDepsSet sync.Map | 
|  | 335 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 336 | OncePer | 
| MarkDacek | ff851b8 | 2022-04-21 18:33:17 +0000 | [diff] [blame] | 337 |  | 
| Jihoon Kang | 2a929ad | 2023-06-08 19:02:07 +0000 | [diff] [blame] | 338 | // If buildFromSourceStub is true then the Java API stubs are | 
|  | 339 | // built from the source Java files, not the signature text files. | 
|  | 340 | buildFromSourceStub bool | 
| MarkDacek | f47e142 | 2023-04-19 16:47:36 +0000 | [diff] [blame] | 341 |  | 
|  | 342 | // If ensureAllowlistIntegrity is true, then the presence of any allowlisted | 
|  | 343 | // modules that aren't mixed-built for at least one variant will cause a build | 
|  | 344 | // failure | 
|  | 345 | ensureAllowlistIntegrity bool | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 346 |  | 
|  | 347 | // List of Api libraries that contribute to Api surfaces. | 
|  | 348 | apiLibraries map[string]struct{} | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 349 | } | 
|  | 350 |  | 
|  | 351 | type deviceConfig struct { | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 352 | config *config | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 353 | OncePer | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 354 | } | 
|  | 355 |  | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 356 | type jsonConfigurable interface { | 
| Colin Cross | 2738597 | 2015-09-18 10:57:10 -0700 | [diff] [blame] | 357 | SetDefaultConfig() | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 358 | } | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 359 |  | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 360 | func loadConfig(config *config) error { | 
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 361 | return loadFromConfigFile(&config.productVariables, absolutePath(config.ProductVariablesFileName)) | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 362 | } | 
|  | 363 |  | 
| Cole Faust | d92430e | 2024-02-07 01:02:04 +0000 | [diff] [blame] | 364 | // Checks if the string is a valid go identifier. This is equivalent to blueprint's definition | 
|  | 365 | // of an identifier, so it will match the same identifiers as those that can be used in bp files. | 
|  | 366 | func isGoIdentifier(ident string) bool { | 
|  | 367 | for i, r := range ident { | 
|  | 368 | valid := r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r) && i > 0 | 
|  | 369 | if !valid { | 
|  | 370 | return false | 
|  | 371 | } | 
|  | 372 | } | 
|  | 373 | return len(ident) > 0 | 
|  | 374 | } | 
|  | 375 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 376 | // loadFromConfigFile loads and decodes configuration options from a JSON file | 
|  | 377 | // in the current working directory. | 
| Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 378 | func loadFromConfigFile(configurable *ProductVariables, filename string) error { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 379 | // Try to open the file | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 380 | configFileReader, err := os.Open(filename) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 381 | defer configFileReader.Close() | 
|  | 382 | if os.IsNotExist(err) { | 
|  | 383 | // Need to create a file, so that blueprint & ninja don't get in | 
|  | 384 | // a dependency tracking loop. | 
|  | 385 | // Make a file-configurable-options with defaults, write it out using | 
|  | 386 | // a json writer. | 
| Colin Cross | 2738597 | 2015-09-18 10:57:10 -0700 | [diff] [blame] | 387 | configurable.SetDefaultConfig() | 
|  | 388 | err = saveToConfigFile(configurable, filename) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 389 | if err != nil { | 
|  | 390 | return err | 
|  | 391 | } | 
| Colin Cross | 15cd21a | 2018-02-27 11:26:02 -0800 | [diff] [blame] | 392 | } else if err != nil { | 
|  | 393 | return fmt.Errorf("config file: could not open %s: %s", filename, err.Error()) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 394 | } else { | 
|  | 395 | // Make a decoder for it | 
|  | 396 | jsonDecoder := json.NewDecoder(configFileReader) | 
| Cole Faust | e1129b8 | 2024-06-04 11:10:11 -0700 | [diff] [blame] | 397 | jsonDecoder.DisallowUnknownFields() | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 398 | err = jsonDecoder.Decode(configurable) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 399 | if err != nil { | 
| Colin Cross | 15cd21a | 2018-02-27 11:26:02 -0800 | [diff] [blame] | 400 | return fmt.Errorf("config file: %s did not parse correctly: %s", filename, err.Error()) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 401 | } | 
|  | 402 | } | 
|  | 403 |  | 
| Liz Kammer | 09f947d | 2021-05-12 14:51:49 -0400 | [diff] [blame] | 404 | if Bool(configurable.GcovCoverage) && Bool(configurable.ClangCoverage) { | 
|  | 405 | return fmt.Errorf("GcovCoverage and ClangCoverage cannot both be set") | 
|  | 406 | } | 
|  | 407 |  | 
|  | 408 | configurable.Native_coverage = proptools.BoolPtr( | 
|  | 409 | Bool(configurable.GcovCoverage) || | 
|  | 410 | Bool(configurable.ClangCoverage)) | 
|  | 411 |  | 
| Cole Faust | d92430e | 2024-02-07 01:02:04 +0000 | [diff] [blame] | 412 | // The go scanner's definition of identifiers is c-style identifiers, but allowing unicode's | 
|  | 413 | // definition of letters and digits. This is the same scanner that blueprint uses, so it | 
|  | 414 | // will allow the same identifiers as are valid in bp files. | 
|  | 415 | for namespace := range configurable.VendorVars { | 
|  | 416 | if !isGoIdentifier(namespace) { | 
|  | 417 | return fmt.Errorf("soong config namespaces must be valid identifiers: %q", namespace) | 
|  | 418 | } | 
|  | 419 | for variable := range configurable.VendorVars[namespace] { | 
|  | 420 | if !isGoIdentifier(variable) { | 
|  | 421 | return fmt.Errorf("soong config variables must be valid identifiers: %q", variable) | 
|  | 422 | } | 
|  | 423 | } | 
|  | 424 | } | 
|  | 425 |  | 
| Yuntao Xu | 402e9b0 | 2021-08-09 15:44:44 -0700 | [diff] [blame] | 426 | // when Platform_sdk_final is true (or PLATFORM_VERSION_CODENAME is REL), use Platform_sdk_version; | 
|  | 427 | // if false (pre-released version, for example), use Platform_sdk_codename. | 
|  | 428 | if Bool(configurable.Platform_sdk_final) { | 
|  | 429 | if configurable.Platform_sdk_version != nil { | 
|  | 430 | configurable.Platform_sdk_version_or_codename = | 
|  | 431 | proptools.StringPtr(strconv.Itoa(*(configurable.Platform_sdk_version))) | 
|  | 432 | } else { | 
|  | 433 | return fmt.Errorf("Platform_sdk_version cannot be pointed by a NULL pointer") | 
|  | 434 | } | 
|  | 435 | } else { | 
|  | 436 | configurable.Platform_sdk_version_or_codename = | 
|  | 437 | proptools.StringPtr(String(configurable.Platform_sdk_codename)) | 
|  | 438 | } | 
|  | 439 |  | 
| Cole Faust | ad18649 | 2024-06-14 14:13:54 -0700 | [diff] [blame] | 440 | return nil | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 441 | } | 
|  | 442 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 443 | // atomically writes the config file in case two copies of soong_build are running simultaneously | 
|  | 444 | // (for example, docs generation and ninja manifest generation) | 
| Cole Faust | f8231dd | 2023-04-21 17:37:11 -0700 | [diff] [blame] | 445 | func saveToConfigFile(config *ProductVariables, filename string) error { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 446 | data, err := json.MarshalIndent(&config, "", "    ") | 
|  | 447 | if err != nil { | 
|  | 448 | return fmt.Errorf("cannot marshal config data: %s", err.Error()) | 
|  | 449 | } | 
|  | 450 |  | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 451 | f, err := os.CreateTemp(filepath.Dir(filename), "config") | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 452 | if err != nil { | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 453 | return fmt.Errorf("cannot create empty config file %s: %s", filename, err.Error()) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 454 | } | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 455 | defer os.Remove(f.Name()) | 
|  | 456 | defer f.Close() | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 457 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 458 | _, err = f.Write(data) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 459 | if err != nil { | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 460 | return fmt.Errorf("default config file: %s could not be written: %s", filename, err.Error()) | 
|  | 461 | } | 
|  | 462 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 463 | _, err = f.WriteString("\n") | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 464 | if err != nil { | 
|  | 465 | return fmt.Errorf("default config file: %s could not be written: %s", filename, err.Error()) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 466 | } | 
|  | 467 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 468 | f.Close() | 
|  | 469 | os.Rename(f.Name(), filename) | 
|  | 470 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 471 | return nil | 
|  | 472 | } | 
|  | 473 |  | 
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 474 | // NullConfig returns a mostly empty Config for use by standalone tools like dexpreopt_gen that | 
|  | 475 | // use the android package. | 
| Lukacs T. Berki | d6cee7e | 2021-09-01 16:25:51 +0200 | [diff] [blame] | 476 | func NullConfig(outDir, soongOutDir string) Config { | 
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 477 | return Config{ | 
|  | 478 | config: &config{ | 
| Lukacs T. Berki | d6cee7e | 2021-09-01 16:25:51 +0200 | [diff] [blame] | 479 | outDir:      outDir, | 
| Lukacs T. Berki | 9f6c24a | 2021-08-26 15:07:24 +0200 | [diff] [blame] | 480 | soongOutDir: soongOutDir, | 
|  | 481 | fs:          pathtools.OsFs, | 
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 482 | }, | 
|  | 483 | } | 
|  | 484 | } | 
|  | 485 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 486 | // NewConfig creates a new Config object. The srcDir argument specifies the path | 
|  | 487 | // to the root source directory. It also loads the config file, if found. | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 488 | func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) { | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 489 | // Make a config with default options. | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 490 | config := &config{ | 
| Kiyoung Kim | a37d9ba | 2023-04-19 13:13:45 +0900 | [diff] [blame] | 491 | ProductVariablesFileName: cmdArgs.SoongVariables, | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 492 |  | 
| Lukacs T. Berki | 53b2f36 | 2021-04-12 14:04:24 +0200 | [diff] [blame] | 493 | env: availableEnv, | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 494 |  | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 495 | outDir:            cmdArgs.OutDir, | 
|  | 496 | soongOutDir:       cmdArgs.SoongOutDir, | 
|  | 497 | runGoTests:        cmdArgs.RunGoTests, | 
| Lukacs T. Berki | e1df43f | 2021-09-08 15:31:14 +0200 | [diff] [blame] | 498 | multilibConflicts: make(map[ArchType]bool), | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 499 |  | 
| Colin Cross | b63d7b3 | 2023-12-07 16:54:51 -0800 | [diff] [blame] | 500 | moduleListFile: cmdArgs.ModuleListFile, | 
|  | 501 | fs:             pathtools.NewOsFs(absSrcDir), | 
| Chris Parsons | 9402ca8 | 2023-02-23 17:28:06 -0500 | [diff] [blame] | 502 |  | 
| Jihoon Kang | 2a929ad | 2023-06-08 19:02:07 +0000 | [diff] [blame] | 503 | buildFromSourceStub: cmdArgs.BuildFromSourceStub, | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 504 | } | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 505 |  | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 506 | config.deviceConfig = &deviceConfig{ | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 507 | config: config, | 
|  | 508 | } | 
|  | 509 |  | 
| Liz Kammer | 7941b30 | 2020-07-28 13:27:34 -0700 | [diff] [blame] | 510 | // Soundness check of the build and source directories. This won't catch strange | 
|  | 511 | // configurations with symlinks, but at least checks the obvious case. | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 512 | absBuildDir, err := filepath.Abs(cmdArgs.SoongOutDir) | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 513 | if err != nil { | 
|  | 514 | return Config{}, err | 
|  | 515 | } | 
|  | 516 |  | 
| Lukacs T. Berki | f7e36d8 | 2021-08-16 17:05:09 +0200 | [diff] [blame] | 517 | absSrcDir, err := filepath.Abs(".") | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 518 | if err != nil { | 
|  | 519 | return Config{}, err | 
|  | 520 | } | 
|  | 521 |  | 
|  | 522 | if strings.HasPrefix(absSrcDir, absBuildDir) { | 
|  | 523 | return Config{}, fmt.Errorf("Build dir must not contain source directory") | 
|  | 524 | } | 
|  | 525 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 526 | // Load any configurable options from the configuration file | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 527 | err = loadConfig(config) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 528 | if err != nil { | 
| Colin Cross | c3c0a49 | 2015-04-10 15:43:55 -0700 | [diff] [blame] | 529 | return Config{}, err | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 530 | } | 
|  | 531 |  | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 532 | KatiEnabledMarkerFile := filepath.Join(cmdArgs.SoongOutDir, ".soong.kati_enabled") | 
| Jingwen Chen | cda22c9 | 2020-11-23 00:22:30 -0500 | [diff] [blame] | 533 | if _, err := os.Stat(absolutePath(KatiEnabledMarkerFile)); err == nil { | 
|  | 534 | config.katiEnabled = true | 
| Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 535 | } | 
|  | 536 |  | 
| Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 537 | determineBuildOS(config) | 
|  | 538 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 539 | // Sets up the map of target OSes to the finer grained compilation targets | 
|  | 540 | // that are configured from the product variables. | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 541 | targets, err := decodeTargetProductVariables(config) | 
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 542 | if err != nil { | 
|  | 543 | return Config{}, err | 
|  | 544 | } | 
|  | 545 |  | 
| Paul Duffin | 1356d8c | 2020-02-25 19:26:33 +0000 | [diff] [blame] | 546 | // Make the CommonOS OsType available for all products. | 
|  | 547 | targets[CommonOS] = []Target{commonTargetMap[CommonOS.Name]} | 
|  | 548 |  | 
| Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame] | 549 | var archConfig []archConfig | 
| Jingwen Chen | c4d91bc | 2020-11-24 22:59:26 -0500 | [diff] [blame] | 550 | if config.NdkAbis() { | 
| Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame] | 551 | archConfig = getNdkAbisConfig() | 
| Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 552 | } else if config.AmlAbis() { | 
|  | 553 | archConfig = getAmlAbisConfig() | 
| Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame] | 554 | } | 
|  | 555 |  | 
|  | 556 | if archConfig != nil { | 
| Liz Kammer | b7f3366 | 2022-02-28 14:16:16 -0500 | [diff] [blame] | 557 | androidTargets, err := decodeAndroidArchSettings(archConfig) | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 558 | if err != nil { | 
|  | 559 | return Config{}, err | 
|  | 560 | } | 
| Dan Willemsen | 0ef639b | 2018-10-10 17:02:29 -0700 | [diff] [blame] | 561 | targets[Android] = androidTargets | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 562 | } | 
|  | 563 |  | 
| Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 564 | multilib := make(map[string]bool) | 
|  | 565 | for _, target := range targets[Android] { | 
|  | 566 | if seen := multilib[target.Arch.ArchType.Multilib]; seen { | 
|  | 567 | config.multilibConflicts[target.Arch.ArchType] = true | 
|  | 568 | } | 
|  | 569 | multilib[target.Arch.ArchType.Multilib] = true | 
|  | 570 | } | 
|  | 571 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 572 | // Map of OS to compilation targets. | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 573 | config.Targets = targets | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 574 |  | 
|  | 575 | // Compilation targets for host tools. | 
| Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 576 | config.BuildOSTarget = config.Targets[config.BuildOS][0] | 
|  | 577 | config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0] | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 578 |  | 
|  | 579 | // Compilation targets for Android. | 
| Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 580 | if len(config.Targets[Android]) > 0 { | 
|  | 581 | config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0] | 
| Sam Delmerico | cc271e2 | 2022-06-01 15:45:02 +0000 | [diff] [blame] | 582 | config.AndroidFirstDeviceTarget = FirstTarget(config.Targets[Android], "lib64", "lib32")[0] | 
| Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 583 | } | 
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 584 |  | 
| Usta Shrestha | cae3bfa | 2022-12-21 11:44:26 -0500 | [diff] [blame] | 585 | setBuildMode := func(arg string, mode SoongBuildMode) { | 
|  | 586 | if arg != "" { | 
|  | 587 | if config.BuildMode != AnalysisNoBazel { | 
|  | 588 | fmt.Fprintf(os.Stderr, "buildMode is already set, illegal argument: %s", arg) | 
|  | 589 | os.Exit(1) | 
|  | 590 | } | 
|  | 591 | config.BuildMode = mode | 
|  | 592 | } | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 593 | } | 
| Usta Shrestha | cae3bfa | 2022-12-21 11:44:26 -0500 | [diff] [blame] | 594 | setBuildMode(cmdArgs.BazelQueryViewDir, GenerateQueryView) | 
| Usta Shrestha | cae3bfa | 2022-12-21 11:44:26 -0500 | [diff] [blame] | 595 | setBuildMode(cmdArgs.ModuleGraphFile, GenerateModuleGraph) | 
|  | 596 | setBuildMode(cmdArgs.DocFile, GenerateDocFile) | 
| MarkDacek | d06db5d | 2022-11-29 00:47:59 +0000 | [diff] [blame] | 597 |  | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 598 | // TODO(b/276958307): Replace the hardcoded list to a sdk_library local prop. | 
|  | 599 | config.apiLibraries = map[string]struct{}{ | 
|  | 600 | "android.net.ipsec.ike":             {}, | 
|  | 601 | "art.module.public.api":             {}, | 
|  | 602 | "conscrypt.module.public.api":       {}, | 
|  | 603 | "framework-adservices":              {}, | 
|  | 604 | "framework-appsearch":               {}, | 
|  | 605 | "framework-bluetooth":               {}, | 
| Jihoon Kang | 480943f | 2023-05-19 06:02:08 +0000 | [diff] [blame] | 606 | "framework-configinfrastructure":    {}, | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 607 | "framework-connectivity":            {}, | 
|  | 608 | "framework-connectivity-t":          {}, | 
| Jihoon Kang | 480943f | 2023-05-19 06:02:08 +0000 | [diff] [blame] | 609 | "framework-devicelock":              {}, | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 610 | "framework-graphics":                {}, | 
| Jihoon Kang | 480943f | 2023-05-19 06:02:08 +0000 | [diff] [blame] | 611 | "framework-healthfitness":           {}, | 
| Mark White | 387a658 | 2023-08-06 00:20:47 +0000 | [diff] [blame] | 612 | "framework-location":                {}, | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 613 | "framework-media":                   {}, | 
|  | 614 | "framework-mediaprovider":           {}, | 
| Roshan Pius | 92307ff | 2023-11-13 17:16:35 -0800 | [diff] [blame] | 615 | "framework-nfc":                     {}, | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 616 | "framework-ondevicepersonalization": {}, | 
| Alyssa Ketpreechasawat | 9f63436 | 2023-11-08 16:03:53 +0000 | [diff] [blame] | 617 | "framework-pdf":                     {}, | 
| Nishant Panwar | 0ce9465 | 2024-02-10 09:02:15 +0000 | [diff] [blame] | 618 | "framework-pdf-v":                   {}, | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 619 | "framework-permission":              {}, | 
|  | 620 | "framework-permission-s":            {}, | 
|  | 621 | "framework-scheduling":              {}, | 
|  | 622 | "framework-sdkextensions":           {}, | 
|  | 623 | "framework-statsd":                  {}, | 
|  | 624 | "framework-sdksandbox":              {}, | 
|  | 625 | "framework-tethering":               {}, | 
|  | 626 | "framework-uwb":                     {}, | 
|  | 627 | "framework-virtualization":          {}, | 
|  | 628 | "framework-wifi":                    {}, | 
|  | 629 | "i18n.module.public.api":            {}, | 
|  | 630 | } | 
|  | 631 |  | 
| Jihoon Kang | c1b04d6 | 2023-11-16 19:07:04 +0000 | [diff] [blame] | 632 | config.productVariables.Build_from_text_stub = boolPtr(config.BuildFromTextStub()) | 
|  | 633 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 634 | return Config{config}, err | 
|  | 635 | } | 
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 636 |  | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 637 | // mockFileSystem replaces all reads with accesses to the provided map of | 
|  | 638 | // filenames to contents stored as a byte slice. | 
|  | 639 | func (c *config) mockFileSystem(bp string, fs map[string][]byte) { | 
|  | 640 | mockFS := map[string][]byte{} | 
|  | 641 |  | 
|  | 642 | if _, exists := mockFS["Android.bp"]; !exists { | 
|  | 643 | mockFS["Android.bp"] = []byte(bp) | 
|  | 644 | } | 
|  | 645 |  | 
|  | 646 | for k, v := range fs { | 
|  | 647 | mockFS[k] = v | 
|  | 648 | } | 
|  | 649 |  | 
|  | 650 | // no module list file specified; find every file named Blueprints or Android.bp | 
|  | 651 | pathsToParse := []string{} | 
|  | 652 | for candidate := range mockFS { | 
|  | 653 | base := filepath.Base(candidate) | 
| Lukacs T. Berki | b838b0a | 2021-09-02 11:46:24 +0200 | [diff] [blame] | 654 | if base == "Android.bp" { | 
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 655 | pathsToParse = append(pathsToParse, candidate) | 
|  | 656 | } | 
|  | 657 | } | 
|  | 658 | if len(pathsToParse) < 1 { | 
|  | 659 | panic(fmt.Sprintf("No Blueprint or Android.bp files found in mock filesystem: %v\n", mockFS)) | 
|  | 660 | } | 
|  | 661 | mockFS[blueprint.MockModuleListFile] = []byte(strings.Join(pathsToParse, "\n")) | 
|  | 662 |  | 
|  | 663 | c.fs = pathtools.MockFs(mockFS) | 
|  | 664 | c.mockBpList = blueprint.MockModuleListFile | 
|  | 665 | } | 
|  | 666 |  | 
| Lukacs T. Berki | d1e3f1f | 2021-03-16 08:55:23 +0100 | [diff] [blame] | 667 | func (c *config) SetAllowMissingDependencies() { | 
|  | 668 | c.productVariables.Allow_missing_dependencies = proptools.BoolPtr(true) | 
|  | 669 | } | 
|  | 670 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 671 | // BlueprintToolLocation returns the directory containing build system tools | 
|  | 672 | // from Blueprint, like soong_zip and merge_zips. | 
| Lukacs T. Berki | a806e41 | 2021-09-01 08:57:48 +0200 | [diff] [blame] | 673 | func (c *config) HostToolDir() string { | 
| Colin Cross | acfcc1f | 2021-10-25 15:40:32 -0700 | [diff] [blame] | 674 | if c.KatiEnabled() { | 
|  | 675 | return filepath.Join(c.outDir, "host", c.PrebuiltOS(), "bin") | 
|  | 676 | } else { | 
|  | 677 | return filepath.Join(c.soongOutDir, "host", c.PrebuiltOS(), "bin") | 
|  | 678 | } | 
| Dan Willemsen | c2aa4a9 | 2016-05-26 15:13:03 -0700 | [diff] [blame] | 679 | } | 
|  | 680 |  | 
| Dan Willemsen | 60e62f0 | 2018-11-16 21:05:32 -0800 | [diff] [blame] | 681 | func (c *config) HostToolPath(ctx PathContext, tool string) Path { | 
| Cole Faust | 3b703f3 | 2023-10-16 13:30:51 -0700 | [diff] [blame] | 682 | path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin", tool) | 
| Colin Cross | 790ef35 | 2021-10-25 19:15:55 -0700 | [diff] [blame] | 683 | return path | 
| Dan Willemsen | 60e62f0 | 2018-11-16 21:05:32 -0800 | [diff] [blame] | 684 | } | 
|  | 685 |  | 
| Colin Cross | 790ef35 | 2021-10-25 19:15:55 -0700 | [diff] [blame] | 686 | func (c *config) HostJNIToolPath(ctx PathContext, lib string) Path { | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 687 | ext := ".so" | 
|  | 688 | if runtime.GOOS == "darwin" { | 
|  | 689 | ext = ".dylib" | 
|  | 690 | } | 
| Cole Faust | 3b703f3 | 2023-10-16 13:30:51 -0700 | [diff] [blame] | 691 | path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "lib64", lib+ext) | 
| Colin Cross | 790ef35 | 2021-10-25 19:15:55 -0700 | [diff] [blame] | 692 | return path | 
| Martin Stjernholm | 7260d06 | 2019-12-09 21:47:14 +0000 | [diff] [blame] | 693 | } | 
|  | 694 |  | 
| Colin Cross | ae5330a | 2021-11-03 13:31:22 -0700 | [diff] [blame] | 695 | func (c *config) HostJavaToolPath(ctx PathContext, tool string) Path { | 
| Cole Faust | 3b703f3 | 2023-10-16 13:30:51 -0700 | [diff] [blame] | 696 | path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "framework", tool) | 
| Colin Cross | 3e3eda6 | 2021-11-04 10:22:51 -0700 | [diff] [blame] | 697 | return path | 
|  | 698 | } | 
|  | 699 |  | 
| Vinh Tran | 0958195 | 2023-05-16 16:03:20 -0400 | [diff] [blame] | 700 | func (c *config) HostCcSharedLibPath(ctx PathContext, lib string) Path { | 
|  | 701 | libDir := "lib" | 
|  | 702 | if ctx.Config().BuildArch.Multilib == "lib64" { | 
|  | 703 | libDir = "lib64" | 
|  | 704 | } | 
| Cole Faust | 3b703f3 | 2023-10-16 13:30:51 -0700 | [diff] [blame] | 705 | return pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, libDir, lib+".so") | 
| Vinh Tran | 0958195 | 2023-05-16 16:03:20 -0400 | [diff] [blame] | 706 | } | 
|  | 707 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 708 | // PrebuiltOS returns the name of the host OS used in prebuilts directories. | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 709 | func (c *config) PrebuiltOS() string { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 710 | switch runtime.GOOS { | 
|  | 711 | case "linux": | 
|  | 712 | return "linux-x86" | 
|  | 713 | case "darwin": | 
|  | 714 | return "darwin-x86" | 
|  | 715 | default: | 
|  | 716 | panic("Unknown GOOS") | 
|  | 717 | } | 
|  | 718 | } | 
|  | 719 |  | 
|  | 720 | // GoRoot returns the path to the root directory of the Go toolchain. | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 721 | func (c *config) GoRoot() string { | 
| Lukacs T. Berki | f7e36d8 | 2021-08-16 17:05:09 +0200 | [diff] [blame] | 722 | return fmt.Sprintf("prebuilts/go/%s", c.PrebuiltOS()) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 723 | } | 
|  | 724 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 725 | // PrebuiltBuildTool returns the path to a tool in the prebuilts directory containing | 
|  | 726 | // checked-in tools, like Kati, Ninja or Toybox, for the current host OS. | 
| Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 727 | func (c *config) PrebuiltBuildTool(ctx PathContext, tool string) Path { | 
|  | 728 | return PathForSource(ctx, "prebuilts/build-tools", c.PrebuiltOS(), "bin", tool) | 
|  | 729 | } | 
|  | 730 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 731 | // CpPreserveSymlinksFlags returns the host-specific flag for the cp(1) command | 
|  | 732 | // to preserve symlinks. | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 733 | func (c *config) CpPreserveSymlinksFlags() string { | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 734 | switch runtime.GOOS { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 735 | case "darwin": | 
|  | 736 | return "-R" | 
|  | 737 | case "linux": | 
|  | 738 | return "-d" | 
|  | 739 | default: | 
|  | 740 | return "" | 
|  | 741 | } | 
|  | 742 | } | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 743 |  | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 744 | func (c *config) Getenv(key string) string { | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 745 | var val string | 
|  | 746 | var exists bool | 
| Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 747 | c.envLock.Lock() | 
| Colin Cross | c0d58b4 | 2017-02-06 15:40:41 -0800 | [diff] [blame] | 748 | defer c.envLock.Unlock() | 
|  | 749 | if c.envDeps == nil { | 
|  | 750 | c.envDeps = make(map[string]string) | 
|  | 751 | } | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 752 | if val, exists = c.envDeps[key]; !exists { | 
| Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 753 | if c.envFrozen { | 
|  | 754 | panic("Cannot access new environment variables after envdeps are frozen") | 
|  | 755 | } | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 756 | val, _ = c.env[key] | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 757 | c.envDeps[key] = val | 
|  | 758 | } | 
|  | 759 | return val | 
|  | 760 | } | 
|  | 761 |  | 
| Colin Cross | 99d7c23 | 2016-11-23 16:52:04 -0800 | [diff] [blame] | 762 | func (c *config) GetenvWithDefault(key string, defaultValue string) string { | 
|  | 763 | ret := c.Getenv(key) | 
|  | 764 | if ret == "" { | 
|  | 765 | return defaultValue | 
|  | 766 | } | 
|  | 767 | return ret | 
|  | 768 | } | 
|  | 769 |  | 
|  | 770 | func (c *config) IsEnvTrue(key string) bool { | 
| AdityaK | 1938410 | 2024-05-01 13:51:25 -0700 | [diff] [blame] | 771 | value := strings.ToLower(c.Getenv(key)) | 
| Colin Cross | 99d7c23 | 2016-11-23 16:52:04 -0800 | [diff] [blame] | 772 | return value == "1" || value == "y" || value == "yes" || value == "on" || value == "true" | 
|  | 773 | } | 
|  | 774 |  | 
|  | 775 | func (c *config) IsEnvFalse(key string) bool { | 
| AdityaK | 1938410 | 2024-05-01 13:51:25 -0700 | [diff] [blame] | 776 | value := strings.ToLower(c.Getenv(key)) | 
| Colin Cross | 99d7c23 | 2016-11-23 16:52:04 -0800 | [diff] [blame] | 777 | return value == "0" || value == "n" || value == "no" || value == "off" || value == "false" | 
|  | 778 | } | 
|  | 779 |  | 
| Sorin Basca | 253f8c0 | 2024-05-23 10:28:24 +0100 | [diff] [blame] | 780 | func (c *config) TargetsJava21() bool { | 
|  | 781 | return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_21") | 
|  | 782 | } | 
|  | 783 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 784 | // EnvDeps returns the environment variables this build depends on. The first | 
|  | 785 | // call to this function blocks future reads from the environment. | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 786 | func (c *config) EnvDeps() map[string]string { | 
| Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 787 | c.envLock.Lock() | 
| Colin Cross | c0d58b4 | 2017-02-06 15:40:41 -0800 | [diff] [blame] | 788 | defer c.envLock.Unlock() | 
| Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 789 | c.envFrozen = true | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 790 | return c.envDeps | 
|  | 791 | } | 
| Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 792 |  | 
| Jingwen Chen | cda22c9 | 2020-11-23 00:22:30 -0500 | [diff] [blame] | 793 | func (c *config) KatiEnabled() bool { | 
|  | 794 | return c.katiEnabled | 
| Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 795 | } | 
|  | 796 |  | 
| Cole Faust | 11edf55 | 2023-10-13 11:32:14 -0700 | [diff] [blame] | 797 | func (c *config) ProductVariables() ProductVariables { | 
|  | 798 | return c.productVariables | 
|  | 799 | } | 
|  | 800 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 801 | func (c *config) BuildId() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 802 | return String(c.productVariables.BuildId) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 803 | } | 
|  | 804 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 805 | func (c *config) DisplayBuildNumber() bool { | 
|  | 806 | return Bool(c.productVariables.DisplayBuildNumber) | 
|  | 807 | } | 
|  | 808 |  | 
| Inseob Kim | 2da72af | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 809 | // BuildFingerprintFile returns the path to a text file containing metadata | 
|  | 810 | // representing the current build's fingerprint. | 
|  | 811 | // | 
|  | 812 | // Rules that want to reference the build fingerprint should read from this file | 
|  | 813 | // without depending on it. They will run whenever their other dependencies | 
|  | 814 | // require them to run and get the current build fingerprint. This ensures they | 
|  | 815 | // don't rebuild on every incremental build when the build number changes. | 
|  | 816 | func (c *config) BuildFingerprintFile(ctx PathContext) Path { | 
|  | 817 | return PathForArbitraryOutput(ctx, "target", "product", c.DeviceName(), String(c.productVariables.BuildFingerprintFile)) | 
|  | 818 | } | 
|  | 819 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 820 | // BuildNumberFile returns the path to a text file containing metadata | 
|  | 821 | // representing the current build's number. | 
|  | 822 | // | 
|  | 823 | // Rules that want to reference the build number should read from this file | 
|  | 824 | // without depending on it. They will run whenever their other dependencies | 
|  | 825 | // require them to run and get the current build number. This ensures they don't | 
|  | 826 | // rebuild on every incremental build when the build number changes. | 
| Colin Cross | 2a2e0db | 2020-02-21 16:55:46 -0800 | [diff] [blame] | 827 | func (c *config) BuildNumberFile(ctx PathContext) Path { | 
|  | 828 | return PathForOutput(ctx, String(c.productVariables.BuildNumberFile)) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 829 | } | 
|  | 830 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 831 | // BuildHostnameFile returns the path to a text file containing metadata | 
|  | 832 | // representing the current build's host name. | 
|  | 833 | func (c *config) BuildHostnameFile(ctx PathContext) Path { | 
|  | 834 | return PathForOutput(ctx, String(c.productVariables.BuildHostnameFile)) | 
|  | 835 | } | 
|  | 836 |  | 
|  | 837 | // BuildThumbprintFile returns the path to a text file containing metadata | 
|  | 838 | // representing the current build's thumbprint. | 
|  | 839 | // | 
|  | 840 | // Rules that want to reference the build thumbprint should read from this file | 
|  | 841 | // without depending on it. They will run whenever their other dependencies | 
|  | 842 | // require them to run and get the current build thumbprint. This ensures they | 
|  | 843 | // don't rebuild on every incremental build when the build thumbprint changes. | 
|  | 844 | func (c *config) BuildThumbprintFile(ctx PathContext) Path { | 
|  | 845 | return PathForArbitraryOutput(ctx, "target", "product", c.DeviceName(), String(c.productVariables.BuildThumbprintFile)) | 
|  | 846 | } | 
|  | 847 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 848 | // DeviceName returns the name of the current device target. | 
| Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 849 | // TODO: take an AndroidModuleContext to select the device name for multi-device builds | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 850 | func (c *config) DeviceName() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 851 | return *c.productVariables.DeviceName | 
| Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 852 | } | 
|  | 853 |  | 
| Trevor Radcliffe | 90727f4 | 2022-03-21 19:34:02 +0000 | [diff] [blame] | 854 | // DeviceProduct returns the current product target. There could be multiple of | 
|  | 855 | // these per device type. | 
|  | 856 | // | 
| Chris Parsons | ef615e5 | 2022-08-18 22:04:11 -0400 | [diff] [blame] | 857 | // NOTE: Do not base conditional logic on this value. It may break product inheritance. | 
| Trevor Radcliffe | 90727f4 | 2022-03-21 19:34:02 +0000 | [diff] [blame] | 858 | func (c *config) DeviceProduct() string { | 
|  | 859 | return *c.productVariables.DeviceProduct | 
|  | 860 | } | 
|  | 861 |  | 
| Cole Faust | b85d1a1 | 2022-11-08 18:14:01 -0800 | [diff] [blame] | 862 | // HasDeviceProduct returns if the build has a product. A build will not | 
|  | 863 | // necessarily have a product when --skip-config is passed to soong, like it is | 
|  | 864 | // in prebuilts/build-tools/build-prebuilts.sh | 
|  | 865 | func (c *config) HasDeviceProduct() bool { | 
|  | 866 | return c.productVariables.DeviceProduct != nil | 
|  | 867 | } | 
|  | 868 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 869 | func (c *config) DeviceAbi() []string { | 
|  | 870 | return c.productVariables.DeviceAbi | 
|  | 871 | } | 
|  | 872 |  | 
| Anton Hansson | 53c8844 | 2019-03-18 15:53:16 +0000 | [diff] [blame] | 873 | func (c *config) DeviceResourceOverlays() []string { | 
|  | 874 | return c.productVariables.DeviceResourceOverlays | 
|  | 875 | } | 
|  | 876 |  | 
|  | 877 | func (c *config) ProductResourceOverlays() []string { | 
|  | 878 | return c.productVariables.ProductResourceOverlays | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 879 | } | 
|  | 880 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 881 | func (c *config) PlatformDisplayVersionName() string { | 
|  | 882 | return String(c.productVariables.Platform_display_version_name) | 
|  | 883 | } | 
|  | 884 |  | 
| Colin Cross | bfd347d | 2018-05-09 11:11:35 -0700 | [diff] [blame] | 885 | func (c *config) PlatformVersionName() string { | 
|  | 886 | return String(c.productVariables.Platform_version_name) | 
|  | 887 | } | 
|  | 888 |  | 
| Dan Albert | 4f378d7 | 2020-07-23 17:32:15 -0700 | [diff] [blame] | 889 | func (c *config) PlatformSdkVersion() ApiLevel { | 
|  | 890 | return uncheckedFinalApiLevel(*c.productVariables.Platform_sdk_version) | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 891 | } | 
|  | 892 |  | 
| Cole Faust | 37d27c4 | 2023-04-12 10:27:45 -0700 | [diff] [blame] | 893 | func (c *config) RawPlatformSdkVersion() *int { | 
|  | 894 | return c.productVariables.Platform_sdk_version | 
|  | 895 | } | 
|  | 896 |  | 
| Mu-Le Lee | 5e04753 | 2022-07-27 02:32:03 +0000 | [diff] [blame] | 897 | func (c *config) PlatformSdkFinal() bool { | 
|  | 898 | return Bool(c.productVariables.Platform_sdk_final) | 
|  | 899 | } | 
|  | 900 |  | 
| Colin Cross | d09b0b6 | 2018-04-18 11:06:47 -0700 | [diff] [blame] | 901 | func (c *config) PlatformSdkCodename() string { | 
|  | 902 | return String(c.productVariables.Platform_sdk_codename) | 
|  | 903 | } | 
|  | 904 |  | 
| Anton Hansson | 97d0bae | 2022-02-16 16:15:10 +0000 | [diff] [blame] | 905 | func (c *config) PlatformSdkExtensionVersion() int { | 
|  | 906 | return *c.productVariables.Platform_sdk_extension_version | 
|  | 907 | } | 
|  | 908 |  | 
|  | 909 | func (c *config) PlatformBaseSdkExtensionVersion() int { | 
|  | 910 | return *c.productVariables.Platform_base_sdk_extension_version | 
|  | 911 | } | 
|  | 912 |  | 
| Colin Cross | 092c9da | 2019-04-02 22:56:43 -0700 | [diff] [blame] | 913 | func (c *config) PlatformSecurityPatch() string { | 
|  | 914 | return String(c.productVariables.Platform_security_patch) | 
|  | 915 | } | 
|  | 916 |  | 
|  | 917 | func (c *config) PlatformPreviewSdkVersion() string { | 
|  | 918 | return String(c.productVariables.Platform_preview_sdk_version) | 
|  | 919 | } | 
|  | 920 |  | 
|  | 921 | func (c *config) PlatformMinSupportedTargetSdkVersion() string { | 
| Linus Tufvesson | ba270c5 | 2024-04-12 13:06:22 +0200 | [diff] [blame] | 922 | var val, ok = c.productVariables.BuildFlags["RELEASE_PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION"] | 
|  | 923 | if !ok { | 
|  | 924 | return "" | 
|  | 925 | } | 
|  | 926 | return val | 
| Colin Cross | 092c9da | 2019-04-02 22:56:43 -0700 | [diff] [blame] | 927 | } | 
|  | 928 |  | 
|  | 929 | func (c *config) PlatformBaseOS() string { | 
|  | 930 | return String(c.productVariables.Platform_base_os) | 
|  | 931 | } | 
|  | 932 |  | 
| Inseob Kim | 4f1f3d9 | 2022-04-25 18:23:58 +0900 | [diff] [blame] | 933 | func (c *config) PlatformVersionLastStable() string { | 
|  | 934 | return String(c.productVariables.Platform_version_last_stable) | 
|  | 935 | } | 
|  | 936 |  | 
| Jiyong Park | 3707384 | 2022-06-21 10:13:42 +0900 | [diff] [blame] | 937 | func (c *config) PlatformVersionKnownCodenames() string { | 
|  | 938 | return String(c.productVariables.Platform_version_known_codenames) | 
|  | 939 | } | 
|  | 940 |  | 
| Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 941 | func (c *config) MinSupportedSdkVersion() ApiLevel { | 
| Dan Albert | 6bfb6bb | 2022-08-17 20:11:57 +0000 | [diff] [blame] | 942 | return uncheckedFinalApiLevel(21) | 
| Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 943 | } | 
|  | 944 |  | 
|  | 945 | func (c *config) FinalApiLevels() []ApiLevel { | 
|  | 946 | var levels []ApiLevel | 
| Dan Albert | 4f378d7 | 2020-07-23 17:32:15 -0700 | [diff] [blame] | 947 | for i := 1; i <= c.PlatformSdkVersion().FinalOrFutureInt(); i++ { | 
| Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 948 | levels = append(levels, uncheckedFinalApiLevel(i)) | 
|  | 949 | } | 
|  | 950 | return levels | 
|  | 951 | } | 
|  | 952 |  | 
|  | 953 | func (c *config) PreviewApiLevels() []ApiLevel { | 
|  | 954 | var levels []ApiLevel | 
| Dan Albert | f93ea13 | 2023-10-05 20:40:46 +0000 | [diff] [blame] | 955 | i := 0 | 
|  | 956 | for _, codename := range c.PlatformVersionActiveCodenames() { | 
|  | 957 | if codename == "REL" { | 
|  | 958 | continue | 
|  | 959 | } | 
|  | 960 |  | 
| Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 961 | levels = append(levels, ApiLevel{ | 
|  | 962 | value:     codename, | 
|  | 963 | number:    i, | 
|  | 964 | isPreview: true, | 
|  | 965 | }) | 
| Dan Albert | f93ea13 | 2023-10-05 20:40:46 +0000 | [diff] [blame] | 966 | i++ | 
| Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 967 | } | 
|  | 968 | return levels | 
|  | 969 | } | 
|  | 970 |  | 
| satayev | cca4ab7 | 2021-11-30 12:33:55 +0000 | [diff] [blame] | 971 | func (c *config) LatestPreviewApiLevel() ApiLevel { | 
|  | 972 | level := NoneApiLevel | 
|  | 973 | for _, l := range c.PreviewApiLevels() { | 
|  | 974 | if l.GreaterThan(level) { | 
|  | 975 | level = l | 
|  | 976 | } | 
|  | 977 | } | 
|  | 978 | return level | 
|  | 979 | } | 
|  | 980 |  | 
| Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 981 | func (c *config) AllSupportedApiLevels() []ApiLevel { | 
|  | 982 | var levels []ApiLevel | 
|  | 983 | levels = append(levels, c.FinalApiLevels()...) | 
|  | 984 | return append(levels, c.PreviewApiLevels()...) | 
| Dan Albert | f5415d7 | 2017-08-17 16:19:59 -0700 | [diff] [blame] | 985 | } | 
|  | 986 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 987 | // DefaultAppTargetSdk returns the API level that platform apps are targeting. | 
|  | 988 | // This converts a codename to the exact ApiLevel it represents. | 
| Dan Albert | 4f378d7 | 2020-07-23 17:32:15 -0700 | [diff] [blame] | 989 | func (c *config) DefaultAppTargetSdk(ctx EarlyModuleContext) ApiLevel { | 
| Colin Cross | d09b0b6 | 2018-04-18 11:06:47 -0700 | [diff] [blame] | 990 | if Bool(c.productVariables.Platform_sdk_final) { | 
|  | 991 | return c.PlatformSdkVersion() | 
| Colin Cross | d09b0b6 | 2018-04-18 11:06:47 -0700 | [diff] [blame] | 992 | } | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 993 | codename := c.PlatformSdkCodename() | 
| Jiyong Park | 3a00e3d | 2023-03-27 17:39:48 +0900 | [diff] [blame] | 994 | hostOnlyBuild := c.productVariables.DeviceArch == nil | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 995 | if codename == "" { | 
| Jiyong Park | 3a00e3d | 2023-03-27 17:39:48 +0900 | [diff] [blame] | 996 | // There are some host-only builds (those are invoked by build-prebuilts.sh) which | 
|  | 997 | // don't set platform sdk codename. Platform sdk codename makes sense only when we | 
|  | 998 | // are building the platform. So we don't enforce the below panic for the host-only | 
|  | 999 | // builds. | 
|  | 1000 | if hostOnlyBuild { | 
|  | 1001 | return NoneApiLevel | 
|  | 1002 | } | 
|  | 1003 | panic("Platform_sdk_codename must be set") | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1004 | } | 
|  | 1005 | if codename == "REL" { | 
|  | 1006 | panic("Platform_sdk_codename should not be REL when Platform_sdk_final is true") | 
|  | 1007 | } | 
|  | 1008 | return ApiLevelOrPanic(ctx, codename) | 
| Colin Cross | d09b0b6 | 2018-04-18 11:06:47 -0700 | [diff] [blame] | 1009 | } | 
|  | 1010 |  | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 1011 | func (c *config) AppsDefaultVersionName() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1012 | return String(c.productVariables.AppsDefaultVersionName) | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 1013 | } | 
|  | 1014 |  | 
| Dan Albert | 31384de | 2017-07-28 12:39:46 -0700 | [diff] [blame] | 1015 | // Codenames that are active in the current lunch target. | 
|  | 1016 | func (c *config) PlatformVersionActiveCodenames() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1017 | return c.productVariables.Platform_version_active_codenames | 
| Dan Albert | 31384de | 2017-07-28 12:39:46 -0700 | [diff] [blame] | 1018 | } | 
|  | 1019 |  | 
| Dan Albert | 8c7a994 | 2023-03-27 20:34:01 +0000 | [diff] [blame] | 1020 | // All unreleased codenames. | 
|  | 1021 | func (c *config) PlatformVersionAllPreviewCodenames() []string { | 
|  | 1022 | return c.productVariables.Platform_version_all_preview_codenames | 
|  | 1023 | } | 
|  | 1024 |  | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 1025 | func (c *config) ProductAAPTConfig() []string { | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 1026 | return c.productVariables.AAPTConfig | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 1027 | } | 
|  | 1028 |  | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 1029 | func (c *config) ProductAAPTPreferredConfig() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1030 | return String(c.productVariables.AAPTPreferredConfig) | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 1031 | } | 
|  | 1032 |  | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 1033 | func (c *config) ProductAAPTCharacteristics() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1034 | return String(c.productVariables.AAPTCharacteristics) | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 1035 | } | 
|  | 1036 |  | 
|  | 1037 | func (c *config) ProductAAPTPrebuiltDPI() []string { | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 1038 | return c.productVariables.AAPTPrebuiltDPI | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 1039 | } | 
|  | 1040 |  | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 1041 | func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1042 | defaultCert := String(c.productVariables.DefaultAppCertificate) | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 1043 | if defaultCert != "" { | 
|  | 1044 | return PathForSource(ctx, filepath.Dir(defaultCert)) | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 1045 | } | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 1046 | return PathForSource(ctx, testKeyDir) | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 1047 | } | 
|  | 1048 |  | 
| Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 1049 | func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1050 | defaultCert := String(c.productVariables.DefaultAppCertificate) | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 1051 | if defaultCert != "" { | 
| Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 1052 | return PathForSource(ctx, defaultCert+".x509.pem"), PathForSource(ctx, defaultCert+".pk8") | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 1053 | } | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1054 | defaultDir := c.DefaultAppCertificateDir(ctx) | 
|  | 1055 | return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8") | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 1056 | } | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 1057 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 1058 | func (c *config) BuildKeys() string { | 
|  | 1059 | defaultCert := String(c.productVariables.DefaultAppCertificate) | 
|  | 1060 | if defaultCert == "" || defaultCert == filepath.Join(testKeyDir, "testkey") { | 
|  | 1061 | return "test-keys" | 
|  | 1062 | } | 
|  | 1063 | return "dev-keys" | 
|  | 1064 | } | 
|  | 1065 |  | 
| Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1066 | func (c *config) ApexKeyDir(ctx ModuleContext) SourcePath { | 
|  | 1067 | // TODO(b/121224311): define another variable such as TARGET_APEX_KEY_OVERRIDE | 
|  | 1068 | defaultCert := String(c.productVariables.DefaultAppCertificate) | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 1069 | if defaultCert == "" || filepath.Dir(defaultCert) == testKeyDir { | 
| Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1070 | // When defaultCert is unset or is set to the testkeys path, use the APEX keys | 
|  | 1071 | // that is under the module dir | 
| Colin Cross | 07e5161 | 2019-03-05 12:46:40 -0800 | [diff] [blame] | 1072 | return pathForModuleSrc(ctx) | 
| Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1073 | } | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1074 | // If not, APEX keys are under the specified directory | 
|  | 1075 | return PathForSource(ctx, filepath.Dir(defaultCert)) | 
| Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1076 | } | 
|  | 1077 |  | 
| Inseob Kim | 80fa798 | 2022-08-12 21:36:25 +0900 | [diff] [blame] | 1078 | // Certificate for the NetworkStack sepolicy context | 
|  | 1079 | func (c *config) MainlineSepolicyDevCertificatesDir(ctx ModuleContext) SourcePath { | 
|  | 1080 | cert := String(c.productVariables.MainlineSepolicyDevCertificates) | 
|  | 1081 | if cert != "" { | 
|  | 1082 | return PathForSource(ctx, cert) | 
|  | 1083 | } | 
|  | 1084 | return c.DefaultAppCertificateDir(ctx) | 
|  | 1085 | } | 
|  | 1086 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1087 | // AllowMissingDependencies configures Blueprint/Soong to not fail when modules | 
|  | 1088 | // are configured to depend on non-existent modules. Note that this does not | 
|  | 1089 | // affect missing input dependencies at the Ninja level. | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 1090 | func (c *config) AllowMissingDependencies() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1091 | return Bool(c.productVariables.Allow_missing_dependencies) | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 1092 | } | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 1093 |  | 
| Jeongik Cha | 816a23a | 2020-07-08 01:09:23 +0900 | [diff] [blame] | 1094 | // Returns true if a full platform source tree cannot be assumed. | 
| Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 1095 | func (c *config) UnbundledBuild() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1096 | return Bool(c.productVariables.Unbundled_build) | 
| Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 1097 | } | 
|  | 1098 |  | 
| Martin Stjernholm | fd9eb4b | 2020-06-17 01:13:15 +0100 | [diff] [blame] | 1099 | // Returns true if building apps that aren't bundled with the platform. | 
|  | 1100 | // UnbundledBuild() is always true when this is true. | 
|  | 1101 | func (c *config) UnbundledBuildApps() bool { | 
| Cole Faust | 701ca25 | 2021-11-23 19:02:08 -0800 | [diff] [blame] | 1102 | return len(c.productVariables.Unbundled_build_apps) > 0 | 
| Martin Stjernholm | fd9eb4b | 2020-06-17 01:13:15 +0100 | [diff] [blame] | 1103 | } | 
|  | 1104 |  | 
| Jeongik Cha | 4b073cd | 2021-06-08 11:35:00 +0900 | [diff] [blame] | 1105 | // Returns true if building image that aren't bundled with the platform. | 
|  | 1106 | // UnbundledBuild() is always true when this is true. | 
|  | 1107 | func (c *config) UnbundledBuildImage() bool { | 
|  | 1108 | return Bool(c.productVariables.Unbundled_build_image) | 
|  | 1109 | } | 
|  | 1110 |  | 
| Jeongik Cha | 816a23a | 2020-07-08 01:09:23 +0900 | [diff] [blame] | 1111 | // Returns true if building modules against prebuilt SDKs. | 
|  | 1112 | func (c *config) AlwaysUsePrebuiltSdks() bool { | 
|  | 1113 | return Bool(c.productVariables.Always_use_prebuilt_sdks) | 
| Colin Cross | 1f367bf | 2018-12-18 22:46:24 -0800 | [diff] [blame] | 1114 | } | 
|  | 1115 |  | 
| Colin Cross | 126a25c | 2017-10-31 13:55:34 -0700 | [diff] [blame] | 1116 | func (c *config) MinimizeJavaDebugInfo() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1117 | return Bool(c.productVariables.MinimizeJavaDebugInfo) && !Bool(c.productVariables.Eng) | 
| Colin Cross | 126a25c | 2017-10-31 13:55:34 -0700 | [diff] [blame] | 1118 | } | 
|  | 1119 |  | 
| Colin Cross | ed064c0 | 2018-09-05 16:28:13 -0700 | [diff] [blame] | 1120 | func (c *config) Debuggable() bool { | 
|  | 1121 | return Bool(c.productVariables.Debuggable) | 
|  | 1122 | } | 
|  | 1123 |  | 
| Jaewoong Jung | 1d6eb68 | 2018-11-29 15:08:44 -0800 | [diff] [blame] | 1124 | func (c *config) Eng() bool { | 
|  | 1125 | return Bool(c.productVariables.Eng) | 
|  | 1126 | } | 
|  | 1127 |  | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 1128 | func (c *config) BuildType() string { | 
|  | 1129 | return String(c.productVariables.BuildType) | 
|  | 1130 | } | 
|  | 1131 |  | 
| Colin Cross | c53c37f | 2021-12-08 15:42:22 -0800 | [diff] [blame] | 1132 | // DevicePrimaryArchType returns the ArchType for the first configured device architecture, or | 
|  | 1133 | // Common if there are no device architectures. | 
| Jiyong Park | 8d52f86 | 2018-07-07 18:02:07 +0900 | [diff] [blame] | 1134 | func (c *config) DevicePrimaryArchType() ArchType { | 
| Colin Cross | c53c37f | 2021-12-08 15:42:22 -0800 | [diff] [blame] | 1135 | if androidTargets := c.Targets[Android]; len(androidTargets) > 0 { | 
|  | 1136 | return androidTargets[0].Arch.ArchType | 
|  | 1137 | } | 
|  | 1138 | return Common | 
| Jiyong Park | 8d52f86 | 2018-07-07 18:02:07 +0900 | [diff] [blame] | 1139 | } | 
|  | 1140 |  | 
| Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1141 | func (c *config) SanitizeHost() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1142 | return append([]string(nil), c.productVariables.SanitizeHost...) | 
| Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1143 | } | 
|  | 1144 |  | 
|  | 1145 | func (c *config) SanitizeDevice() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1146 | return append([]string(nil), c.productVariables.SanitizeDevice...) | 
| Colin Cross | 23ae82a | 2016-11-02 14:34:39 -0700 | [diff] [blame] | 1147 | } | 
|  | 1148 |  | 
| Ivan Lozano | 0c3a1ef | 2017-06-28 09:10:48 -0700 | [diff] [blame] | 1149 | func (c *config) SanitizeDeviceDiag() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1150 | return append([]string(nil), c.productVariables.SanitizeDeviceDiag...) | 
| Ivan Lozano | 0c3a1ef | 2017-06-28 09:10:48 -0700 | [diff] [blame] | 1151 | } | 
|  | 1152 |  | 
| Colin Cross | 23ae82a | 2016-11-02 14:34:39 -0700 | [diff] [blame] | 1153 | func (c *config) SanitizeDeviceArch() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1154 | return append([]string(nil), c.productVariables.SanitizeDeviceArch...) | 
| Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1155 | } | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 1156 |  | 
| Vishwath Mohan | 1b017a7 | 2017-01-19 13:54:55 -0800 | [diff] [blame] | 1157 | func (c *config) EnableCFI() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1158 | if c.productVariables.EnableCFI == nil { | 
| Vishwath Mohan | c32c3eb | 2017-01-24 14:20:54 -0800 | [diff] [blame] | 1159 | return true | 
| Vishwath Mohan | c32c3eb | 2017-01-24 14:20:54 -0800 | [diff] [blame] | 1160 | } | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1161 | return *c.productVariables.EnableCFI | 
| Vishwath Mohan | 1b017a7 | 2017-01-19 13:54:55 -0800 | [diff] [blame] | 1162 | } | 
|  | 1163 |  | 
| Kostya Kortchinsky | d5275c8 | 2019-02-01 08:42:56 -0800 | [diff] [blame] | 1164 | func (c *config) DisableScudo() bool { | 
|  | 1165 | return Bool(c.productVariables.DisableScudo) | 
|  | 1166 | } | 
|  | 1167 |  | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 1168 | func (c *config) Android64() bool { | 
| Dan Willemsen | 0ef639b | 2018-10-10 17:02:29 -0700 | [diff] [blame] | 1169 | for _, t := range c.Targets[Android] { | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 1170 | if t.Arch.ArchType.Multilib == "lib64" { | 
|  | 1171 | return true | 
|  | 1172 | } | 
|  | 1173 | } | 
|  | 1174 |  | 
|  | 1175 | return false | 
|  | 1176 | } | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 1177 |  | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 1178 | func (c *config) UseGoma() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1179 | return Bool(c.productVariables.UseGoma) | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 1180 | } | 
|  | 1181 |  | 
| Ramy Medhat | bbf2567 | 2019-07-17 12:30:04 +0000 | [diff] [blame] | 1182 | func (c *config) UseRBE() bool { | 
|  | 1183 | return Bool(c.productVariables.UseRBE) | 
|  | 1184 | } | 
|  | 1185 |  | 
| Ramy Medhat | 8ea054a | 2020-01-27 14:19:44 -0500 | [diff] [blame] | 1186 | func (c *config) UseRBEJAVAC() bool { | 
|  | 1187 | return Bool(c.productVariables.UseRBEJAVAC) | 
|  | 1188 | } | 
|  | 1189 |  | 
|  | 1190 | func (c *config) UseRBER8() bool { | 
|  | 1191 | return Bool(c.productVariables.UseRBER8) | 
|  | 1192 | } | 
|  | 1193 |  | 
|  | 1194 | func (c *config) UseRBED8() bool { | 
|  | 1195 | return Bool(c.productVariables.UseRBED8) | 
|  | 1196 | } | 
|  | 1197 |  | 
| Colin Cross | 8b8bec3 | 2019-11-15 13:18:43 -0800 | [diff] [blame] | 1198 | func (c *config) UseRemoteBuild() bool { | 
|  | 1199 | return c.UseGoma() || c.UseRBE() | 
|  | 1200 | } | 
|  | 1201 |  | 
| Colin Cross | 6654810 | 2018-06-19 22:47:35 -0700 | [diff] [blame] | 1202 | func (c *config) RunErrorProne() bool { | 
|  | 1203 | return c.IsEnvTrue("RUN_ERROR_PRONE") | 
|  | 1204 | } | 
|  | 1205 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1206 | // XrefCorpusName returns the Kythe cross-reference corpus name. | 
| Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1207 | func (c *config) XrefCorpusName() string { | 
|  | 1208 | return c.Getenv("XREF_CORPUS") | 
|  | 1209 | } | 
|  | 1210 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1211 | // XrefCuEncoding returns the compilation unit encoding to use for Kythe code | 
|  | 1212 | // xrefs. Can be 'json' (default), 'proto' or 'all'. | 
| Sasha Smundak | 6c2d4f9 | 2020-01-09 17:34:23 -0800 | [diff] [blame] | 1213 | func (c *config) XrefCuEncoding() string { | 
|  | 1214 | if enc := c.Getenv("KYTHE_KZIP_ENCODING"); enc != "" { | 
|  | 1215 | return enc | 
|  | 1216 | } | 
|  | 1217 | return "json" | 
|  | 1218 | } | 
|  | 1219 |  | 
| Sasha Smundak | b0addaf | 2021-02-16 10:39:40 -0800 | [diff] [blame] | 1220 | // XrefCuJavaSourceMax returns the maximum number of the Java source files | 
|  | 1221 | // in a single compilation unit | 
|  | 1222 | const xrefJavaSourceFileMaxDefault = "1000" | 
|  | 1223 |  | 
|  | 1224 | func (c Config) XrefCuJavaSourceMax() string { | 
|  | 1225 | v := c.Getenv("KYTHE_JAVA_SOURCE_BATCH_SIZE") | 
|  | 1226 | if v == "" { | 
|  | 1227 | return xrefJavaSourceFileMaxDefault | 
|  | 1228 | } | 
|  | 1229 | if _, err := strconv.ParseUint(v, 0, 0); err != nil { | 
|  | 1230 | fmt.Fprintf(os.Stderr, | 
|  | 1231 | "bad KYTHE_JAVA_SOURCE_BATCH_SIZE value: %s, will use %s", | 
|  | 1232 | err, xrefJavaSourceFileMaxDefault) | 
|  | 1233 | return xrefJavaSourceFileMaxDefault | 
|  | 1234 | } | 
|  | 1235 | return v | 
|  | 1236 |  | 
|  | 1237 | } | 
|  | 1238 |  | 
| Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1239 | func (c *config) EmitXrefRules() bool { | 
|  | 1240 | return c.XrefCorpusName() != "" | 
|  | 1241 | } | 
|  | 1242 |  | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 1243 | func (c *config) ClangTidy() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1244 | return Bool(c.productVariables.ClangTidy) | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 1245 | } | 
|  | 1246 |  | 
|  | 1247 | func (c *config) TidyChecks() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1248 | if c.productVariables.TidyChecks == nil { | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 1249 | return "" | 
|  | 1250 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1251 | return *c.productVariables.TidyChecks | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 1252 | } | 
|  | 1253 |  | 
| Colin Cross | 0f4e0d6 | 2016-07-27 10:56:55 -0700 | [diff] [blame] | 1254 | func (c *config) LibartImgHostBaseAddress() string { | 
|  | 1255 | return "0x60000000" | 
|  | 1256 | } | 
|  | 1257 |  | 
|  | 1258 | func (c *config) LibartImgDeviceBaseAddress() string { | 
| Elliott Hughes | da3a071 | 2020-03-06 16:55:28 -0800 | [diff] [blame] | 1259 | return "0x70000000" | 
| Colin Cross | 0f4e0d6 | 2016-07-27 10:56:55 -0700 | [diff] [blame] | 1260 | } | 
|  | 1261 |  | 
| Hiroshi Yamauchi | e2a1063 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 1262 | func (c *config) ArtUseReadBarrier() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1263 | return Bool(c.productVariables.ArtUseReadBarrier) | 
| Hiroshi Yamauchi | e2a1063 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 1264 | } | 
|  | 1265 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1266 | // Enforce Runtime Resource Overlays for a module. RROs supersede static RROs, | 
|  | 1267 | // but some modules still depend on it. | 
|  | 1268 | // | 
|  | 1269 | // More info: https://source.android.com/devices/architecture/rros | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 1270 | func (c *config) EnforceRROForModule(name string) bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1271 | enforceList := c.productVariables.EnforceRROTargets | 
| Jeongik Cha | cee5ba9 | 2021-02-19 12:11:51 +0900 | [diff] [blame] | 1272 |  | 
| Roland Levillain | f6cc261 | 2020-07-09 16:58:14 +0100 | [diff] [blame] | 1273 | if len(enforceList) > 0 { | 
| Yo Chiang | 4ebd06a | 2019-10-01 13:13:41 +0800 | [diff] [blame] | 1274 | if InList("*", enforceList) { | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 1275 | return true | 
|  | 1276 | } | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 1277 | return InList(name, enforceList) | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 1278 | } | 
|  | 1279 | return false | 
|  | 1280 | } | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 1281 | func (c *config) EnforceRROExcludedOverlay(path string) bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1282 | excluded := c.productVariables.EnforceRROExcludedOverlays | 
| Roland Levillain | f6cc261 | 2020-07-09 16:58:14 +0100 | [diff] [blame] | 1283 | if len(excluded) > 0 { | 
| Jaewoong Jung | 3aff578 | 2020-02-11 07:54:35 -0800 | [diff] [blame] | 1284 | return HasAnyPrefix(path, excluded) | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 1285 | } | 
|  | 1286 | return false | 
|  | 1287 | } | 
|  | 1288 |  | 
|  | 1289 | func (c *config) ExportedNamespaces() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1290 | return append([]string(nil), c.productVariables.NamespacesToExport...) | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 1291 | } | 
|  | 1292 |  | 
| Sam Delmerico | 98a7329 | 2023-02-21 11:50:29 -0500 | [diff] [blame] | 1293 | func (c *config) SourceRootDirs() []string { | 
|  | 1294 | return c.productVariables.SourceRootDirs | 
|  | 1295 | } | 
|  | 1296 |  | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 1297 | func (c *config) HostStaticBinaries() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1298 | return Bool(c.productVariables.HostStaticBinaries) | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 1299 | } | 
|  | 1300 |  | 
| Colin Cross | 5a0dcd5 | 2018-10-05 14:20:06 -0700 | [diff] [blame] | 1301 | func (c *config) UncompressPrivAppDex() bool { | 
|  | 1302 | return Bool(c.productVariables.UncompressPrivAppDex) | 
|  | 1303 | } | 
|  | 1304 |  | 
|  | 1305 | func (c *config) ModulesLoadedByPrivilegedModules() []string { | 
|  | 1306 | return c.productVariables.ModulesLoadedByPrivilegedModules | 
|  | 1307 | } | 
|  | 1308 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1309 | // DexpreoptGlobalConfigPath returns the path to the dexpreopt.config file in | 
|  | 1310 | // the output directory, if it was created during the product configuration | 
|  | 1311 | // phase by Kati. | 
| Jingwen Chen | ebb0b57 | 2020-11-02 00:24:57 -0500 | [diff] [blame] | 1312 | func (c *config) DexpreoptGlobalConfigPath(ctx PathContext) OptionalPath { | 
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 1313 | if c.productVariables.DexpreoptGlobalConfig == nil { | 
| Jingwen Chen | ebb0b57 | 2020-11-02 00:24:57 -0500 | [diff] [blame] | 1314 | return OptionalPathForPath(nil) | 
|  | 1315 | } | 
|  | 1316 | return OptionalPathForPath( | 
|  | 1317 | pathForBuildToolDep(ctx, *c.productVariables.DexpreoptGlobalConfig)) | 
|  | 1318 | } | 
|  | 1319 |  | 
| Jingwen Chen | c711fec | 2020-11-22 23:52:50 -0500 | [diff] [blame] | 1320 | // DexpreoptGlobalConfig returns the raw byte contents of the dexpreopt global | 
|  | 1321 | // configuration. Since the configuration file was created by Kati during | 
|  | 1322 | // product configuration (externally of soong_build), it's not tracked, so we | 
|  | 1323 | // also manually add a Ninja file dependency on the configuration file to the | 
|  | 1324 | // rule that creates the main build.ninja file. This ensures that build.ninja is | 
|  | 1325 | // regenerated correctly if dexpreopt.config changes. | 
| Jingwen Chen | ebb0b57 | 2020-11-02 00:24:57 -0500 | [diff] [blame] | 1326 | func (c *config) DexpreoptGlobalConfig(ctx PathContext) ([]byte, error) { | 
|  | 1327 | path := c.DexpreoptGlobalConfigPath(ctx) | 
|  | 1328 | if !path.Valid() { | 
| Colin Cross | 988414c | 2020-01-11 01:11:46 +0000 | [diff] [blame] | 1329 | return nil, nil | 
|  | 1330 | } | 
| Jingwen Chen | ebb0b57 | 2020-11-02 00:24:57 -0500 | [diff] [blame] | 1331 | ctx.AddNinjaFileDeps(path.String()) | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 1332 | return os.ReadFile(absolutePath(path.String())) | 
| Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 1333 | } | 
|  | 1334 |  | 
| Inseob Kim | 7b85eeb | 2021-03-23 20:52:24 +0900 | [diff] [blame] | 1335 | func (c *deviceConfig) WithDexpreopt() bool { | 
|  | 1336 | return c.config.productVariables.WithDexpreopt | 
|  | 1337 | } | 
|  | 1338 |  | 
| Colin Cross | 662d614 | 2022-11-03 20:38:01 -0700 | [diff] [blame] | 1339 | func (c *config) FrameworksBaseDirExists(ctx PathGlobContext) bool { | 
| Colin Cross | 5a756a6 | 2021-03-16 16:34:46 -0700 | [diff] [blame] | 1340 | return ExistentPathForSource(ctx, "frameworks", "base", "Android.bp").Valid() | 
| David Brazdil | 91b4e3e | 2019-01-23 21:04:05 +0000 | [diff] [blame] | 1341 | } | 
|  | 1342 |  | 
| Inseob Kim | ae55303 | 2019-05-14 18:52:49 +0900 | [diff] [blame] | 1343 | func (c *config) VndkSnapshotBuildArtifacts() bool { | 
|  | 1344 | return Bool(c.productVariables.VndkSnapshotBuildArtifacts) | 
|  | 1345 | } | 
|  | 1346 |  | 
| Colin Cross | 3b19f5d | 2019-09-17 14:45:31 -0700 | [diff] [blame] | 1347 | func (c *config) HasMultilibConflict(arch ArchType) bool { | 
|  | 1348 | return c.multilibConflicts[arch] | 
|  | 1349 | } | 
|  | 1350 |  | 
| Sasha Smundak | af5ca92 | 2022-12-12 21:23:34 -0800 | [diff] [blame] | 1351 | func (c *config) PrebuiltHiddenApiDir(_ PathContext) string { | 
| Bill Peckham | bae4749 | 2021-01-08 09:34:44 -0800 | [diff] [blame] | 1352 | return String(c.productVariables.PrebuiltHiddenApiDir) | 
|  | 1353 | } | 
|  | 1354 |  | 
| Justin Yun | 41cbb5e | 2023-11-29 17:58:16 +0900 | [diff] [blame] | 1355 | func (c *config) VendorApiLevel() string { | 
|  | 1356 | return String(c.productVariables.VendorApiLevel) | 
|  | 1357 | } | 
|  | 1358 |  | 
| Hsin-Yi Chen | 2c4a977 | 2024-02-05 17:37:27 +0800 | [diff] [blame] | 1359 | func (c *config) PrevVendorApiLevel() string { | 
|  | 1360 | vendorApiLevel, err := strconv.Atoi(c.VendorApiLevel()) | 
|  | 1361 | if err != nil { | 
|  | 1362 | panic(fmt.Errorf("Cannot parse vendor API level %s to an integer: %s", | 
|  | 1363 | c.VendorApiLevel(), err)) | 
|  | 1364 | } | 
| Hsin-Yi Chen | 2c4a977 | 2024-02-05 17:37:27 +0800 | [diff] [blame] | 1365 | // The version before trunk stable is 34. | 
|  | 1366 | if vendorApiLevel == 202404 { | 
|  | 1367 | return "34" | 
|  | 1368 | } | 
| Hsin-Yi Chen | 890e772 | 2024-03-05 15:56:44 +0800 | [diff] [blame] | 1369 | if vendorApiLevel >= 1 && vendorApiLevel <= 34 { | 
|  | 1370 | return strconv.Itoa(vendorApiLevel - 1) | 
|  | 1371 | } | 
|  | 1372 | if vendorApiLevel < 202404 || vendorApiLevel%100 != 4 { | 
|  | 1373 | panic("Unknown vendor API level " + c.VendorApiLevel()) | 
|  | 1374 | } | 
| Hsin-Yi Chen | 2c4a977 | 2024-02-05 17:37:27 +0800 | [diff] [blame] | 1375 | return strconv.Itoa(vendorApiLevel - 100) | 
|  | 1376 | } | 
|  | 1377 |  | 
| Hsin-Yi Chen | 64b2d03 | 2024-03-29 19:12:35 +0800 | [diff] [blame] | 1378 | func IsTrunkStableVendorApiLevel(level string) bool { | 
|  | 1379 | levelInt, err := strconv.Atoi(level) | 
|  | 1380 | return err == nil && levelInt >= 202404 | 
|  | 1381 | } | 
|  | 1382 |  | 
| Yi-Yo Chiang | 88960aa | 2024-01-19 15:02:29 +0800 | [diff] [blame] | 1383 | func (c *config) VendorApiLevelFrozen() bool { | 
|  | 1384 | return c.productVariables.GetBuildFlagBool("RELEASE_BOARD_API_LEVEL_FROZEN") | 
|  | 1385 | } | 
|  | 1386 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 1387 | func (c *deviceConfig) Arches() []Arch { | 
|  | 1388 | var arches []Arch | 
| Dan Willemsen | 0ef639b | 2018-10-10 17:02:29 -0700 | [diff] [blame] | 1389 | for _, target := range c.config.Targets[Android] { | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 1390 | arches = append(arches, target.Arch) | 
|  | 1391 | } | 
|  | 1392 | return arches | 
|  | 1393 | } | 
| Dan Willemsen | d2ede87 | 2016-11-18 14:54:24 -0800 | [diff] [blame] | 1394 |  | 
| Jayant Chowdhary | 34ce67d | 2018-03-08 11:00:50 -0800 | [diff] [blame] | 1395 | func (c *deviceConfig) BinderBitness() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1396 | is32BitBinder := c.config.productVariables.Binder32bit | 
| Jayant Chowdhary | 34ce67d | 2018-03-08 11:00:50 -0800 | [diff] [blame] | 1397 | if is32BitBinder != nil && *is32BitBinder { | 
|  | 1398 | return "32" | 
|  | 1399 | } | 
|  | 1400 | return "64" | 
|  | 1401 | } | 
|  | 1402 |  | 
| Dan Willemsen | 4353bc4 | 2016-12-05 17:16:02 -0800 | [diff] [blame] | 1403 | func (c *deviceConfig) VendorPath() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1404 | if c.config.productVariables.VendorPath != nil { | 
|  | 1405 | return *c.config.productVariables.VendorPath | 
| Dan Willemsen | 4353bc4 | 2016-12-05 17:16:02 -0800 | [diff] [blame] | 1406 | } | 
|  | 1407 | return "vendor" | 
|  | 1408 | } | 
|  | 1409 |  | 
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1410 | func (c *deviceConfig) RecoverySnapshotVersion() string { | 
|  | 1411 | return String(c.config.productVariables.RecoverySnapshotVersion) | 
|  | 1412 | } | 
|  | 1413 |  | 
| Jeongik Cha | 219141c | 2020-08-06 23:00:37 +0900 | [diff] [blame] | 1414 | func (c *deviceConfig) CurrentApiLevelForVendorModules() string { | 
|  | 1415 | return StringDefault(c.config.productVariables.DeviceCurrentApiLevelForVendorModules, "current") | 
|  | 1416 | } | 
|  | 1417 |  | 
| Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 1418 | func (c *deviceConfig) ExtraVndkVersions() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1419 | return c.config.productVariables.ExtraVndkVersions | 
| Dan Willemsen | d2ede87 | 2016-11-18 14:54:24 -0800 | [diff] [blame] | 1420 | } | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 1421 |  | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 1422 | func (c *deviceConfig) SystemSdkVersions() []string { | 
| Colin Cross | a74ca04 | 2019-01-31 14:31:51 -0800 | [diff] [blame] | 1423 | return c.config.productVariables.DeviceSystemSdkVersions | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 1424 | } | 
|  | 1425 |  | 
|  | 1426 | func (c *deviceConfig) PlatformSystemSdkVersions() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1427 | return c.config.productVariables.Platform_systemsdk_versions | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 1428 | } | 
|  | 1429 |  | 
| Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 1430 | func (c *deviceConfig) OdmPath() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1431 | if c.config.productVariables.OdmPath != nil { | 
|  | 1432 | return *c.config.productVariables.OdmPath | 
| Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 1433 | } | 
|  | 1434 | return "odm" | 
|  | 1435 | } | 
|  | 1436 |  | 
| Jaekyun Seok | 5cfbfbb | 2018-01-10 19:00:15 +0900 | [diff] [blame] | 1437 | func (c *deviceConfig) ProductPath() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1438 | if c.config.productVariables.ProductPath != nil { | 
|  | 1439 | return *c.config.productVariables.ProductPath | 
| Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 1440 | } | 
| Jaekyun Seok | 5cfbfbb | 2018-01-10 19:00:15 +0900 | [diff] [blame] | 1441 | return "product" | 
| Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 1442 | } | 
|  | 1443 |  | 
| Justin Yun | d5f6c82 | 2019-06-25 16:47:17 +0900 | [diff] [blame] | 1444 | func (c *deviceConfig) SystemExtPath() string { | 
|  | 1445 | if c.config.productVariables.SystemExtPath != nil { | 
|  | 1446 | return *c.config.productVariables.SystemExtPath | 
| Dario Freni | fd05a74 | 2018-05-29 13:28:54 +0100 | [diff] [blame] | 1447 | } | 
| Justin Yun | d5f6c82 | 2019-06-25 16:47:17 +0900 | [diff] [blame] | 1448 | return "system_ext" | 
| Dario Freni | fd05a74 | 2018-05-29 13:28:54 +0100 | [diff] [blame] | 1449 | } | 
|  | 1450 |  | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 1451 | func (c *deviceConfig) BtConfigIncludeDir() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1452 | return String(c.config.productVariables.BtConfigIncludeDir) | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 1453 | } | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1454 |  | 
| Jiyong Park | d773eb3 | 2017-07-03 13:18:12 +0900 | [diff] [blame] | 1455 | func (c *deviceConfig) DeviceKernelHeaderDirs() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1456 | return c.config.productVariables.DeviceKernelHeaders | 
| Jiyong Park | d773eb3 | 2017-07-03 13:18:12 +0900 | [diff] [blame] | 1457 | } | 
|  | 1458 |  | 
| Roland Levillain | ada1270 | 2020-06-09 13:07:36 +0100 | [diff] [blame] | 1459 | // JavaCoverageEnabledForPath returns whether Java code coverage is enabled for | 
|  | 1460 | // path. Coverage is enabled by default when the product variable | 
|  | 1461 | // JavaCoveragePaths is empty. If JavaCoveragePaths is not empty, coverage is | 
|  | 1462 | // enabled for any path which is part of this variable (and not part of the | 
|  | 1463 | // JavaCoverageExcludePaths product variable). Value "*" in JavaCoveragePaths | 
|  | 1464 | // represents any path. | 
|  | 1465 | func (c *deviceConfig) JavaCoverageEnabledForPath(path string) bool { | 
|  | 1466 | coverage := false | 
| Chris Gross | 2f74869 | 2020-06-24 20:36:59 +0000 | [diff] [blame] | 1467 | if len(c.config.productVariables.JavaCoveragePaths) == 0 || | 
| Roland Levillain | ada1270 | 2020-06-09 13:07:36 +0100 | [diff] [blame] | 1468 | InList("*", c.config.productVariables.JavaCoveragePaths) || | 
|  | 1469 | HasAnyPrefix(path, c.config.productVariables.JavaCoveragePaths) { | 
|  | 1470 | coverage = true | 
|  | 1471 | } | 
| Roland Levillain | f6cc261 | 2020-07-09 16:58:14 +0100 | [diff] [blame] | 1472 | if coverage && len(c.config.productVariables.JavaCoverageExcludePaths) > 0 { | 
| Roland Levillain | ada1270 | 2020-06-09 13:07:36 +0100 | [diff] [blame] | 1473 | if HasAnyPrefix(path, c.config.productVariables.JavaCoverageExcludePaths) { | 
|  | 1474 | coverage = false | 
|  | 1475 | } | 
|  | 1476 | } | 
|  | 1477 | return coverage | 
|  | 1478 | } | 
|  | 1479 |  | 
| Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 1480 | // Returns true if gcov or clang coverage is enabled. | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1481 | func (c *deviceConfig) NativeCoverageEnabled() bool { | 
| Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 1482 | return Bool(c.config.productVariables.GcovCoverage) || | 
|  | 1483 | Bool(c.config.productVariables.ClangCoverage) | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1484 | } | 
|  | 1485 |  | 
| Oliver Nguyen | 1382ab6 | 2019-12-06 15:22:41 -0800 | [diff] [blame] | 1486 | func (c *deviceConfig) ClangCoverageEnabled() bool { | 
|  | 1487 | return Bool(c.config.productVariables.ClangCoverage) | 
|  | 1488 | } | 
|  | 1489 |  | 
| Pirama Arumuga Nainar | b37ae58 | 2022-01-26 22:14:32 -0800 | [diff] [blame] | 1490 | func (c *deviceConfig) ClangCoverageContinuousMode() bool { | 
|  | 1491 | return Bool(c.config.productVariables.ClangCoverageContinuousMode) | 
|  | 1492 | } | 
|  | 1493 |  | 
| Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 1494 | func (c *deviceConfig) GcovCoverageEnabled() bool { | 
|  | 1495 | return Bool(c.config.productVariables.GcovCoverage) | 
|  | 1496 | } | 
|  | 1497 |  | 
| Roland Levillain | 4f5297b | 2020-06-09 12:44:06 +0100 | [diff] [blame] | 1498 | // NativeCoverageEnabledForPath returns whether (GCOV- or Clang-based) native | 
|  | 1499 | // code coverage is enabled for path. By default, coverage is not enabled for a | 
|  | 1500 | // given path unless it is part of the NativeCoveragePaths product variable (and | 
|  | 1501 | // not part of the NativeCoverageExcludePaths product variable). Value "*" in | 
|  | 1502 | // NativeCoveragePaths represents any path. | 
|  | 1503 | func (c *deviceConfig) NativeCoverageEnabledForPath(path string) bool { | 
| Ryan Campbell | 469a18a | 2017-02-27 09:01:54 -0800 | [diff] [blame] | 1504 | coverage := false | 
| Roland Levillain | f6cc261 | 2020-07-09 16:58:14 +0100 | [diff] [blame] | 1505 | if len(c.config.productVariables.NativeCoveragePaths) > 0 { | 
| Roland Levillain | 4f5297b | 2020-06-09 12:44:06 +0100 | [diff] [blame] | 1506 | if InList("*", c.config.productVariables.NativeCoveragePaths) || HasAnyPrefix(path, c.config.productVariables.NativeCoveragePaths) { | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 1507 | coverage = true | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1508 | } | 
|  | 1509 | } | 
| Roland Levillain | f6cc261 | 2020-07-09 16:58:14 +0100 | [diff] [blame] | 1510 | if coverage && len(c.config.productVariables.NativeCoverageExcludePaths) > 0 { | 
| Yi Kong | fd07ed2 | 2023-02-16 17:42:27 +0900 | [diff] [blame] | 1511 | // Workaround coverage boot failure. | 
|  | 1512 | // http://b/269981180 | 
|  | 1513 | if strings.HasPrefix(path, "external/protobuf") { | 
|  | 1514 | coverage = false | 
|  | 1515 | } | 
| Roland Levillain | 4f5297b | 2020-06-09 12:44:06 +0100 | [diff] [blame] | 1516 | if HasAnyPrefix(path, c.config.productVariables.NativeCoverageExcludePaths) { | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 1517 | coverage = false | 
| Ryan Campbell | 469a18a | 2017-02-27 09:01:54 -0800 | [diff] [blame] | 1518 | } | 
|  | 1519 | } | 
|  | 1520 | return coverage | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1521 | } | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 1522 |  | 
| Pirama Arumuga Nainar | 4954080 | 2018-01-29 23:11:42 -0800 | [diff] [blame] | 1523 | func (c *deviceConfig) PgoAdditionalProfileDirs() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame] | 1524 | return c.config.productVariables.PgoAdditionalProfileDirs | 
| Pirama Arumuga Nainar | 4954080 | 2018-01-29 23:11:42 -0800 | [diff] [blame] | 1525 | } | 
|  | 1526 |  | 
| Vinh Tran | 44cb78c | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 1527 | // AfdoProfile returns fully qualified path associated to the given module name | 
| Colin Cross | d38feb0 | 2024-01-23 16:38:06 -0800 | [diff] [blame] | 1528 | func (c *deviceConfig) AfdoProfile(name string) (string, error) { | 
| Vinh Tran | 44cb78c | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 1529 | for _, afdoProfile := range c.config.productVariables.AfdoProfiles { | 
|  | 1530 | split := strings.Split(afdoProfile, ":") | 
|  | 1531 | if len(split) != 3 { | 
| Colin Cross | d38feb0 | 2024-01-23 16:38:06 -0800 | [diff] [blame] | 1532 | return "", fmt.Errorf("AFDO_PROFILES has invalid value: %s. "+ | 
| Vinh Tran | 44cb78c | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 1533 | "The expected format is <module>:<fully-qualified-path-to-fdo_profile>", afdoProfile) | 
|  | 1534 | } | 
|  | 1535 | if split[0] == name { | 
| Colin Cross | d38feb0 | 2024-01-23 16:38:06 -0800 | [diff] [blame] | 1536 | return strings.Join([]string{split[1], split[2]}, ":"), nil | 
| Vinh Tran | 44cb78c | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 1537 | } | 
|  | 1538 | } | 
| Colin Cross | d38feb0 | 2024-01-23 16:38:06 -0800 | [diff] [blame] | 1539 | return "", nil | 
| Vinh Tran | 44cb78c | 2023-03-09 22:07:19 -0500 | [diff] [blame] | 1540 | } | 
|  | 1541 |  | 
| Tri Vo | 35a5143 | 2018-03-25 20:00:00 -0700 | [diff] [blame] | 1542 | func (c *deviceConfig) VendorSepolicyDirs() []string { | 
|  | 1543 | return c.config.productVariables.BoardVendorSepolicyDirs | 
|  | 1544 | } | 
|  | 1545 |  | 
|  | 1546 | func (c *deviceConfig) OdmSepolicyDirs() []string { | 
|  | 1547 | return c.config.productVariables.BoardOdmSepolicyDirs | 
|  | 1548 | } | 
|  | 1549 |  | 
| Felix | a20a875 | 2020-05-17 18:28:35 +0200 | [diff] [blame] | 1550 | func (c *deviceConfig) SystemExtPublicSepolicyDirs() []string { | 
|  | 1551 | return c.config.productVariables.SystemExtPublicSepolicyDirs | 
| Tri Vo | 35a5143 | 2018-03-25 20:00:00 -0700 | [diff] [blame] | 1552 | } | 
|  | 1553 |  | 
| Felix | a20a875 | 2020-05-17 18:28:35 +0200 | [diff] [blame] | 1554 | func (c *deviceConfig) SystemExtPrivateSepolicyDirs() []string { | 
|  | 1555 | return c.config.productVariables.SystemExtPrivateSepolicyDirs | 
| Tri Vo | 35a5143 | 2018-03-25 20:00:00 -0700 | [diff] [blame] | 1556 | } | 
|  | 1557 |  | 
| Inseob Kim | 0866b00 | 2019-04-15 20:21:29 +0900 | [diff] [blame] | 1558 | func (c *deviceConfig) SepolicyM4Defs() []string { | 
|  | 1559 | return c.config.productVariables.BoardSepolicyM4Defs | 
|  | 1560 | } | 
|  | 1561 |  | 
| Jiyong Park | 7f67f48 | 2019-01-05 12:57:48 +0900 | [diff] [blame] | 1562 | func (c *deviceConfig) OverrideManifestPackageNameFor(name string) (manifestName string, overridden bool) { | 
| Jaewoong Jung | 2ad817c | 2019-01-18 14:27:16 -0800 | [diff] [blame] | 1563 | return findOverrideValue(c.config.productVariables.ManifestPackageNameOverrides, name, | 
|  | 1564 | "invalid override rule %q in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES should be <module_name>:<manifest_name>") | 
|  | 1565 | } | 
|  | 1566 |  | 
|  | 1567 | func (c *deviceConfig) OverrideCertificateFor(name string) (certificatePath string, overridden bool) { | 
| Jaewoong Jung | acb6db3 | 2019-02-28 16:22:30 +0000 | [diff] [blame] | 1568 | return findOverrideValue(c.config.productVariables.CertificateOverrides, name, | 
| Jaewoong Jung | 2ad817c | 2019-01-18 14:27:16 -0800 | [diff] [blame] | 1569 | "invalid override rule %q in PRODUCT_CERTIFICATE_OVERRIDES should be <module_name>:<certificate_module_name>") | 
|  | 1570 | } | 
|  | 1571 |  | 
| Jaewoong Jung | 9d22a91 | 2019-01-23 16:27:47 -0800 | [diff] [blame] | 1572 | func (c *deviceConfig) OverridePackageNameFor(name string) string { | 
|  | 1573 | newName, overridden := findOverrideValue( | 
|  | 1574 | c.config.productVariables.PackageNameOverrides, | 
|  | 1575 | name, | 
|  | 1576 | "invalid override rule %q in PRODUCT_PACKAGE_NAME_OVERRIDES should be <module_name>:<package_name>") | 
|  | 1577 | if overridden { | 
|  | 1578 | return newName | 
|  | 1579 | } | 
|  | 1580 | return name | 
|  | 1581 | } | 
|  | 1582 |  | 
| Jaewoong Jung | 2ad817c | 2019-01-18 14:27:16 -0800 | [diff] [blame] | 1583 | func findOverrideValue(overrides []string, name string, errorMsg string) (newValue string, overridden bool) { | 
| Jiyong Park | 7f67f48 | 2019-01-05 12:57:48 +0900 | [diff] [blame] | 1584 | if overrides == nil || len(overrides) == 0 { | 
|  | 1585 | return "", false | 
|  | 1586 | } | 
|  | 1587 | for _, o := range overrides { | 
|  | 1588 | split := strings.Split(o, ":") | 
|  | 1589 | if len(split) != 2 { | 
|  | 1590 | // This shouldn't happen as this is first checked in make, but just in case. | 
| Jaewoong Jung | 2ad817c | 2019-01-18 14:27:16 -0800 | [diff] [blame] | 1591 | panic(fmt.Errorf(errorMsg, o)) | 
| Jiyong Park | 7f67f48 | 2019-01-05 12:57:48 +0900 | [diff] [blame] | 1592 | } | 
|  | 1593 | if matchPattern(split[0], name) { | 
|  | 1594 | return substPattern(split[0], split[1], name), true | 
|  | 1595 | } | 
|  | 1596 | } | 
|  | 1597 | return "", false | 
|  | 1598 | } | 
|  | 1599 |  | 
| Albert Martin | eefabcf | 2022-03-21 20:11:16 +0000 | [diff] [blame] | 1600 | func (c *deviceConfig) ApexGlobalMinSdkVersionOverride() string { | 
|  | 1601 | return String(c.config.productVariables.ApexGlobalMinSdkVersionOverride) | 
|  | 1602 | } | 
|  | 1603 |  | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 1604 | func (c *config) IntegerOverflowDisabledForPath(path string) bool { | 
| Roland Levillain | f6cc261 | 2020-07-09 16:58:14 +0100 | [diff] [blame] | 1605 | if len(c.productVariables.IntegerOverflowExcludePaths) == 0 { | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 1606 | return false | 
|  | 1607 | } | 
| Jaewoong Jung | 3aff578 | 2020-02-11 07:54:35 -0800 | [diff] [blame] | 1608 | return HasAnyPrefix(path, c.productVariables.IntegerOverflowExcludePaths) | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 1609 | } | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 1610 |  | 
|  | 1611 | func (c *config) CFIDisabledForPath(path string) bool { | 
| Roland Levillain | f6cc261 | 2020-07-09 16:58:14 +0100 | [diff] [blame] | 1612 | if len(c.productVariables.CFIExcludePaths) == 0 { | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 1613 | return false | 
|  | 1614 | } | 
| Jaewoong Jung | 3aff578 | 2020-02-11 07:54:35 -0800 | [diff] [blame] | 1615 | return HasAnyPrefix(path, c.productVariables.CFIExcludePaths) | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 1616 | } | 
|  | 1617 |  | 
|  | 1618 | func (c *config) CFIEnabledForPath(path string) bool { | 
| Roland Levillain | f6cc261 | 2020-07-09 16:58:14 +0100 | [diff] [blame] | 1619 | if len(c.productVariables.CFIIncludePaths) == 0 { | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 1620 | return false | 
|  | 1621 | } | 
| Evgenii Stepanov | 779b64e | 2021-04-09 14:33:10 -0700 | [diff] [blame] | 1622 | return HasAnyPrefix(path, c.productVariables.CFIIncludePaths) && !c.CFIDisabledForPath(path) | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 1623 | } | 
| Colin Cross | e15ddaf | 2017-12-04 11:24:31 -0800 | [diff] [blame] | 1624 |  | 
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 1625 | func (c *config) MemtagHeapDisabledForPath(path string) bool { | 
|  | 1626 | if len(c.productVariables.MemtagHeapExcludePaths) == 0 { | 
|  | 1627 | return false | 
|  | 1628 | } | 
|  | 1629 | return HasAnyPrefix(path, c.productVariables.MemtagHeapExcludePaths) | 
|  | 1630 | } | 
|  | 1631 |  | 
|  | 1632 | func (c *config) MemtagHeapAsyncEnabledForPath(path string) bool { | 
|  | 1633 | if len(c.productVariables.MemtagHeapAsyncIncludePaths) == 0 { | 
|  | 1634 | return false | 
|  | 1635 | } | 
| Evgenii Stepanov | 779b64e | 2021-04-09 14:33:10 -0700 | [diff] [blame] | 1636 | return HasAnyPrefix(path, c.productVariables.MemtagHeapAsyncIncludePaths) && !c.MemtagHeapDisabledForPath(path) | 
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 1637 | } | 
|  | 1638 |  | 
|  | 1639 | func (c *config) MemtagHeapSyncEnabledForPath(path string) bool { | 
|  | 1640 | if len(c.productVariables.MemtagHeapSyncIncludePaths) == 0 { | 
|  | 1641 | return false | 
|  | 1642 | } | 
| Evgenii Stepanov | 779b64e | 2021-04-09 14:33:10 -0700 | [diff] [blame] | 1643 | return HasAnyPrefix(path, c.productVariables.MemtagHeapSyncIncludePaths) && !c.MemtagHeapDisabledForPath(path) | 
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 1644 | } | 
|  | 1645 |  | 
| Tomislav Novak | f734f00 | 2023-08-22 10:51:44 -0700 | [diff] [blame] | 1646 | func (c *config) HWASanDisabledForPath(path string) bool { | 
|  | 1647 | if len(c.productVariables.HWASanExcludePaths) == 0 { | 
|  | 1648 | return false | 
|  | 1649 | } | 
|  | 1650 | return HasAnyPrefix(path, c.productVariables.HWASanExcludePaths) | 
|  | 1651 | } | 
|  | 1652 |  | 
| Hang Lu | a98aab9 | 2023-03-17 13:17:22 +0800 | [diff] [blame] | 1653 | func (c *config) HWASanEnabledForPath(path string) bool { | 
|  | 1654 | if len(c.productVariables.HWASanIncludePaths) == 0 { | 
|  | 1655 | return false | 
|  | 1656 | } | 
| Tomislav Novak | f734f00 | 2023-08-22 10:51:44 -0700 | [diff] [blame] | 1657 | return HasAnyPrefix(path, c.productVariables.HWASanIncludePaths) && !c.HWASanDisabledForPath(path) | 
| Hang Lu | a98aab9 | 2023-03-17 13:17:22 +0800 | [diff] [blame] | 1658 | } | 
|  | 1659 |  | 
| Dan Willemsen | 0fe7866 | 2018-03-26 12:41:18 -0700 | [diff] [blame] | 1660 | func (c *config) VendorConfig(name string) VendorConfig { | 
| Colin Cross | 9d34f35 | 2019-11-22 16:03:51 -0800 | [diff] [blame] | 1661 | return soongconfig.Config(c.productVariables.VendorVars[name]) | 
| Dan Willemsen | 0fe7866 | 2018-03-26 12:41:18 -0700 | [diff] [blame] | 1662 | } | 
|  | 1663 |  | 
| Colin Cross | 395f2cf | 2018-10-24 16:10:32 -0700 | [diff] [blame] | 1664 | func (c *config) NdkAbis() bool { | 
|  | 1665 | return Bool(c.productVariables.Ndk_abis) | 
|  | 1666 | } | 
|  | 1667 |  | 
| Martin Stjernholm | c1ecc43 | 2019-11-15 15:00:31 +0000 | [diff] [blame] | 1668 | func (c *config) AmlAbis() bool { | 
|  | 1669 | return Bool(c.productVariables.Aml_abis) | 
|  | 1670 | } | 
|  | 1671 |  | 
| Jiyong Park | 4da0797 | 2021-01-05 21:01:11 +0900 | [diff] [blame] | 1672 | func (c *config) ForceApexSymlinkOptimization() bool { | 
|  | 1673 | return Bool(c.productVariables.ForceApexSymlinkOptimization) | 
|  | 1674 | } | 
|  | 1675 |  | 
| Sasha Smundak | fe9a5b8 | 2022-07-27 14:51:45 -0700 | [diff] [blame] | 1676 | func (c *config) ApexCompressionEnabled() bool { | 
|  | 1677 | return Bool(c.productVariables.CompressedApex) && !c.UnbundledBuildApps() | 
| Mohammad Samiul Islam | 3cd005d | 2020-11-26 13:32:26 +0000 | [diff] [blame] | 1678 | } | 
|  | 1679 |  | 
| Dennis Shen | e2ed70c | 2023-01-11 14:15:43 +0000 | [diff] [blame] | 1680 | func (c *config) ApexTrimEnabled() bool { | 
|  | 1681 | return Bool(c.productVariables.TrimmedApex) | 
|  | 1682 | } | 
|  | 1683 |  | 
| Jeongik Cha | c946414 | 2019-01-07 12:07:27 +0900 | [diff] [blame] | 1684 | func (c *config) EnforceSystemCertificate() bool { | 
|  | 1685 | return Bool(c.productVariables.EnforceSystemCertificate) | 
|  | 1686 | } | 
|  | 1687 |  | 
| Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 1688 | func (c *config) EnforceSystemCertificateAllowList() []string { | 
|  | 1689 | return c.productVariables.EnforceSystemCertificateAllowList | 
| Jeongik Cha | c946414 | 2019-01-07 12:07:27 +0900 | [diff] [blame] | 1690 | } | 
|  | 1691 |  | 
| Jeongik Cha | 2cc570d | 2019-10-29 15:44:45 +0900 | [diff] [blame] | 1692 | func (c *config) EnforceProductPartitionInterface() bool { | 
|  | 1693 | return Bool(c.productVariables.EnforceProductPartitionInterface) | 
|  | 1694 | } | 
|  | 1695 |  | 
| JaeMan Park | ff71556 | 2020-10-19 17:25:58 +0900 | [diff] [blame] | 1696 | func (c *config) EnforceInterPartitionJavaSdkLibrary() bool { | 
|  | 1697 | return Bool(c.productVariables.EnforceInterPartitionJavaSdkLibrary) | 
|  | 1698 | } | 
|  | 1699 |  | 
|  | 1700 | func (c *config) InterPartitionJavaLibraryAllowList() []string { | 
|  | 1701 | return c.productVariables.InterPartitionJavaLibraryAllowList | 
|  | 1702 | } | 
|  | 1703 |  | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 1704 | func (c *config) ProductHiddenAPIStubs() []string { | 
|  | 1705 | return c.productVariables.ProductHiddenAPIStubs | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 1706 | } | 
|  | 1707 |  | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 1708 | func (c *config) ProductHiddenAPIStubsSystem() []string { | 
|  | 1709 | return c.productVariables.ProductHiddenAPIStubsSystem | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 1710 | } | 
|  | 1711 |  | 
| Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 1712 | func (c *config) ProductHiddenAPIStubsTest() []string { | 
|  | 1713 | return c.productVariables.ProductHiddenAPIStubsTest | 
| Colin Cross | 8faf8fc | 2019-01-16 15:15:52 -0800 | [diff] [blame] | 1714 | } | 
| Dan Willemsen | 71c7460 | 2019-04-10 12:27:35 -0700 | [diff] [blame] | 1715 |  | 
| Dan Willemsen | 54879d1 | 2019-04-18 10:08:46 -0700 | [diff] [blame] | 1716 | func (c *deviceConfig) TargetFSConfigGen() []string { | 
| Dan Willemsen | 71c7460 | 2019-04-10 12:27:35 -0700 | [diff] [blame] | 1717 | return c.config.productVariables.TargetFSConfigGen | 
|  | 1718 | } | 
| Inseob Kim | 0866b00 | 2019-04-15 20:21:29 +0900 | [diff] [blame] | 1719 |  | 
|  | 1720 | func (c *config) ProductPublicSepolicyDirs() []string { | 
|  | 1721 | return c.productVariables.ProductPublicSepolicyDirs | 
|  | 1722 | } | 
|  | 1723 |  | 
|  | 1724 | func (c *config) ProductPrivateSepolicyDirs() []string { | 
|  | 1725 | return c.productVariables.ProductPrivateSepolicyDirs | 
|  | 1726 | } | 
|  | 1727 |  | 
| Inseob Kim | 5eb7ee9 | 2022-04-27 10:30:34 +0900 | [diff] [blame] | 1728 | func (c *config) TargetMultitreeUpdateMeta() bool { | 
|  | 1729 | return c.productVariables.MultitreeUpdateMeta | 
|  | 1730 | } | 
|  | 1731 |  | 
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 1732 | func (c *deviceConfig) DeviceArch() string { | 
|  | 1733 | return String(c.config.productVariables.DeviceArch) | 
|  | 1734 | } | 
|  | 1735 |  | 
|  | 1736 | func (c *deviceConfig) DeviceArchVariant() string { | 
|  | 1737 | return String(c.config.productVariables.DeviceArchVariant) | 
|  | 1738 | } | 
|  | 1739 |  | 
|  | 1740 | func (c *deviceConfig) DeviceSecondaryArch() string { | 
|  | 1741 | return String(c.config.productVariables.DeviceSecondaryArch) | 
|  | 1742 | } | 
|  | 1743 |  | 
|  | 1744 | func (c *deviceConfig) DeviceSecondaryArchVariant() string { | 
|  | 1745 | return String(c.config.productVariables.DeviceSecondaryArchVariant) | 
|  | 1746 | } | 
| Yifan Hong | 82db735 | 2020-01-21 16:12:26 -0800 | [diff] [blame] | 1747 |  | 
|  | 1748 | func (c *deviceConfig) BoardUsesRecoveryAsBoot() bool { | 
|  | 1749 | return Bool(c.config.productVariables.BoardUsesRecoveryAsBoot) | 
|  | 1750 | } | 
| Yifan Hong | 97365ee | 2020-07-29 09:51:57 -0700 | [diff] [blame] | 1751 |  | 
|  | 1752 | func (c *deviceConfig) BoardKernelBinaries() []string { | 
|  | 1753 | return c.config.productVariables.BoardKernelBinaries | 
|  | 1754 | } | 
| Ulya Trafimovich | 249386a | 2020-07-01 14:31:13 +0100 | [diff] [blame] | 1755 |  | 
| Yifan Hong | 42bef8d | 2020-08-05 14:36:09 -0700 | [diff] [blame] | 1756 | func (c *deviceConfig) BoardKernelModuleInterfaceVersions() []string { | 
|  | 1757 | return c.config.productVariables.BoardKernelModuleInterfaceVersions | 
|  | 1758 | } | 
|  | 1759 |  | 
| Yifan Hong | dd8dacc | 2020-10-21 15:40:17 -0700 | [diff] [blame] | 1760 | func (c *deviceConfig) BoardMoveRecoveryResourcesToVendorBoot() bool { | 
|  | 1761 | return Bool(c.config.productVariables.BoardMoveRecoveryResourcesToVendorBoot) | 
|  | 1762 | } | 
|  | 1763 |  | 
| Inseob Kim | 16ebd5a | 2020-12-09 23:08:17 +0900 | [diff] [blame] | 1764 | func (c *deviceConfig) PlatformSepolicyVersion() string { | 
|  | 1765 | return String(c.config.productVariables.PlatformSepolicyVersion) | 
|  | 1766 | } | 
|  | 1767 |  | 
| Inseob Kim | 843f664 | 2022-01-07 09:11:23 +0900 | [diff] [blame] | 1768 | func (c *deviceConfig) PlatformSepolicyCompatVersions() []string { | 
|  | 1769 | return c.config.productVariables.PlatformSepolicyCompatVersions | 
|  | 1770 | } | 
|  | 1771 |  | 
| Inseob Kim | 16ebd5a | 2020-12-09 23:08:17 +0900 | [diff] [blame] | 1772 | func (c *deviceConfig) BoardSepolicyVers() string { | 
| Inseob Kim | 0c4eec8 | 2021-03-22 22:33:40 +0900 | [diff] [blame] | 1773 | if ver := String(c.config.productVariables.BoardSepolicyVers); ver != "" { | 
|  | 1774 | return ver | 
|  | 1775 | } | 
|  | 1776 | return c.PlatformSepolicyVersion() | 
| Inseob Kim | 16ebd5a | 2020-12-09 23:08:17 +0900 | [diff] [blame] | 1777 | } | 
|  | 1778 |  | 
| Inseob Kim | 1a0afcc | 2022-02-14 23:10:51 +0900 | [diff] [blame] | 1779 | func (c *deviceConfig) SystemExtSepolicyPrebuiltApiDir() string { | 
|  | 1780 | return String(c.config.productVariables.SystemExtSepolicyPrebuiltApiDir) | 
|  | 1781 | } | 
|  | 1782 |  | 
|  | 1783 | func (c *deviceConfig) ProductSepolicyPrebuiltApiDir() string { | 
|  | 1784 | return String(c.config.productVariables.ProductSepolicyPrebuiltApiDir) | 
|  | 1785 | } | 
|  | 1786 |  | 
|  | 1787 | func (c *deviceConfig) IsPartnerTrebleSepolicyTestEnabled() bool { | 
|  | 1788 | return c.SystemExtSepolicyPrebuiltApiDir() != "" || c.ProductSepolicyPrebuiltApiDir() != "" | 
|  | 1789 | } | 
|  | 1790 |  | 
| Inseob Kim | 7cf1465 | 2021-01-06 23:06:52 +0900 | [diff] [blame] | 1791 | func (c *deviceConfig) DirectedVendorSnapshot() bool { | 
|  | 1792 | return c.config.productVariables.DirectedVendorSnapshot | 
|  | 1793 | } | 
|  | 1794 |  | 
|  | 1795 | func (c *deviceConfig) VendorSnapshotModules() map[string]bool { | 
|  | 1796 | return c.config.productVariables.VendorSnapshotModules | 
|  | 1797 | } | 
|  | 1798 |  | 
| Jose Galmes | 4c6895e | 2021-02-09 07:44:30 -0800 | [diff] [blame] | 1799 | func (c *deviceConfig) DirectedRecoverySnapshot() bool { | 
|  | 1800 | return c.config.productVariables.DirectedRecoverySnapshot | 
|  | 1801 | } | 
|  | 1802 |  | 
|  | 1803 | func (c *deviceConfig) RecoverySnapshotModules() map[string]bool { | 
|  | 1804 | return c.config.productVariables.RecoverySnapshotModules | 
|  | 1805 | } | 
|  | 1806 |  | 
| Justin DeMartino | 383bfb3 | 2021-02-24 10:49:43 -0800 | [diff] [blame] | 1807 | func createDirsMap(previous map[string]bool, dirs []string) (map[string]bool, error) { | 
|  | 1808 | var ret = make(map[string]bool) | 
|  | 1809 | for _, dir := range dirs { | 
|  | 1810 | clean := filepath.Clean(dir) | 
|  | 1811 | if previous[clean] || ret[clean] { | 
|  | 1812 | return nil, fmt.Errorf("Duplicate entry %s", dir) | 
|  | 1813 | } | 
|  | 1814 | ret[clean] = true | 
|  | 1815 | } | 
|  | 1816 | return ret, nil | 
|  | 1817 | } | 
|  | 1818 |  | 
|  | 1819 | func (c *deviceConfig) createDirsMapOnce(onceKey OnceKey, previous map[string]bool, dirs []string) map[string]bool { | 
|  | 1820 | dirMap := c.Once(onceKey, func() interface{} { | 
|  | 1821 | ret, err := createDirsMap(previous, dirs) | 
|  | 1822 | if err != nil { | 
|  | 1823 | panic(fmt.Errorf("%s: %w", onceKey.key, err)) | 
|  | 1824 | } | 
|  | 1825 | return ret | 
|  | 1826 | }) | 
|  | 1827 | if dirMap == nil { | 
|  | 1828 | return nil | 
|  | 1829 | } | 
|  | 1830 | return dirMap.(map[string]bool) | 
|  | 1831 | } | 
|  | 1832 |  | 
|  | 1833 | var vendorSnapshotDirsExcludedKey = NewOnceKey("VendorSnapshotDirsExcludedMap") | 
|  | 1834 |  | 
|  | 1835 | func (c *deviceConfig) VendorSnapshotDirsExcludedMap() map[string]bool { | 
|  | 1836 | return c.createDirsMapOnce(vendorSnapshotDirsExcludedKey, nil, | 
|  | 1837 | c.config.productVariables.VendorSnapshotDirsExcluded) | 
|  | 1838 | } | 
|  | 1839 |  | 
|  | 1840 | var vendorSnapshotDirsIncludedKey = NewOnceKey("VendorSnapshotDirsIncludedMap") | 
|  | 1841 |  | 
|  | 1842 | func (c *deviceConfig) VendorSnapshotDirsIncludedMap() map[string]bool { | 
|  | 1843 | excludedMap := c.VendorSnapshotDirsExcludedMap() | 
|  | 1844 | return c.createDirsMapOnce(vendorSnapshotDirsIncludedKey, excludedMap, | 
|  | 1845 | c.config.productVariables.VendorSnapshotDirsIncluded) | 
|  | 1846 | } | 
|  | 1847 |  | 
|  | 1848 | var recoverySnapshotDirsExcludedKey = NewOnceKey("RecoverySnapshotDirsExcludedMap") | 
|  | 1849 |  | 
|  | 1850 | func (c *deviceConfig) RecoverySnapshotDirsExcludedMap() map[string]bool { | 
|  | 1851 | return c.createDirsMapOnce(recoverySnapshotDirsExcludedKey, nil, | 
|  | 1852 | c.config.productVariables.RecoverySnapshotDirsExcluded) | 
|  | 1853 | } | 
|  | 1854 |  | 
|  | 1855 | var recoverySnapshotDirsIncludedKey = NewOnceKey("RecoverySnapshotDirsIncludedMap") | 
|  | 1856 |  | 
|  | 1857 | func (c *deviceConfig) RecoverySnapshotDirsIncludedMap() map[string]bool { | 
|  | 1858 | excludedMap := c.RecoverySnapshotDirsExcludedMap() | 
|  | 1859 | return c.createDirsMapOnce(recoverySnapshotDirsIncludedKey, excludedMap, | 
|  | 1860 | c.config.productVariables.RecoverySnapshotDirsIncluded) | 
|  | 1861 | } | 
|  | 1862 |  | 
| Rob Seymour | 925aa09 | 2021-08-10 20:42:03 +0000 | [diff] [blame] | 1863 | func (c *deviceConfig) HostFakeSnapshotEnabled() bool { | 
|  | 1864 | return c.config.productVariables.HostFakeSnapshotEnabled | 
|  | 1865 | } | 
|  | 1866 |  | 
| Inseob Kim | 60c32f0 | 2020-12-21 22:53:05 +0900 | [diff] [blame] | 1867 | func (c *deviceConfig) ShippingApiLevel() ApiLevel { | 
| Steven Moreland | a48df2b | 2024-06-03 22:29:38 +0000 | [diff] [blame] | 1868 | if c.config.productVariables.Shipping_api_level == nil { | 
| Inseob Kim | 60c32f0 | 2020-12-21 22:53:05 +0900 | [diff] [blame] | 1869 | return NoneApiLevel | 
|  | 1870 | } | 
| Steven Moreland | a48df2b | 2024-06-03 22:29:38 +0000 | [diff] [blame] | 1871 | apiLevel, _ := strconv.Atoi(*c.config.productVariables.Shipping_api_level) | 
| Inseob Kim | 60c32f0 | 2020-12-21 22:53:05 +0900 | [diff] [blame] | 1872 | return uncheckedFinalApiLevel(apiLevel) | 
|  | 1873 | } | 
|  | 1874 |  | 
| Liz Kammer | 33cc80e | 2023-05-18 18:20:28 +0000 | [diff] [blame] | 1875 | func (c *deviceConfig) BuildBrokenPluginValidation() []string { | 
|  | 1876 | return c.config.productVariables.BuildBrokenPluginValidation | 
|  | 1877 | } | 
|  | 1878 |  | 
| Alix Espino | ef47e54 | 2022-09-14 19:10:51 +0000 | [diff] [blame] | 1879 | func (c *deviceConfig) BuildBrokenClangAsFlags() bool { | 
|  | 1880 | return c.config.productVariables.BuildBrokenClangAsFlags | 
|  | 1881 | } | 
|  | 1882 |  | 
|  | 1883 | func (c *deviceConfig) BuildBrokenClangCFlags() bool { | 
|  | 1884 | return c.config.productVariables.BuildBrokenClangCFlags | 
|  | 1885 | } | 
|  | 1886 |  | 
| Alix | b5f6d9e | 2022-04-20 23:00:58 +0000 | [diff] [blame] | 1887 | func (c *deviceConfig) BuildBrokenClangProperty() bool { | 
|  | 1888 | return c.config.productVariables.BuildBrokenClangProperty | 
|  | 1889 | } | 
|  | 1890 |  | 
| Inseob Kim | 67e5add19 | 2021-03-17 18:05:33 +0900 | [diff] [blame] | 1891 | func (c *deviceConfig) BuildBrokenEnforceSyspropOwner() bool { | 
|  | 1892 | return c.config.productVariables.BuildBrokenEnforceSyspropOwner | 
|  | 1893 | } | 
|  | 1894 |  | 
|  | 1895 | func (c *deviceConfig) BuildBrokenTrebleSyspropNeverallow() bool { | 
|  | 1896 | return c.config.productVariables.BuildBrokenTrebleSyspropNeverallow | 
|  | 1897 | } | 
|  | 1898 |  | 
| Cole Faust | edc4c50 | 2022-09-09 19:39:25 -0700 | [diff] [blame] | 1899 | func (c *deviceConfig) BuildBrokenUsesSoongPython2Modules() bool { | 
|  | 1900 | return c.config.productVariables.BuildBrokenUsesSoongPython2Modules | 
|  | 1901 | } | 
|  | 1902 |  | 
| Hridya Valsaraju | 5a5c7d5 | 2021-04-02 16:45:24 -0700 | [diff] [blame] | 1903 | func (c *deviceConfig) BuildDebugfsRestrictionsEnabled() bool { | 
|  | 1904 | return c.config.productVariables.BuildDebugfsRestrictionsEnabled | 
|  | 1905 | } | 
|  | 1906 |  | 
| Inseob Kim | 0cac7b4 | 2021-02-03 18:16:46 +0900 | [diff] [blame] | 1907 | func (c *deviceConfig) BuildBrokenVendorPropertyNamespace() bool { | 
|  | 1908 | return c.config.productVariables.BuildBrokenVendorPropertyNamespace | 
|  | 1909 | } | 
|  | 1910 |  | 
| Liz Kammer | 619be46 | 2022-01-28 15:13:39 -0500 | [diff] [blame] | 1911 | func (c *deviceConfig) BuildBrokenInputDir(name string) bool { | 
|  | 1912 | return InList(name, c.config.productVariables.BuildBrokenInputDirModules) | 
|  | 1913 | } | 
|  | 1914 |  | 
| Jiyong Park | 3bb9924 | 2024-01-04 23:21:26 +0000 | [diff] [blame] | 1915 | func (c *deviceConfig) BuildBrokenDontCheckSystemSdk() bool { | 
|  | 1916 | return c.config.productVariables.BuildBrokenDontCheckSystemSdk | 
|  | 1917 | } | 
|  | 1918 |  | 
| Inseob Kim | 2da72af | 2024-06-18 11:09:12 +0900 | [diff] [blame] | 1919 | func (c *deviceConfig) BuildBrokenDupSysprop() bool { | 
|  | 1920 | return c.config.productVariables.BuildBrokenDupSysprop | 
|  | 1921 | } | 
|  | 1922 |  | 
| Jiakai Zhang | 48203e3 | 2023-06-02 23:42:21 +0100 | [diff] [blame] | 1923 | func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string { | 
|  | 1924 | return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist | 
|  | 1925 | } | 
|  | 1926 |  | 
| Yu Liu | 6a7940c | 2023-05-09 17:12:22 -0700 | [diff] [blame] | 1927 | func (c *deviceConfig) GenruleSandboxing() bool { | 
|  | 1928 | return Bool(c.config.productVariables.GenruleSandboxing) | 
| Vinh Tran | 140d588 | 2022-06-10 14:23:27 -0400 | [diff] [blame] | 1929 | } | 
|  | 1930 |  | 
| Inseob Kim | 67e5add19 | 2021-03-17 18:05:33 +0900 | [diff] [blame] | 1931 | func (c *deviceConfig) RequiresInsecureExecmemForSwiftshader() bool { | 
|  | 1932 | return c.config.productVariables.RequiresInsecureExecmemForSwiftshader | 
|  | 1933 | } | 
|  | 1934 |  | 
| Devin Moore | c381e10 | 2023-07-06 22:03:58 +0000 | [diff] [blame] | 1935 | func (c *deviceConfig) Release_aidl_use_unfrozen() bool { | 
|  | 1936 | return Bool(c.config.productVariables.Release_aidl_use_unfrozen) | 
|  | 1937 | } | 
|  | 1938 |  | 
| Inseob Kim | 67e5add19 | 2021-03-17 18:05:33 +0900 | [diff] [blame] | 1939 | func (c *config) SelinuxIgnoreNeverallows() bool { | 
|  | 1940 | return c.productVariables.SelinuxIgnoreNeverallows | 
|  | 1941 | } | 
|  | 1942 |  | 
| Inseob Kim | a10ef27 | 2021-09-15 03:04:53 +0000 | [diff] [blame] | 1943 | func (c *deviceConfig) SepolicyFreezeTestExtraDirs() []string { | 
|  | 1944 | return c.config.productVariables.SepolicyFreezeTestExtraDirs | 
|  | 1945 | } | 
|  | 1946 |  | 
|  | 1947 | func (c *deviceConfig) SepolicyFreezeTestExtraPrebuiltDirs() []string { | 
|  | 1948 | return c.config.productVariables.SepolicyFreezeTestExtraPrebuiltDirs | 
|  | 1949 | } | 
|  | 1950 |  | 
| Jiyong Park | d163d4d | 2021-10-12 16:47:43 +0900 | [diff] [blame] | 1951 | func (c *deviceConfig) GenerateAidlNdkPlatformBackend() bool { | 
|  | 1952 | return c.config.productVariables.GenerateAidlNdkPlatformBackend | 
|  | 1953 | } | 
|  | 1954 |  | 
| Yu Liu | 67a2842 | 2024-03-05 00:36:31 +0000 | [diff] [blame] | 1955 | func (c *deviceConfig) AconfigContainerValidation() string { | 
|  | 1956 | return c.config.productVariables.AconfigContainerValidation | 
|  | 1957 | } | 
|  | 1958 |  | 
| Christopher Ferris | 98f1022 | 2022-07-13 23:16:52 -0700 | [diff] [blame] | 1959 | func (c *config) IgnorePrefer32OnDevice() bool { | 
|  | 1960 | return c.productVariables.IgnorePrefer32OnDevice | 
|  | 1961 | } | 
|  | 1962 |  | 
| Ulya Trafimovich | 249386a | 2020-07-01 14:31:13 +0100 | [diff] [blame] | 1963 | func (c *config) BootJars() []string { | 
|  | 1964 | return c.Once(earlyBootJarsKey, func() interface{} { | 
| Paul Duffin | 69d1fb1 | 2020-10-23 21:14:20 +0100 | [diff] [blame] | 1965 | list := c.productVariables.BootJars.CopyOfJars() | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 1966 | return append(list, c.productVariables.ApexBootJars.CopyOfJars()...) | 
| Ulya Trafimovich | 249386a | 2020-07-01 14:31:13 +0100 | [diff] [blame] | 1967 | }).([]string) | 
|  | 1968 | } | 
| Paul Duffin | 9a89a2a | 2020-10-28 19:20:06 +0000 | [diff] [blame] | 1969 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 1970 | func (c *config) NonApexBootJars() ConfiguredJarList { | 
| Paul Duffin | 9a89a2a | 2020-10-28 19:20:06 +0000 | [diff] [blame] | 1971 | return c.productVariables.BootJars | 
|  | 1972 | } | 
|  | 1973 |  | 
| satayev | d604b21 | 2021-07-21 14:23:52 +0100 | [diff] [blame] | 1974 | func (c *config) ApexBootJars() ConfiguredJarList { | 
|  | 1975 | return c.productVariables.ApexBootJars | 
| Paul Duffin | 9a89a2a | 2020-10-28 19:20:06 +0000 | [diff] [blame] | 1976 | } | 
| Colin Cross | 77cdcfd | 2021-03-12 11:28:25 -0800 | [diff] [blame] | 1977 |  | 
|  | 1978 | func (c *config) RBEWrapper() string { | 
|  | 1979 | return c.GetenvWithDefault("RBE_WRAPPER", remoteexec.DefaultWrapperPath) | 
|  | 1980 | } | 
| Colin Cross | 9b698b6 | 2021-12-22 09:55:32 -0800 | [diff] [blame] | 1981 |  | 
|  | 1982 | // UseHostMusl returns true if the host target has been configured to build against musl libc. | 
|  | 1983 | func (c *config) UseHostMusl() bool { | 
|  | 1984 | return Bool(c.productVariables.HostMusl) | 
|  | 1985 | } | 
| MarkDacek | ff851b8 | 2022-04-21 18:33:17 +0000 | [diff] [blame] | 1986 |  | 
| Spandan Das | 9e93d3d | 2023-03-08 05:47:29 +0000 | [diff] [blame] | 1987 | // ApiSurfaces directory returns the source path inside the api_surfaces repo | 
|  | 1988 | // (relative to workspace root). | 
|  | 1989 | func (c *config) ApiSurfacesDir(s ApiSurface, version string) string { | 
|  | 1990 | return filepath.Join( | 
|  | 1991 | "build", | 
|  | 1992 | "bazel", | 
|  | 1993 | "api_surfaces", | 
|  | 1994 | s.String(), | 
|  | 1995 | version) | 
|  | 1996 | } | 
| Jihoon Kang | 1bff034 | 2023-01-17 20:40:22 +0000 | [diff] [blame] | 1997 |  | 
| Jihoon Kang | 1975d3e | 2023-10-16 23:24:11 +0000 | [diff] [blame] | 1998 | func (c *config) JavaCoverageEnabled() bool { | 
|  | 1999 | return c.IsEnvTrue("EMMA_INSTRUMENT") || c.IsEnvTrue("EMMA_INSTRUMENT_STATIC") || c.IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") | 
|  | 2000 | } | 
|  | 2001 |  | 
| Jihoon Kang | c1b04d6 | 2023-11-16 19:07:04 +0000 | [diff] [blame] | 2002 | func (c *deviceConfig) BuildFromSourceStub() bool { | 
|  | 2003 | return Bool(c.config.productVariables.BuildFromSourceStub) | 
|  | 2004 | } | 
|  | 2005 |  | 
| Jihoon Kang | 1bff034 | 2023-01-17 20:40:22 +0000 | [diff] [blame] | 2006 | func (c *config) BuildFromTextStub() bool { | 
| Jihoon Kang | 1975d3e | 2023-10-16 23:24:11 +0000 | [diff] [blame] | 2007 | // TODO: b/302320354 - Remove the coverage build specific logic once the | 
|  | 2008 | // robust solution for handling native properties in from-text stub build | 
|  | 2009 | // is implemented. | 
| Jihoon Kang | c1b04d6 | 2023-11-16 19:07:04 +0000 | [diff] [blame] | 2010 | return !c.buildFromSourceStub && | 
|  | 2011 | !c.JavaCoverageEnabled() && | 
|  | 2012 | !c.deviceConfig.BuildFromSourceStub() | 
| Jihoon Kang | 1bff034 | 2023-01-17 20:40:22 +0000 | [diff] [blame] | 2013 | } | 
| Spandan Das | 4deab28 | 2023-03-30 17:06:32 +0000 | [diff] [blame] | 2014 |  | 
|  | 2015 | func (c *config) SetBuildFromTextStub(b bool) { | 
| Jihoon Kang | 2a929ad | 2023-06-08 19:02:07 +0000 | [diff] [blame] | 2016 | c.buildFromSourceStub = !b | 
| Jihoon Kang | cbcad7c | 2023-06-01 22:31:52 +0000 | [diff] [blame] | 2017 | c.productVariables.Build_from_text_stub = boolPtr(b) | 
| Spandan Das | 4deab28 | 2023-03-30 17:06:32 +0000 | [diff] [blame] | 2018 | } | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 2019 |  | 
| Jihoon Kang | 1c92c3e | 2023-03-23 17:44:51 +0000 | [diff] [blame] | 2020 | func (c *config) SetApiLibraries(libs []string) { | 
|  | 2021 | c.apiLibraries = make(map[string]struct{}) | 
|  | 2022 | for _, lib := range libs { | 
|  | 2023 | c.apiLibraries[lib] = struct{}{} | 
|  | 2024 | } | 
|  | 2025 | } | 
|  | 2026 |  | 
|  | 2027 | func (c *config) GetApiLibraries() map[string]struct{} { | 
|  | 2028 | return c.apiLibraries | 
|  | 2029 | } | 
| Inseob Kim | 5bac3b6 | 2023-08-25 21:29:46 +0900 | [diff] [blame] | 2030 |  | 
|  | 2031 | func (c *deviceConfig) CheckVendorSeappViolations() bool { | 
|  | 2032 | return Bool(c.config.productVariables.CheckVendorSeappViolations) | 
|  | 2033 | } | 
| Jihoon Kang | cfbc407 | 2023-09-20 01:02:18 +0000 | [diff] [blame] | 2034 |  | 
| Inseob Kim | e4e85d5 | 2023-10-25 23:53:58 +0900 | [diff] [blame] | 2035 | func (c *config) GetBuildFlag(name string) (string, bool) { | 
|  | 2036 | val, ok := c.productVariables.BuildFlags[name] | 
|  | 2037 | return val, ok | 
|  | 2038 | } | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2039 |  | 
| Colin Cross | 8f1b033 | 2024-01-25 13:39:06 -0800 | [diff] [blame] | 2040 | func (c *config) UseResourceProcessorByDefault() bool { | 
|  | 2041 | return c.productVariables.GetBuildFlagBool("RELEASE_USE_RESOURCE_PROCESSOR_BY_DEFAULT") | 
|  | 2042 | } | 
|  | 2043 |  | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2044 | var ( | 
|  | 2045 | mainlineApexContributionBuildFlags = []string{ | 
| Spandan Das | 06c64f0 | 2024-02-28 18:37:20 +0000 | [diff] [blame] | 2046 | "RELEASE_APEX_CONTRIBUTIONS_ADBD", | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2047 | "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", | 
|  | 2048 | "RELEASE_APEX_CONTRIBUTIONS_APPSEARCH", | 
|  | 2049 | "RELEASE_APEX_CONTRIBUTIONS_ART", | 
|  | 2050 | "RELEASE_APEX_CONTRIBUTIONS_BLUETOOTH", | 
| Spandan Das | 06c64f0 | 2024-02-28 18:37:20 +0000 | [diff] [blame] | 2051 | "RELEASE_APEX_CONTRIBUTIONS_CAPTIVEPORTALLOGIN", | 
|  | 2052 | "RELEASE_APEX_CONTRIBUTIONS_CELLBROADCAST", | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2053 | "RELEASE_APEX_CONTRIBUTIONS_CONFIGINFRASTRUCTURE", | 
|  | 2054 | "RELEASE_APEX_CONTRIBUTIONS_CONNECTIVITY", | 
|  | 2055 | "RELEASE_APEX_CONTRIBUTIONS_CONSCRYPT", | 
|  | 2056 | "RELEASE_APEX_CONTRIBUTIONS_CRASHRECOVERY", | 
|  | 2057 | "RELEASE_APEX_CONTRIBUTIONS_DEVICELOCK", | 
| Spandan Das | 06c64f0 | 2024-02-28 18:37:20 +0000 | [diff] [blame] | 2058 | "RELEASE_APEX_CONTRIBUTIONS_DOCUMENTSUIGOOGLE", | 
|  | 2059 | "RELEASE_APEX_CONTRIBUTIONS_EXTSERVICES", | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2060 | "RELEASE_APEX_CONTRIBUTIONS_HEALTHFITNESS", | 
|  | 2061 | "RELEASE_APEX_CONTRIBUTIONS_IPSEC", | 
|  | 2062 | "RELEASE_APEX_CONTRIBUTIONS_MEDIA", | 
|  | 2063 | "RELEASE_APEX_CONTRIBUTIONS_MEDIAPROVIDER", | 
| Spandan Das | dab69e1 | 2024-04-30 18:14:49 +0000 | [diff] [blame] | 2064 | "RELEASE_APEX_CONTRIBUTIONS_MODULE_METADATA", | 
| Spandan Das | 06c64f0 | 2024-02-28 18:37:20 +0000 | [diff] [blame] | 2065 | "RELEASE_APEX_CONTRIBUTIONS_NETWORKSTACKGOOGLE", | 
|  | 2066 | "RELEASE_APEX_CONTRIBUTIONS_NEURALNETWORKS", | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2067 | "RELEASE_APEX_CONTRIBUTIONS_ONDEVICEPERSONALIZATION", | 
|  | 2068 | "RELEASE_APEX_CONTRIBUTIONS_PERMISSION", | 
| Pedro Loureiro | 57b1b68 | 2024-05-09 13:18:15 +0000 | [diff] [blame] | 2069 | "RELEASE_APEX_CONTRIBUTIONS_PRIMARY_LIBS", | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2070 | "RELEASE_APEX_CONTRIBUTIONS_REMOTEKEYPROVISIONING", | 
| Spandan Das | 06c64f0 | 2024-02-28 18:37:20 +0000 | [diff] [blame] | 2071 | "RELEASE_APEX_CONTRIBUTIONS_RESOLV", | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2072 | "RELEASE_APEX_CONTRIBUTIONS_SCHEDULING", | 
|  | 2073 | "RELEASE_APEX_CONTRIBUTIONS_SDKEXTENSIONS", | 
| Spandan Das | 06c64f0 | 2024-02-28 18:37:20 +0000 | [diff] [blame] | 2074 | "RELEASE_APEX_CONTRIBUTIONS_SWCODEC", | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2075 | "RELEASE_APEX_CONTRIBUTIONS_STATSD", | 
| Alyssa Ketpreechasawat | dcda1c8 | 2024-05-30 19:27:48 +0000 | [diff] [blame] | 2076 | "RELEASE_APEX_CONTRIBUTIONS_TELEMETRY_TVP", | 
| Spandan Das | 06c64f0 | 2024-02-28 18:37:20 +0000 | [diff] [blame] | 2077 | "RELEASE_APEX_CONTRIBUTIONS_TZDATA", | 
| Spandan Das | e3fcb41 | 2023-10-26 20:48:02 +0000 | [diff] [blame] | 2078 | "RELEASE_APEX_CONTRIBUTIONS_UWB", | 
|  | 2079 | "RELEASE_APEX_CONTRIBUTIONS_WIFI", | 
|  | 2080 | } | 
|  | 2081 | ) | 
|  | 2082 |  | 
|  | 2083 | // Returns the list of _selected_ apex_contributions | 
|  | 2084 | // Each mainline module will have one entry in the list | 
|  | 2085 | func (c *config) AllApexContributions() []string { | 
|  | 2086 | ret := []string{} | 
|  | 2087 | for _, f := range mainlineApexContributionBuildFlags { | 
|  | 2088 | if val, exists := c.GetBuildFlag(f); exists && val != "" { | 
|  | 2089 | ret = append(ret, val) | 
|  | 2090 | } | 
|  | 2091 | } | 
|  | 2092 | return ret | 
|  | 2093 | } | 
| Spandan Das | 8ab28dd | 2024-02-17 03:31:45 +0000 | [diff] [blame] | 2094 |  | 
| Spandan Das | 0d24ade | 2024-03-08 04:20:15 +0000 | [diff] [blame] | 2095 | func (c *config) BuildIgnoreApexContributionContents() *bool { | 
| Spandan Das | 8ab28dd | 2024-02-17 03:31:45 +0000 | [diff] [blame] | 2096 | return c.productVariables.BuildIgnoreApexContributionContents | 
|  | 2097 | } | 
| Inseob Kim | 8fa54da | 2024-03-19 16:48:59 +0900 | [diff] [blame] | 2098 |  | 
|  | 2099 | func (c *config) ProductLocales() []string { | 
|  | 2100 | return c.productVariables.ProductLocales | 
|  | 2101 | } | 
|  | 2102 |  | 
|  | 2103 | func (c *config) ProductDefaultWifiChannels() []string { | 
|  | 2104 | return c.productVariables.ProductDefaultWifiChannels | 
|  | 2105 | } | 
|  | 2106 |  | 
|  | 2107 | func (c *config) BoardUseVbmetaDigestInFingerprint() bool { | 
|  | 2108 | return Bool(c.productVariables.BoardUseVbmetaDigestInFingerprint) | 
|  | 2109 | } | 
|  | 2110 |  | 
|  | 2111 | func (c *config) OemProperties() []string { | 
|  | 2112 | return c.productVariables.OemProperties | 
|  | 2113 | } |