| 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 |  | 
|  | 17 | import ( | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 18 | "encoding/json" | 
|  | 19 | "fmt" | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 20 | "io/ioutil" | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 21 | "os" | 
| Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 22 | "path/filepath" | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 23 | "runtime" | 
| Dan Willemsen | 5951c8a | 2016-07-19 19:08:14 -0700 | [diff] [blame] | 24 | "strconv" | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 25 | "strings" | 
| Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 26 | "sync" | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 27 |  | 
| Colin Cross | e87040b | 2017-12-11 15:52:26 -0800 | [diff] [blame] | 28 | "github.com/google/blueprint/bootstrap" | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 29 | "github.com/google/blueprint/proptools" | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 30 | ) | 
|  | 31 |  | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 32 | var Bool = proptools.Bool | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 33 | var String = proptools.String | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 34 | var FutureApiLevel = 10000 | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 35 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 36 | // The configuration file name | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 37 | const configFileName = "soong.config" | 
|  | 38 | const productVariablesFileName = "soong.variables" | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 39 |  | 
|  | 40 | // A FileConfigurableOptions contains options which can be configured by the | 
|  | 41 | // config file. These will be included in the config struct. | 
|  | 42 | type FileConfigurableOptions struct { | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 43 | Mega_device *bool `json:",omitempty"` | 
| Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame] | 44 | Ndk_abis    *bool `json:",omitempty"` | 
| Dan Willemsen | 01a405a | 2016-06-13 17:19:03 -0700 | [diff] [blame] | 45 | Host_bionic *bool `json:",omitempty"` | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 46 | } | 
|  | 47 |  | 
| Colin Cross | 2738597 | 2015-09-18 10:57:10 -0700 | [diff] [blame] | 48 | func (f *FileConfigurableOptions) SetDefaultConfig() { | 
|  | 49 | *f = FileConfigurableOptions{} | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 50 | } | 
|  | 51 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 52 | // A Config object represents the entire build configuration for Android. | 
| Colin Cross | c3c0a49 | 2015-04-10 15:43:55 -0700 | [diff] [blame] | 53 | type Config struct { | 
|  | 54 | *config | 
|  | 55 | } | 
|  | 56 |  | 
| Jeff Gaston | efc1b41 | 2017-03-29 17:29:06 -0700 | [diff] [blame] | 57 | func (c Config) BuildDir() string { | 
|  | 58 | return c.buildDir | 
|  | 59 | } | 
|  | 60 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 61 | // A DeviceConfig object represents the configuration for a particular device being built.  For | 
|  | 62 | // now there will only be one of these, but in the future there may be multiple devices being | 
|  | 63 | // built | 
|  | 64 | type DeviceConfig struct { | 
|  | 65 | *deviceConfig | 
|  | 66 | } | 
|  | 67 |  | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 68 | type config struct { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 69 | FileConfigurableOptions | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 70 | productVariables productVariables | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 71 |  | 
| Dan Willemsen | 674dc7f | 2018-03-12 18:06:05 -0700 | [diff] [blame] | 72 | // Only available on configs created by TestConfig | 
|  | 73 | TestProductVariables *productVariables | 
|  | 74 |  | 
| Colin Cross | e87040b | 2017-12-11 15:52:26 -0800 | [diff] [blame] | 75 | PrimaryBuilder           string | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 76 | ConfigFileName           string | 
|  | 77 | ProductVariablesFileName string | 
|  | 78 |  | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 79 | Targets        map[OsClass][]Target | 
|  | 80 | BuildOsVariant string | 
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 81 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 82 | deviceConfig *deviceConfig | 
|  | 83 |  | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 84 | srcDir   string // the path of the root source directory | 
|  | 85 | buildDir string // the path of the build output directory | 
| Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 86 |  | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 87 | env       map[string]string | 
| Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 88 | envLock   sync.Mutex | 
|  | 89 | envDeps   map[string]string | 
|  | 90 | envFrozen bool | 
| Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 91 |  | 
|  | 92 | inMake bool | 
| Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 93 |  | 
| Colin Cross | 32616ed | 2017-09-05 21:56:44 -0700 | [diff] [blame] | 94 | captureBuild      bool // true for tests, saves build parameters for each module | 
|  | 95 | ignoreEnvironment bool // true for tests, returns empty from all Getenv calls | 
| Colin Cross | cec8171 | 2017-07-13 14:43:27 -0700 | [diff] [blame] | 96 |  | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 97 | useOpenJDK9    bool // Use OpenJDK9, but possibly target 1.8 | 
|  | 98 | targetOpenJDK9 bool // Use OpenJDK9 and target 1.9 | 
|  | 99 |  | 
| Colin Cross | e87040b | 2017-12-11 15:52:26 -0800 | [diff] [blame] | 100 | stopBefore bootstrap.StopBefore | 
|  | 101 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 102 | OncePer | 
|  | 103 | } | 
|  | 104 |  | 
|  | 105 | type deviceConfig struct { | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 106 | config *config | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 107 | OncePer | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 108 | } | 
|  | 109 |  | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 110 | type jsonConfigurable interface { | 
| Colin Cross | 2738597 | 2015-09-18 10:57:10 -0700 | [diff] [blame] | 111 | SetDefaultConfig() | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 112 | } | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 113 |  | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 114 | func loadConfig(config *config) error { | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 115 | err := loadFromConfigFile(&config.FileConfigurableOptions, config.ConfigFileName) | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 116 | if err != nil { | 
|  | 117 | return err | 
|  | 118 | } | 
|  | 119 |  | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 120 | return loadFromConfigFile(&config.productVariables, config.ProductVariablesFileName) | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 121 | } | 
|  | 122 |  | 
|  | 123 | // loads configuration options from a JSON file in the cwd. | 
|  | 124 | func loadFromConfigFile(configurable jsonConfigurable, filename string) error { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 125 | // Try to open the file | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 126 | configFileReader, err := os.Open(filename) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 127 | defer configFileReader.Close() | 
|  | 128 | if os.IsNotExist(err) { | 
|  | 129 | // Need to create a file, so that blueprint & ninja don't get in | 
|  | 130 | // a dependency tracking loop. | 
|  | 131 | // Make a file-configurable-options with defaults, write it out using | 
|  | 132 | // a json writer. | 
| Colin Cross | 2738597 | 2015-09-18 10:57:10 -0700 | [diff] [blame] | 133 | configurable.SetDefaultConfig() | 
|  | 134 | err = saveToConfigFile(configurable, filename) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 135 | if err != nil { | 
|  | 136 | return err | 
|  | 137 | } | 
| Colin Cross | 15cd21a | 2018-02-27 11:26:02 -0800 | [diff] [blame] | 138 | } else if err != nil { | 
|  | 139 | 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] | 140 | } else { | 
|  | 141 | // Make a decoder for it | 
|  | 142 | jsonDecoder := json.NewDecoder(configFileReader) | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 143 | err = jsonDecoder.Decode(configurable) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 144 | if err != nil { | 
| Colin Cross | 15cd21a | 2018-02-27 11:26:02 -0800 | [diff] [blame] | 145 | 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] | 146 | } | 
|  | 147 | } | 
|  | 148 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 149 | // No error | 
|  | 150 | return nil | 
|  | 151 | } | 
|  | 152 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 153 | // atomically writes the config file in case two copies of soong_build are running simultaneously | 
|  | 154 | // (for example, docs generation and ninja manifest generation) | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 155 | func saveToConfigFile(config jsonConfigurable, filename string) error { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 156 | data, err := json.MarshalIndent(&config, "", "    ") | 
|  | 157 | if err != nil { | 
|  | 158 | return fmt.Errorf("cannot marshal config data: %s", err.Error()) | 
|  | 159 | } | 
|  | 160 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 161 | f, err := ioutil.TempFile(filepath.Dir(filename), "config") | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 162 | if err != nil { | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 163 | return fmt.Errorf("cannot create empty config file %s: %s\n", filename, err.Error()) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 164 | } | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 165 | defer os.Remove(f.Name()) | 
|  | 166 | defer f.Close() | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 167 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 168 | _, err = f.Write(data) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 169 | if err != nil { | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 170 | return fmt.Errorf("default config file: %s could not be written: %s", filename, err.Error()) | 
|  | 171 | } | 
|  | 172 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 173 | _, err = f.WriteString("\n") | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 174 | if err != nil { | 
|  | 175 | 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] | 176 | } | 
|  | 177 |  | 
| Colin Cross | d8f2014 | 2016-11-03 09:43:26 -0700 | [diff] [blame] | 178 | f.Close() | 
|  | 179 | os.Rename(f.Name(), filename) | 
|  | 180 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 181 | return nil | 
|  | 182 | } | 
|  | 183 |  | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 184 | // TestConfig returns a Config object suitable for using for tests | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 185 | func TestConfig(buildDir string, env map[string]string) Config { | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 186 | config := &config{ | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 187 | productVariables: productVariables{ | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 188 | DeviceName:           stringPtr("test_device"), | 
|  | 189 | Platform_sdk_version: intPtr(26), | 
|  | 190 | AAPTConfig:           &[]string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"}, | 
|  | 191 | AAPTPreferredConfig:  stringPtr("xhdpi"), | 
|  | 192 | AAPTCharacteristics:  stringPtr("nosdcard"), | 
|  | 193 | AAPTPrebuiltDPI:      &[]string{"xhdpi", "xxhdpi"}, | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 194 | }, | 
|  | 195 |  | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 196 | buildDir:     buildDir, | 
|  | 197 | captureBuild: true, | 
|  | 198 | env:          env, | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 199 | } | 
|  | 200 | config.deviceConfig = &deviceConfig{ | 
|  | 201 | config: config, | 
|  | 202 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 203 | config.TestProductVariables = &config.productVariables | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 204 |  | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 205 | if err := config.fromEnv(); err != nil { | 
|  | 206 | panic(err) | 
|  | 207 | } | 
|  | 208 |  | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 209 | return Config{config} | 
| Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 210 | } | 
|  | 211 |  | 
| Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 212 | // TestConfig returns a Config object suitable for using for tests that need to run the arch mutator | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 213 | func TestArchConfig(buildDir string, env map[string]string) Config { | 
|  | 214 | testConfig := TestConfig(buildDir, env) | 
| Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 215 | config := testConfig.config | 
|  | 216 |  | 
|  | 217 | config.Targets = map[OsClass][]Target{ | 
|  | 218 | Device: []Target{ | 
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 219 | {Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true}}, | 
|  | 220 | {Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true}}, | 
| Colin Cross | ae4c618 | 2017-09-15 17:33:55 -0700 | [diff] [blame] | 221 | }, | 
|  | 222 | Host: []Target{ | 
|  | 223 | {BuildOs, Arch{ArchType: X86_64}}, | 
|  | 224 | {BuildOs, Arch{ArchType: X86}}, | 
|  | 225 | }, | 
|  | 226 | } | 
|  | 227 |  | 
|  | 228 | return testConfig | 
|  | 229 | } | 
|  | 230 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 231 | // New creates a new Config object.  The srcDir argument specifies the path to | 
|  | 232 | // the root source directory. It also loads the config file, if found. | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 233 | func NewConfig(srcDir, buildDir string) (Config, error) { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 234 | // Make a config with default options | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 235 | config := &config{ | 
|  | 236 | ConfigFileName:           filepath.Join(buildDir, configFileName), | 
|  | 237 | ProductVariablesFileName: filepath.Join(buildDir, productVariablesFileName), | 
| Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 238 |  | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 239 | env: originalEnv, | 
|  | 240 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 241 | srcDir:   srcDir, | 
|  | 242 | buildDir: buildDir, | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 243 | } | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 244 |  | 
| Dan Willemsen | 00269f2 | 2017-07-06 16:59:48 -0700 | [diff] [blame] | 245 | config.deviceConfig = &deviceConfig{ | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 246 | config: config, | 
|  | 247 | } | 
|  | 248 |  | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 249 | // Sanity check the build and source directories. This won't catch strange | 
|  | 250 | // configurations with symlinks, but at least checks the obvious cases. | 
|  | 251 | absBuildDir, err := filepath.Abs(buildDir) | 
|  | 252 | if err != nil { | 
|  | 253 | return Config{}, err | 
|  | 254 | } | 
|  | 255 |  | 
|  | 256 | absSrcDir, err := filepath.Abs(srcDir) | 
|  | 257 | if err != nil { | 
|  | 258 | return Config{}, err | 
|  | 259 | } | 
|  | 260 |  | 
|  | 261 | if strings.HasPrefix(absSrcDir, absBuildDir) { | 
|  | 262 | return Config{}, fmt.Errorf("Build dir must not contain source directory") | 
|  | 263 | } | 
|  | 264 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 265 | // Load any configurable options from the configuration file | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 266 | err = loadConfig(config) | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 267 | if err != nil { | 
| Colin Cross | c3c0a49 | 2015-04-10 15:43:55 -0700 | [diff] [blame] | 268 | return Config{}, err | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 269 | } | 
|  | 270 |  | 
| Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 271 | inMakeFile := filepath.Join(buildDir, ".soong.in_make") | 
|  | 272 | if _, err := os.Stat(inMakeFile); err == nil { | 
|  | 273 | config.inMake = true | 
|  | 274 | } | 
|  | 275 |  | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 276 | targets, err := decodeTargetProductVariables(config) | 
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 277 | if err != nil { | 
|  | 278 | return Config{}, err | 
|  | 279 | } | 
|  | 280 |  | 
| Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame] | 281 | var archConfig []archConfig | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 282 | if Bool(config.Mega_device) { | 
| Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame] | 283 | archConfig = getMegaDeviceConfig() | 
|  | 284 | } else if Bool(config.Ndk_abis) { | 
|  | 285 | archConfig = getNdkAbisConfig() | 
|  | 286 | } | 
|  | 287 |  | 
|  | 288 | if archConfig != nil { | 
|  | 289 | deviceTargets, err := decodeArchSettings(archConfig) | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 290 | if err != nil { | 
|  | 291 | return Config{}, err | 
|  | 292 | } | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 293 | targets[Device] = deviceTargets | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 294 | } | 
|  | 295 |  | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 296 | config.Targets = targets | 
|  | 297 | config.BuildOsVariant = targets[Host][0].String() | 
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 298 |  | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 299 | if err := config.fromEnv(); err != nil { | 
|  | 300 | return Config{}, err | 
|  | 301 | } | 
|  | 302 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 303 | return Config{config}, nil | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 304 | } | 
|  | 305 |  | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 306 | func (c *config) fromEnv() error { | 
|  | 307 | switch c.Getenv("EXPERIMENTAL_USE_OPENJDK9") { | 
|  | 308 | case "": | 
| Tobias Thierer | 18099fd | 2017-11-17 14:14:29 +0000 | [diff] [blame] | 309 | if c.Getenv("RUN_ERROR_PRONE") != "true" { | 
|  | 310 | // Use OpenJDK9, but target 1.8 | 
|  | 311 | c.useOpenJDK9 = true | 
|  | 312 | } | 
| Tobias Thierer | a7cdd15 | 2017-11-15 21:16:25 +0000 | [diff] [blame] | 313 | case "false": | 
|  | 314 | // Use OpenJDK8 | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 315 | case "1.8": | 
|  | 316 | // Use OpenJDK9, but target 1.8 | 
|  | 317 | c.useOpenJDK9 = true | 
|  | 318 | case "true": | 
|  | 319 | // Use OpenJDK9 and target 1.9 | 
|  | 320 | c.useOpenJDK9 = true | 
|  | 321 | c.targetOpenJDK9 = true | 
|  | 322 | default: | 
| Tobias Thierer | 18099fd | 2017-11-17 14:14:29 +0000 | [diff] [blame] | 323 | return fmt.Errorf(`Invalid value for EXPERIMENTAL_USE_OPENJDK9, should be "", "false", "1.8", or "true"`) | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 324 | } | 
|  | 325 |  | 
|  | 326 | return nil | 
|  | 327 | } | 
|  | 328 |  | 
| Colin Cross | e87040b | 2017-12-11 15:52:26 -0800 | [diff] [blame] | 329 | func (c *config) StopBefore() bootstrap.StopBefore { | 
|  | 330 | return c.stopBefore | 
| Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 331 | } | 
|  | 332 |  | 
| Colin Cross | e87040b | 2017-12-11 15:52:26 -0800 | [diff] [blame] | 333 | func (c *config) SetStopBefore(stopBefore bootstrap.StopBefore) { | 
|  | 334 | c.stopBefore = stopBefore | 
|  | 335 | } | 
|  | 336 |  | 
|  | 337 | var _ bootstrap.ConfigStopBefore = (*config)(nil) | 
|  | 338 |  | 
| Dan Willemsen | c2aa4a9 | 2016-05-26 15:13:03 -0700 | [diff] [blame] | 339 | func (c *config) BlueprintToolLocation() string { | 
|  | 340 | return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin") | 
|  | 341 | } | 
|  | 342 |  | 
| Colin Cross | e87040b | 2017-12-11 15:52:26 -0800 | [diff] [blame] | 343 | var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil) | 
|  | 344 |  | 
| Dan Willemsen | 6606872 | 2017-05-08 21:15:59 +0000 | [diff] [blame] | 345 | // HostSystemTool looks for non-hermetic tools from the system we're running on. | 
|  | 346 | // Generally shouldn't be used, but useful to find the XCode SDK, etc. | 
|  | 347 | func (c *config) HostSystemTool(name string) string { | 
|  | 348 | for _, dir := range filepath.SplitList(c.Getenv("PATH")) { | 
|  | 349 | path := filepath.Join(dir, name) | 
|  | 350 | if s, err := os.Stat(path); err != nil { | 
|  | 351 | continue | 
|  | 352 | } else if m := s.Mode(); !s.IsDir() && m&0111 != 0 { | 
|  | 353 | return path | 
|  | 354 | } | 
|  | 355 | } | 
|  | 356 | return name | 
|  | 357 | } | 
|  | 358 |  | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 359 | // PrebuiltOS returns the name of the host OS used in prebuilts directories | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 360 | func (c *config) PrebuiltOS() string { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 361 | switch runtime.GOOS { | 
|  | 362 | case "linux": | 
|  | 363 | return "linux-x86" | 
|  | 364 | case "darwin": | 
|  | 365 | return "darwin-x86" | 
|  | 366 | default: | 
|  | 367 | panic("Unknown GOOS") | 
|  | 368 | } | 
|  | 369 | } | 
|  | 370 |  | 
|  | 371 | // GoRoot returns the path to the root directory of the Go toolchain. | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 372 | func (c *config) GoRoot() string { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 373 | return fmt.Sprintf("%s/prebuilts/go/%s", c.srcDir, c.PrebuiltOS()) | 
|  | 374 | } | 
|  | 375 |  | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 376 | func (c *config) CpPreserveSymlinksFlags() string { | 
| Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 377 | switch runtime.GOOS { | 
| Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 378 | case "darwin": | 
|  | 379 | return "-R" | 
|  | 380 | case "linux": | 
|  | 381 | return "-d" | 
|  | 382 | default: | 
|  | 383 | return "" | 
|  | 384 | } | 
|  | 385 | } | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 386 |  | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 387 | func (c *config) Getenv(key string) string { | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 388 | var val string | 
|  | 389 | var exists bool | 
| Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 390 | c.envLock.Lock() | 
| Colin Cross | c0d58b4 | 2017-02-06 15:40:41 -0800 | [diff] [blame] | 391 | defer c.envLock.Unlock() | 
|  | 392 | if c.envDeps == nil { | 
|  | 393 | c.envDeps = make(map[string]string) | 
|  | 394 | } | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 395 | if val, exists = c.envDeps[key]; !exists { | 
| Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 396 | if c.envFrozen { | 
|  | 397 | panic("Cannot access new environment variables after envdeps are frozen") | 
|  | 398 | } | 
| Colin Cross | 6ccbc91 | 2017-10-10 23:07:38 -0700 | [diff] [blame] | 399 | val, _ = c.env[key] | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 400 | c.envDeps[key] = val | 
|  | 401 | } | 
|  | 402 | return val | 
|  | 403 | } | 
|  | 404 |  | 
| Colin Cross | 99d7c23 | 2016-11-23 16:52:04 -0800 | [diff] [blame] | 405 | func (c *config) GetenvWithDefault(key string, defaultValue string) string { | 
|  | 406 | ret := c.Getenv(key) | 
|  | 407 | if ret == "" { | 
|  | 408 | return defaultValue | 
|  | 409 | } | 
|  | 410 | return ret | 
|  | 411 | } | 
|  | 412 |  | 
|  | 413 | func (c *config) IsEnvTrue(key string) bool { | 
|  | 414 | value := c.Getenv(key) | 
|  | 415 | return value == "1" || value == "y" || value == "yes" || value == "on" || value == "true" | 
|  | 416 | } | 
|  | 417 |  | 
|  | 418 | func (c *config) IsEnvFalse(key string) bool { | 
|  | 419 | value := c.Getenv(key) | 
|  | 420 | return value == "0" || value == "n" || value == "no" || value == "off" || value == "false" | 
|  | 421 | } | 
|  | 422 |  | 
| Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 423 | func (c *config) EnvDeps() map[string]string { | 
| Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 424 | c.envLock.Lock() | 
| Colin Cross | c0d58b4 | 2017-02-06 15:40:41 -0800 | [diff] [blame] | 425 | defer c.envLock.Unlock() | 
| Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 426 | c.envFrozen = true | 
| Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 427 | return c.envDeps | 
|  | 428 | } | 
| Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 429 |  | 
| Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 430 | func (c *config) EmbeddedInMake() bool { | 
|  | 431 | return c.inMake | 
|  | 432 | } | 
|  | 433 |  | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 434 | func (c *config) BuildId() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 435 | return String(c.productVariables.BuildId) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 436 | } | 
|  | 437 |  | 
|  | 438 | func (c *config) BuildNumberFromFile() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 439 | return String(c.productVariables.BuildNumberFromFile) | 
| Nan Zhang | 581fd21 | 2018-01-10 16:06:12 -0800 | [diff] [blame] | 440 | } | 
|  | 441 |  | 
| Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 442 | // DeviceName returns the name of the current device target | 
|  | 443 | // 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] | 444 | func (c *config) DeviceName() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 445 | return *c.productVariables.DeviceName | 
| Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 446 | } | 
|  | 447 |  | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 448 | func (c *config) ResourceOverlays() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 449 | if c.productVariables.ResourceOverlays == nil { | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 450 | return nil | 
|  | 451 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 452 | return *c.productVariables.ResourceOverlays | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 453 | } | 
|  | 454 |  | 
| Dan Albert | 073379e | 2016-11-10 10:46:36 -0800 | [diff] [blame] | 455 | func (c *config) PlatformSdkVersionInt() int { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 456 | return *c.productVariables.Platform_sdk_version | 
| Dan Albert | 073379e | 2016-11-10 10:46:36 -0800 | [diff] [blame] | 457 | } | 
|  | 458 |  | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 459 | func (c *config) PlatformSdkVersion() string { | 
| Dan Albert | 073379e | 2016-11-10 10:46:36 -0800 | [diff] [blame] | 460 | return strconv.Itoa(c.PlatformSdkVersionInt()) | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 461 | } | 
|  | 462 |  | 
| Dan Albert | f5415d7 | 2017-08-17 16:19:59 -0700 | [diff] [blame] | 463 | func (c *config) MinSupportedSdkVersion() int { | 
| Dan Albert | d4db4ac | 2017-08-10 12:18:31 -0700 | [diff] [blame] | 464 | return 14 | 
| Dan Albert | f5415d7 | 2017-08-17 16:19:59 -0700 | [diff] [blame] | 465 | } | 
|  | 466 |  | 
| Colin Cross | 595a406 | 2017-08-31 12:30:37 -0700 | [diff] [blame] | 467 | func (c *config) DefaultAppTargetSdkInt() int { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 468 | if Bool(c.productVariables.Platform_sdk_final) { | 
| Colin Cross | 595a406 | 2017-08-31 12:30:37 -0700 | [diff] [blame] | 469 | return c.PlatformSdkVersionInt() | 
|  | 470 | } else { | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 471 | return FutureApiLevel | 
| Colin Cross | 595a406 | 2017-08-31 12:30:37 -0700 | [diff] [blame] | 472 | } | 
|  | 473 | } | 
|  | 474 |  | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 475 | func (c *config) AppsDefaultVersionName() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 476 | return String(c.productVariables.AppsDefaultVersionName) | 
| Colin Cross | 3bc7ffa | 2017-11-22 16:19:37 -0800 | [diff] [blame] | 477 | } | 
|  | 478 |  | 
| Dan Albert | 31384de | 2017-07-28 12:39:46 -0700 | [diff] [blame] | 479 | // Codenames that are active in the current lunch target. | 
|  | 480 | func (c *config) PlatformVersionActiveCodenames() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 481 | return c.productVariables.Platform_version_active_codenames | 
| Dan Albert | 31384de | 2017-07-28 12:39:46 -0700 | [diff] [blame] | 482 | } | 
|  | 483 |  | 
|  | 484 | // Codenames that are available in the branch but not included in the current | 
|  | 485 | // lunch target. | 
|  | 486 | func (c *config) PlatformVersionFutureCodenames() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 487 | return c.productVariables.Platform_version_future_codenames | 
| Dan Albert | 31384de | 2017-07-28 12:39:46 -0700 | [diff] [blame] | 488 | } | 
|  | 489 |  | 
|  | 490 | // All possible codenames in the current branch. NB: Not named AllCodenames | 
|  | 491 | // because "all" has historically meant "active" in make, and still does in | 
|  | 492 | // build.prop. | 
|  | 493 | func (c *config) PlatformVersionCombinedCodenames() []string { | 
|  | 494 | combined := []string{} | 
|  | 495 | combined = append(combined, c.PlatformVersionActiveCodenames()...) | 
|  | 496 | combined = append(combined, c.PlatformVersionFutureCodenames()...) | 
|  | 497 | return combined | 
| Dan Albert | 30c9d6e | 2017-03-28 14:54:55 -0700 | [diff] [blame] | 498 | } | 
|  | 499 |  | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 500 | func (c *config) ProductAAPTConfig() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 501 | return stringSlice(c.productVariables.AAPTConfig) | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 502 | } | 
|  | 503 |  | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 504 | func (c *config) ProductAAPTPreferredConfig() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 505 | return String(c.productVariables.AAPTPreferredConfig) | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 506 | } | 
|  | 507 |  | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 508 | func (c *config) ProductAAPTCharacteristics() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 509 | return String(c.productVariables.AAPTCharacteristics) | 
| Colin Cross | face4e4 | 2017-10-30 17:32:15 -0700 | [diff] [blame] | 510 | } | 
|  | 511 |  | 
|  | 512 | func (c *config) ProductAAPTPrebuiltDPI() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 513 | return stringSlice(c.productVariables.AAPTPrebuiltDPI) | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 514 | } | 
|  | 515 |  | 
| Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 516 | func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 517 | defaultCert := String(c.productVariables.DefaultAppCertificate) | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 518 | if defaultCert != "" { | 
|  | 519 | return PathForSource(ctx, filepath.Dir(defaultCert)) | 
|  | 520 | } else { | 
|  | 521 | return PathForSource(ctx, "build/target/product/security") | 
|  | 522 | } | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 523 | } | 
|  | 524 |  | 
| Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 525 | func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 526 | defaultCert := String(c.productVariables.DefaultAppCertificate) | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 527 | if defaultCert != "" { | 
| Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 528 | return PathForSource(ctx, defaultCert+".x509.pem"), PathForSource(ctx, defaultCert+".pk8") | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 529 | } else { | 
| Colin Cross | e1731a5 | 2017-12-14 11:22:55 -0800 | [diff] [blame] | 530 | defaultDir := c.DefaultAppCertificateDir(ctx) | 
|  | 531 | return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8") | 
| Colin Cross | 61ae0b7 | 2017-12-01 17:16:02 -0800 | [diff] [blame] | 532 | } | 
| Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 533 | } | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 534 |  | 
|  | 535 | func (c *config) AllowMissingDependencies() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 536 | return Bool(c.productVariables.Allow_missing_dependencies) | 
| Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 537 | } | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 538 |  | 
| Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 539 | func (c *config) UnbundledBuild() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 540 | return Bool(c.productVariables.Unbundled_build) | 
| Colin Cross | fc3674a | 2017-09-18 17:41:52 -0700 | [diff] [blame] | 541 | } | 
|  | 542 |  | 
| Colin Cross | 0d3f8c0 | 2017-10-24 10:51:45 -0700 | [diff] [blame] | 543 | func (c *config) IsPdkBuild() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 544 | return Bool(c.productVariables.Pdk) | 
| Colin Cross | 0d3f8c0 | 2017-10-24 10:51:45 -0700 | [diff] [blame] | 545 | } | 
|  | 546 |  | 
| Colin Cross | 126a25c | 2017-10-31 13:55:34 -0700 | [diff] [blame] | 547 | func (c *config) MinimizeJavaDebugInfo() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 548 | return Bool(c.productVariables.MinimizeJavaDebugInfo) && !Bool(c.productVariables.Eng) | 
| Colin Cross | 126a25c | 2017-10-31 13:55:34 -0700 | [diff] [blame] | 549 | } | 
|  | 550 |  | 
| Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 551 | func (c *config) DevicePrefer32BitExecutables() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 552 | return Bool(c.productVariables.DevicePrefer32BitExecutables) | 
| Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 553 | } | 
|  | 554 |  | 
| Dan Willemsen | 7f730fd | 2016-01-14 11:22:23 -0800 | [diff] [blame] | 555 | func (c *config) SkipDeviceInstall() bool { | 
| Colin Cross | 893d816 | 2017-04-26 17:34:03 -0700 | [diff] [blame] | 556 | return c.EmbeddedInMake() | 
|  | 557 | } | 
|  | 558 |  | 
|  | 559 | func (c *config) SkipMegaDeviceInstall(path string) bool { | 
|  | 560 | return Bool(c.Mega_device) && | 
|  | 561 | strings.HasPrefix(path, filepath.Join(c.buildDir, "target", "product")) | 
| Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 562 | } | 
| Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 563 |  | 
|  | 564 | func (c *config) SanitizeHost() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 565 | return append([]string(nil), c.productVariables.SanitizeHost...) | 
| Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 566 | } | 
|  | 567 |  | 
|  | 568 | func (c *config) SanitizeDevice() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 569 | return append([]string(nil), c.productVariables.SanitizeDevice...) | 
| Colin Cross | 23ae82a | 2016-11-02 14:34:39 -0700 | [diff] [blame] | 570 | } | 
|  | 571 |  | 
| Ivan Lozano | 0c3a1ef | 2017-06-28 09:10:48 -0700 | [diff] [blame] | 572 | func (c *config) SanitizeDeviceDiag() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 573 | return append([]string(nil), c.productVariables.SanitizeDeviceDiag...) | 
| Ivan Lozano | 0c3a1ef | 2017-06-28 09:10:48 -0700 | [diff] [blame] | 574 | } | 
|  | 575 |  | 
| Colin Cross | 23ae82a | 2016-11-02 14:34:39 -0700 | [diff] [blame] | 576 | func (c *config) SanitizeDeviceArch() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 577 | return append([]string(nil), c.productVariables.SanitizeDeviceArch...) | 
| Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 578 | } | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 579 |  | 
| Vishwath Mohan | 1b017a7 | 2017-01-19 13:54:55 -0800 | [diff] [blame] | 580 | func (c *config) EnableCFI() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 581 | if c.productVariables.EnableCFI == nil { | 
| Vishwath Mohan | c32c3eb | 2017-01-24 14:20:54 -0800 | [diff] [blame] | 582 | return true | 
|  | 583 | } else { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 584 | return *c.productVariables.EnableCFI | 
| Vishwath Mohan | c32c3eb | 2017-01-24 14:20:54 -0800 | [diff] [blame] | 585 | } | 
| Vishwath Mohan | 1b017a7 | 2017-01-19 13:54:55 -0800 | [diff] [blame] | 586 | } | 
|  | 587 |  | 
| Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 588 | func (c *config) Android64() bool { | 
|  | 589 | for _, t := range c.Targets[Device] { | 
|  | 590 | if t.Arch.ArchType.Multilib == "lib64" { | 
|  | 591 | return true | 
|  | 592 | } | 
|  | 593 | } | 
|  | 594 |  | 
|  | 595 | return false | 
|  | 596 | } | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 597 |  | 
| Alan Leung | c37c634 | 2017-12-13 00:28:49 -0800 | [diff] [blame] | 598 | func (c *config) UseD8Desugar() bool { | 
| Alan Leung | e2fb629 | 2017-12-20 01:15:56 -0800 | [diff] [blame] | 599 | return !c.IsEnvFalse("USE_D8_DESUGAR") | 
| Alan Leung | c37c634 | 2017-12-13 00:28:49 -0800 | [diff] [blame] | 600 | } | 
|  | 601 |  | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 602 | func (c *config) UseGoma() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 603 | return Bool(c.productVariables.UseGoma) | 
| Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 604 | } | 
|  | 605 |  | 
| Colin Cross | 1369cdb | 2017-09-29 17:58:17 -0700 | [diff] [blame] | 606 | // Returns true if OpenJDK9 prebuilts are being used | 
|  | 607 | func (c *config) UseOpenJDK9() bool { | 
|  | 608 | return c.useOpenJDK9 | 
|  | 609 | } | 
|  | 610 |  | 
|  | 611 | // Returns true if -source 1.9 -target 1.9 is being passed to javac | 
|  | 612 | func (c *config) TargetOpenJDK9() bool { | 
|  | 613 | return c.targetOpenJDK9 | 
|  | 614 | } | 
|  | 615 |  | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 616 | func (c *config) ClangTidy() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 617 | return Bool(c.productVariables.ClangTidy) | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 618 | } | 
|  | 619 |  | 
|  | 620 | func (c *config) TidyChecks() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 621 | if c.productVariables.TidyChecks == nil { | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 622 | return "" | 
|  | 623 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 624 | return *c.productVariables.TidyChecks | 
| Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 625 | } | 
|  | 626 |  | 
| Colin Cross | 0f4e0d6 | 2016-07-27 10:56:55 -0700 | [diff] [blame] | 627 | func (c *config) LibartImgHostBaseAddress() string { | 
|  | 628 | return "0x60000000" | 
|  | 629 | } | 
|  | 630 |  | 
|  | 631 | func (c *config) LibartImgDeviceBaseAddress() string { | 
| Colin Cross | 20e1365 | 2017-06-22 15:34:51 -0700 | [diff] [blame] | 632 | archType := Common | 
|  | 633 | if len(c.Targets[Device]) > 0 { | 
|  | 634 | archType = c.Targets[Device][0].Arch.ArchType | 
|  | 635 | } | 
|  | 636 | switch archType { | 
| Colin Cross | 0f4e0d6 | 2016-07-27 10:56:55 -0700 | [diff] [blame] | 637 | default: | 
|  | 638 | return "0x70000000" | 
|  | 639 | case Mips, Mips64: | 
| Chris Larsen | ae7f3e2 | 2017-05-30 16:36:58 -0700 | [diff] [blame] | 640 | return "0x5C000000" | 
| Colin Cross | 0f4e0d6 | 2016-07-27 10:56:55 -0700 | [diff] [blame] | 641 | } | 
|  | 642 | } | 
|  | 643 |  | 
| Hiroshi Yamauchi | e2a1063 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 644 | func (c *config) ArtUseReadBarrier() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 645 | return Bool(c.productVariables.ArtUseReadBarrier) | 
| Hiroshi Yamauchi | e2a1063 | 2016-12-19 13:44:41 -0800 | [diff] [blame] | 646 | } | 
|  | 647 |  | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 648 | func (c *config) EnforceRROForModule(name string) bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 649 | enforceList := c.productVariables.EnforceRROTargets | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 650 | if enforceList != nil { | 
|  | 651 | if len(*enforceList) == 1 && (*enforceList)[0] == "*" { | 
|  | 652 | return true | 
|  | 653 | } | 
|  | 654 | return InList(name, *enforceList) | 
|  | 655 | } | 
|  | 656 | return false | 
|  | 657 | } | 
|  | 658 |  | 
|  | 659 | func (c *config) EnforceRROExcludedOverlay(path string) bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 660 | excluded := c.productVariables.EnforceRROExcludedOverlays | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 661 | if excluded != nil { | 
|  | 662 | for _, exclude := range *excluded { | 
|  | 663 | if strings.HasPrefix(path, exclude) { | 
|  | 664 | return true | 
|  | 665 | } | 
|  | 666 | } | 
|  | 667 | } | 
|  | 668 | return false | 
|  | 669 | } | 
|  | 670 |  | 
|  | 671 | func (c *config) ExportedNamespaces() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 672 | return append([]string(nil), c.productVariables.NamespacesToExport...) | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 673 | } | 
|  | 674 |  | 
|  | 675 | func (c *config) HostStaticBinaries() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 676 | return Bool(c.productVariables.HostStaticBinaries) | 
| Dan Willemsen | 3fb1fae | 2018-03-12 15:30:26 -0700 | [diff] [blame] | 677 | } | 
|  | 678 |  | 
| Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 679 | func (c *deviceConfig) Arches() []Arch { | 
|  | 680 | var arches []Arch | 
|  | 681 | for _, target := range c.config.Targets[Device] { | 
|  | 682 | arches = append(arches, target.Arch) | 
|  | 683 | } | 
|  | 684 | return arches | 
|  | 685 | } | 
| Dan Willemsen | d2ede87 | 2016-11-18 14:54:24 -0800 | [diff] [blame] | 686 |  | 
| Jayant Chowdhary | 34ce67d | 2018-03-08 11:00:50 -0800 | [diff] [blame] | 687 | func (c *deviceConfig) BinderBitness() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 688 | is32BitBinder := c.config.productVariables.Binder32bit | 
| Jayant Chowdhary | 34ce67d | 2018-03-08 11:00:50 -0800 | [diff] [blame] | 689 | if is32BitBinder != nil && *is32BitBinder { | 
|  | 690 | return "32" | 
|  | 691 | } | 
|  | 692 | return "64" | 
|  | 693 | } | 
|  | 694 |  | 
| Dan Willemsen | 4353bc4 | 2016-12-05 17:16:02 -0800 | [diff] [blame] | 695 | func (c *deviceConfig) VendorPath() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 696 | if c.config.productVariables.VendorPath != nil { | 
|  | 697 | return *c.config.productVariables.VendorPath | 
| Dan Willemsen | 4353bc4 | 2016-12-05 17:16:02 -0800 | [diff] [blame] | 698 | } | 
|  | 699 | return "vendor" | 
|  | 700 | } | 
|  | 701 |  | 
| Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 702 | func (c *deviceConfig) VndkVersion() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 703 | return String(c.config.productVariables.DeviceVndkVersion) | 
| Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 704 | } | 
|  | 705 |  | 
| Justin Yun | 8fe1212 | 2017-12-07 17:18:15 +0900 | [diff] [blame] | 706 | func (c *deviceConfig) PlatformVndkVersion() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 707 | return String(c.config.productVariables.Platform_vndk_version) | 
| Justin Yun | 8fe1212 | 2017-12-07 17:18:15 +0900 | [diff] [blame] | 708 | } | 
|  | 709 |  | 
| Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 710 | func (c *deviceConfig) ExtraVndkVersions() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 711 | return c.config.productVariables.ExtraVndkVersions | 
| Dan Willemsen | d2ede87 | 2016-11-18 14:54:24 -0800 | [diff] [blame] | 712 | } | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 713 |  | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 714 | func (c *deviceConfig) SystemSdkVersions() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 715 | if c.config.productVariables.DeviceSystemSdkVersions == nil { | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 716 | return nil | 
|  | 717 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 718 | return *c.config.productVariables.DeviceSystemSdkVersions | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 719 | } | 
|  | 720 |  | 
|  | 721 | func (c *deviceConfig) PlatformSystemSdkVersions() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 722 | return c.config.productVariables.Platform_systemsdk_versions | 
| Jiyong Park | 1a5d7b1 | 2018-01-15 15:05:10 +0900 | [diff] [blame] | 723 | } | 
|  | 724 |  | 
| Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 725 | func (c *deviceConfig) OdmPath() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 726 | if c.config.productVariables.OdmPath != nil { | 
|  | 727 | return *c.config.productVariables.OdmPath | 
| Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 728 | } | 
|  | 729 | return "odm" | 
|  | 730 | } | 
|  | 731 |  | 
| Jaekyun Seok | 5cfbfbb | 2018-01-10 19:00:15 +0900 | [diff] [blame] | 732 | func (c *deviceConfig) ProductPath() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 733 | if c.config.productVariables.ProductPath != nil { | 
|  | 734 | return *c.config.productVariables.ProductPath | 
| Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 735 | } | 
| Jaekyun Seok | 5cfbfbb | 2018-01-10 19:00:15 +0900 | [diff] [blame] | 736 | return "product" | 
| Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 737 | } | 
|  | 738 |  | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 739 | func (c *deviceConfig) BtConfigIncludeDir() string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 740 | return String(c.config.productVariables.BtConfigIncludeDir) | 
| Jack He | 8cc7143 | 2016-12-08 15:45:07 -0800 | [diff] [blame] | 741 | } | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 742 |  | 
| Jiyong Park | d773eb3 | 2017-07-03 13:18:12 +0900 | [diff] [blame] | 743 | func (c *deviceConfig) DeviceKernelHeaderDirs() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 744 | return c.config.productVariables.DeviceKernelHeaders | 
| Jiyong Park | d773eb3 | 2017-07-03 13:18:12 +0900 | [diff] [blame] | 745 | } | 
|  | 746 |  | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 747 | func (c *deviceConfig) NativeCoverageEnabled() bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 748 | return Bool(c.config.productVariables.NativeCoverage) | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 749 | } | 
|  | 750 |  | 
|  | 751 | func (c *deviceConfig) CoverageEnabledForPath(path string) bool { | 
| Ryan Campbell | 469a18a | 2017-02-27 09:01:54 -0800 | [diff] [blame] | 752 | coverage := false | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 753 | if c.config.productVariables.CoveragePaths != nil { | 
|  | 754 | if PrefixInList(path, *c.config.productVariables.CoveragePaths) { | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 755 | coverage = true | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 756 | } | 
|  | 757 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 758 | if coverage && c.config.productVariables.CoverageExcludePaths != nil { | 
|  | 759 | if PrefixInList(path, *c.config.productVariables.CoverageExcludePaths) { | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 760 | coverage = false | 
| Ryan Campbell | 469a18a | 2017-02-27 09:01:54 -0800 | [diff] [blame] | 761 | } | 
|  | 762 | } | 
|  | 763 | return coverage | 
| Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 764 | } | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 765 |  | 
| Pirama Arumuga Nainar | 4954080 | 2018-01-29 23:11:42 -0800 | [diff] [blame] | 766 | func (c *deviceConfig) PgoAdditionalProfileDirs() []string { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 767 | return c.config.productVariables.PgoAdditionalProfileDirs | 
| Pirama Arumuga Nainar | 4954080 | 2018-01-29 23:11:42 -0800 | [diff] [blame] | 768 | } | 
|  | 769 |  | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 770 | func (c *config) IntegerOverflowDisabledForPath(path string) bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 771 | if c.productVariables.IntegerOverflowExcludePaths == nil { | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 772 | return false | 
|  | 773 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 774 | return PrefixInList(path, *c.productVariables.IntegerOverflowExcludePaths) | 
| Ivan Lozano | 5f59553 | 2017-07-13 14:46:05 -0700 | [diff] [blame] | 775 | } | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 776 |  | 
|  | 777 | func (c *config) CFIDisabledForPath(path string) bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 778 | if c.productVariables.CFIExcludePaths == nil { | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 779 | return false | 
|  | 780 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 781 | return PrefixInList(path, *c.productVariables.CFIExcludePaths) | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 782 | } | 
|  | 783 |  | 
|  | 784 | func (c *config) CFIEnabledForPath(path string) bool { | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 785 | if c.productVariables.CFIIncludePaths == nil { | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 786 | return false | 
|  | 787 | } | 
| Dan Willemsen | 45133ac | 2018-03-09 21:22:06 -0800 | [diff] [blame^] | 788 | return PrefixInList(path, *c.productVariables.CFIIncludePaths) | 
| Vishwath Mohan | 1fa3ac5 | 2017-10-31 02:26:14 -0700 | [diff] [blame] | 789 | } | 
| Colin Cross | e15ddaf | 2017-12-04 11:24:31 -0800 | [diff] [blame] | 790 |  | 
|  | 791 | func stringSlice(s *[]string) []string { | 
|  | 792 | if s != nil { | 
|  | 793 | return *s | 
|  | 794 | } else { | 
|  | 795 | return nil | 
|  | 796 | } | 
|  | 797 | } |