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" |
| 20 | "os" |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 21 | "path/filepath" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 22 | "runtime" |
Dan Willemsen | 5951c8a | 2016-07-19 19:08:14 -0700 | [diff] [blame] | 23 | "strconv" |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 24 | "strings" |
Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 25 | "sync" |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 26 | |
| 27 | "github.com/google/blueprint/proptools" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 28 | ) |
| 29 | |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 30 | var Bool = proptools.Bool |
| 31 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 32 | // The configuration file name |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 33 | const configFileName = "soong.config" |
| 34 | const productVariablesFileName = "soong.variables" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 35 | |
| 36 | // A FileConfigurableOptions contains options which can be configured by the |
| 37 | // config file. These will be included in the config struct. |
| 38 | type FileConfigurableOptions struct { |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 39 | Mega_device *bool `json:",omitempty"` |
Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame^] | 40 | Ndk_abis *bool `json:",omitempty"` |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 41 | } |
| 42 | |
Colin Cross | 2738597 | 2015-09-18 10:57:10 -0700 | [diff] [blame] | 43 | func (f *FileConfigurableOptions) SetDefaultConfig() { |
| 44 | *f = FileConfigurableOptions{} |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 45 | } |
| 46 | |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 47 | // A Config object represents the entire build configuration for Android. |
Colin Cross | c3c0a49 | 2015-04-10 15:43:55 -0700 | [diff] [blame] | 48 | type Config struct { |
| 49 | *config |
| 50 | } |
| 51 | |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 52 | // A DeviceConfig object represents the configuration for a particular device being built. For |
| 53 | // now there will only be one of these, but in the future there may be multiple devices being |
| 54 | // built |
| 55 | type DeviceConfig struct { |
| 56 | *deviceConfig |
| 57 | } |
| 58 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 59 | type config struct { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 60 | FileConfigurableOptions |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 61 | ProductVariables productVariables |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 62 | |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 63 | ConfigFileName string |
| 64 | ProductVariablesFileName string |
| 65 | |
Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 66 | Targets map[OsClass][]Target |
| 67 | BuildOsVariant string |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 68 | |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 69 | deviceConfig *deviceConfig |
| 70 | |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 71 | srcDir string // the path of the root source directory |
| 72 | buildDir string // the path of the build output directory |
Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 73 | |
Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 74 | envLock sync.Mutex |
| 75 | envDeps map[string]string |
| 76 | envFrozen bool |
Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 77 | |
| 78 | inMake bool |
Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 79 | |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 80 | OncePer |
| 81 | } |
| 82 | |
| 83 | type deviceConfig struct { |
| 84 | config *config |
| 85 | targets []Arch |
| 86 | OncePer |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 89 | type jsonConfigurable interface { |
Colin Cross | 2738597 | 2015-09-18 10:57:10 -0700 | [diff] [blame] | 90 | SetDefaultConfig() |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 91 | } |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 92 | |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 93 | func loadConfig(config *config) error { |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 94 | err := loadFromConfigFile(&config.FileConfigurableOptions, config.ConfigFileName) |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 95 | if err != nil { |
| 96 | return err |
| 97 | } |
| 98 | |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 99 | return loadFromConfigFile(&config.ProductVariables, config.ProductVariablesFileName) |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | // loads configuration options from a JSON file in the cwd. |
| 103 | func loadFromConfigFile(configurable jsonConfigurable, filename string) error { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 104 | // Try to open the file |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 105 | configFileReader, err := os.Open(filename) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 106 | defer configFileReader.Close() |
| 107 | if os.IsNotExist(err) { |
| 108 | // Need to create a file, so that blueprint & ninja don't get in |
| 109 | // a dependency tracking loop. |
| 110 | // Make a file-configurable-options with defaults, write it out using |
| 111 | // a json writer. |
Colin Cross | 2738597 | 2015-09-18 10:57:10 -0700 | [diff] [blame] | 112 | configurable.SetDefaultConfig() |
| 113 | err = saveToConfigFile(configurable, filename) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 114 | if err != nil { |
| 115 | return err |
| 116 | } |
| 117 | } else { |
| 118 | // Make a decoder for it |
| 119 | jsonDecoder := json.NewDecoder(configFileReader) |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 120 | err = jsonDecoder.Decode(configurable) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 121 | if err != nil { |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 122 | return fmt.Errorf("config file: %s did not parse correctly: "+err.Error(), filename) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 126 | // No error |
| 127 | return nil |
| 128 | } |
| 129 | |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 130 | func saveToConfigFile(config jsonConfigurable, filename string) error { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 131 | data, err := json.MarshalIndent(&config, "", " ") |
| 132 | if err != nil { |
| 133 | return fmt.Errorf("cannot marshal config data: %s", err.Error()) |
| 134 | } |
| 135 | |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 136 | configFileWriter, err := os.Create(filename) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 137 | if err != nil { |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 138 | 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] | 139 | } |
| 140 | defer configFileWriter.Close() |
| 141 | |
| 142 | _, err = configFileWriter.Write(data) |
| 143 | if err != nil { |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 144 | return fmt.Errorf("default config file: %s could not be written: %s", filename, err.Error()) |
| 145 | } |
| 146 | |
| 147 | _, err = configFileWriter.WriteString("\n") |
| 148 | if err != nil { |
| 149 | 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] | 150 | } |
| 151 | |
| 152 | return nil |
| 153 | } |
| 154 | |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 155 | // TestConfig returns a Config object suitable for using for tests |
Colin Cross | 0d614dd | 2016-10-14 15:38:43 -0700 | [diff] [blame] | 156 | func TestConfig(buildDir string) Config { |
| 157 | return Config{&config{ |
| 158 | buildDir: buildDir, |
| 159 | }} |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 162 | // New creates a new Config object. The srcDir argument specifies the path to |
| 163 | // the root source directory. It also loads the config file, if found. |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 164 | func NewConfig(srcDir, buildDir string) (Config, error) { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 165 | // Make a config with default options |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 166 | config := &config{ |
| 167 | ConfigFileName: filepath.Join(buildDir, configFileName), |
| 168 | ProductVariablesFileName: filepath.Join(buildDir, productVariablesFileName), |
Dan Willemsen | 87b17d1 | 2015-07-14 00:39:06 -0700 | [diff] [blame] | 169 | |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 170 | srcDir: srcDir, |
| 171 | buildDir: buildDir, |
| 172 | envDeps: make(map[string]string), |
| 173 | |
| 174 | deviceConfig: &deviceConfig{}, |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 175 | } |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 176 | |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 177 | deviceConfig := &deviceConfig{ |
| 178 | config: config, |
| 179 | } |
| 180 | |
| 181 | config.deviceConfig = deviceConfig |
| 182 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 183 | // Sanity check the build and source directories. This won't catch strange |
| 184 | // configurations with symlinks, but at least checks the obvious cases. |
| 185 | absBuildDir, err := filepath.Abs(buildDir) |
| 186 | if err != nil { |
| 187 | return Config{}, err |
| 188 | } |
| 189 | |
| 190 | absSrcDir, err := filepath.Abs(srcDir) |
| 191 | if err != nil { |
| 192 | return Config{}, err |
| 193 | } |
| 194 | |
| 195 | if strings.HasPrefix(absSrcDir, absBuildDir) { |
| 196 | return Config{}, fmt.Errorf("Build dir must not contain source directory") |
| 197 | } |
| 198 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 199 | // Load any configurable options from the configuration file |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 200 | err = loadConfig(config) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 201 | if err != nil { |
Colin Cross | c3c0a49 | 2015-04-10 15:43:55 -0700 | [diff] [blame] | 202 | return Config{}, err |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 203 | } |
| 204 | |
Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 205 | inMakeFile := filepath.Join(buildDir, ".soong.in_make") |
| 206 | if _, err := os.Stat(inMakeFile); err == nil { |
| 207 | config.inMake = true |
| 208 | } |
| 209 | |
Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 210 | targets, err := decodeTargetProductVariables(config) |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 211 | if err != nil { |
| 212 | return Config{}, err |
| 213 | } |
| 214 | |
Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame^] | 215 | var archConfig []archConfig |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 216 | if Bool(config.Mega_device) { |
Dan Albert | 4098deb | 2016-10-19 14:04:41 -0700 | [diff] [blame^] | 217 | archConfig = getMegaDeviceConfig() |
| 218 | } else if Bool(config.Ndk_abis) { |
| 219 | archConfig = getNdkAbisConfig() |
| 220 | } |
| 221 | |
| 222 | if archConfig != nil { |
| 223 | deviceTargets, err := decodeArchSettings(archConfig) |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 224 | if err != nil { |
| 225 | return Config{}, err |
| 226 | } |
Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 227 | targets[Device] = deviceTargets |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 228 | } |
| 229 | |
Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 230 | config.Targets = targets |
| 231 | config.BuildOsVariant = targets[Host][0].String() |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 232 | |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 233 | return Config{config}, nil |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 234 | } |
| 235 | |
Dan Willemsen | 218f656 | 2015-07-08 18:13:11 -0700 | [diff] [blame] | 236 | func (c *config) RemoveAbandonedFiles() bool { |
| 237 | return false |
| 238 | } |
| 239 | |
Dan Willemsen | c2aa4a9 | 2016-05-26 15:13:03 -0700 | [diff] [blame] | 240 | func (c *config) BlueprintToolLocation() string { |
| 241 | return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin") |
| 242 | } |
| 243 | |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 244 | // PrebuiltOS returns the name of the host OS used in prebuilts directories |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 245 | func (c *config) PrebuiltOS() string { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 246 | switch runtime.GOOS { |
| 247 | case "linux": |
| 248 | return "linux-x86" |
| 249 | case "darwin": |
| 250 | return "darwin-x86" |
| 251 | default: |
| 252 | panic("Unknown GOOS") |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | // GoRoot returns the path to the root directory of the Go toolchain. |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 257 | func (c *config) GoRoot() string { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 258 | return fmt.Sprintf("%s/prebuilts/go/%s", c.srcDir, c.PrebuiltOS()) |
| 259 | } |
| 260 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 261 | func (c *config) CpPreserveSymlinksFlags() string { |
Colin Cross | 485e572 | 2015-08-27 13:28:01 -0700 | [diff] [blame] | 262 | switch runtime.GOOS { |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 263 | case "darwin": |
| 264 | return "-R" |
| 265 | case "linux": |
| 266 | return "-d" |
| 267 | default: |
| 268 | return "" |
| 269 | } |
| 270 | } |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 271 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 272 | func (c *config) Getenv(key string) string { |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 273 | var val string |
| 274 | var exists bool |
Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 275 | c.envLock.Lock() |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 276 | if val, exists = c.envDeps[key]; !exists { |
Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 277 | if c.envFrozen { |
| 278 | panic("Cannot access new environment variables after envdeps are frozen") |
| 279 | } |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 280 | val = os.Getenv(key) |
| 281 | c.envDeps[key] = val |
| 282 | } |
Colin Cross | c1e86a3 | 2015-04-15 12:33:28 -0700 | [diff] [blame] | 283 | c.envLock.Unlock() |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 284 | return val |
| 285 | } |
| 286 | |
Colin Cross | 1332b00 | 2015-04-07 17:11:30 -0700 | [diff] [blame] | 287 | func (c *config) EnvDeps() map[string]string { |
Dan Willemsen | e7680ba | 2015-09-11 17:06:19 -0700 | [diff] [blame] | 288 | c.envLock.Lock() |
| 289 | c.envFrozen = true |
| 290 | c.envLock.Unlock() |
Colin Cross | 68f5510 | 2015-03-25 14:43:57 -0700 | [diff] [blame] | 291 | return c.envDeps |
| 292 | } |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 293 | |
Dan Willemsen | 5ba07e8 | 2015-12-11 13:51:06 -0800 | [diff] [blame] | 294 | func (c *config) EmbeddedInMake() bool { |
| 295 | return c.inMake |
| 296 | } |
| 297 | |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 298 | // DeviceName returns the name of the current device target |
| 299 | // 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] | 300 | func (c *config) DeviceName() string { |
Dan Willemsen | 1d31ec3 | 2015-09-22 16:56:09 -0700 | [diff] [blame] | 301 | return *c.ProductVariables.DeviceName |
Colin Cross | 35cec12 | 2015-04-02 14:37:16 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Dan Willemsen | dd0e2c3 | 2015-10-20 14:29:35 -0700 | [diff] [blame] | 304 | func (c *config) DeviceUsesClang() bool { |
| 305 | if c.ProductVariables.DeviceUsesClang != nil { |
| 306 | return *c.ProductVariables.DeviceUsesClang |
| 307 | } |
Dan Willemsen | 0084d78 | 2016-03-01 14:54:24 -0800 | [diff] [blame] | 308 | return true |
Dan Willemsen | dd0e2c3 | 2015-10-20 14:29:35 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 311 | func (c *config) ResourceOverlays() []SourcePath { |
Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 312 | return nil |
| 313 | } |
| 314 | |
| 315 | func (c *config) PlatformVersion() string { |
| 316 | return "M" |
| 317 | } |
| 318 | |
| 319 | func (c *config) PlatformSdkVersion() string { |
Dan Willemsen | 5951c8a | 2016-07-19 19:08:14 -0700 | [diff] [blame] | 320 | return strconv.Itoa(*c.ProductVariables.Platform_sdk_version) |
Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | func (c *config) BuildNumber() string { |
| 324 | return "000000" |
| 325 | } |
| 326 | |
| 327 | func (c *config) ProductAaptConfig() []string { |
| 328 | return []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"} |
| 329 | } |
| 330 | |
| 331 | func (c *config) ProductAaptPreferredConfig() string { |
| 332 | return "xhdpi" |
| 333 | } |
| 334 | |
| 335 | func (c *config) ProductAaptCharacteristics() string { |
| 336 | return "nosdcard" |
| 337 | } |
| 338 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 339 | func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath { |
| 340 | return PathForSource(ctx, "build/target/product/security") |
Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 343 | func (c *config) DefaultAppCertificate(ctx PathContext) SourcePath { |
| 344 | return c.DefaultAppCertificateDir(ctx).Join(ctx, "testkey") |
Colin Cross | 30e076a | 2015-04-13 13:58:27 -0700 | [diff] [blame] | 345 | } |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 346 | |
| 347 | func (c *config) AllowMissingDependencies() bool { |
Dan Willemsen | b503816 | 2016-03-16 12:35:33 -0700 | [diff] [blame] | 348 | return Bool(c.ProductVariables.Allow_missing_dependencies) |
Colin Cross | 6ff5138 | 2015-12-17 16:39:19 -0800 | [diff] [blame] | 349 | } |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 350 | |
Colin Cross | 1e7d370 | 2016-08-24 15:25:47 -0700 | [diff] [blame] | 351 | func (c *config) DevicePrefer32BitExecutables() bool { |
| 352 | return Bool(c.ProductVariables.DevicePrefer32BitExecutables) |
| 353 | } |
| 354 | |
Dan Willemsen | 7f730fd | 2016-01-14 11:22:23 -0800 | [diff] [blame] | 355 | func (c *config) SkipDeviceInstall() bool { |
Dan Willemsen | 322acaf | 2016-01-12 23:07:05 -0800 | [diff] [blame] | 356 | return c.EmbeddedInMake() || Bool(c.Mega_device) |
| 357 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 358 | |
| 359 | func (c *config) SanitizeHost() []string { |
| 360 | if c.ProductVariables.SanitizeHost == nil { |
| 361 | return nil |
| 362 | } |
Colin Cross | cc85e68 | 2016-07-06 14:24:16 -0700 | [diff] [blame] | 363 | return append([]string(nil), *c.ProductVariables.SanitizeHost...) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | func (c *config) SanitizeDevice() []string { |
| 367 | if c.ProductVariables.SanitizeDevice == nil { |
| 368 | return nil |
| 369 | } |
Colin Cross | cc85e68 | 2016-07-06 14:24:16 -0700 | [diff] [blame] | 370 | return append([]string(nil), *c.ProductVariables.SanitizeDevice...) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 371 | } |
Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 372 | |
| 373 | func (c *config) Android64() bool { |
| 374 | for _, t := range c.Targets[Device] { |
| 375 | if t.Arch.ArchType.Multilib == "lib64" { |
| 376 | return true |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | return false |
| 381 | } |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 382 | |
Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 383 | func (c *config) UseGoma() bool { |
| 384 | return Bool(c.ProductVariables.UseGoma) |
| 385 | } |
| 386 | |
Colin Cross | 0f4e0d6 | 2016-07-27 10:56:55 -0700 | [diff] [blame] | 387 | func (c *config) LibartImgHostBaseAddress() string { |
| 388 | return "0x60000000" |
| 389 | } |
| 390 | |
| 391 | func (c *config) LibartImgDeviceBaseAddress() string { |
| 392 | switch c.Targets[Device][0].Arch.ArchType { |
| 393 | default: |
| 394 | return "0x70000000" |
| 395 | case Mips, Mips64: |
| 396 | return "0x30000000" |
| 397 | } |
| 398 | } |
| 399 | |
Colin Cross | 9272ade | 2016-08-17 15:24:12 -0700 | [diff] [blame] | 400 | func (c *deviceConfig) Arches() []Arch { |
| 401 | var arches []Arch |
| 402 | for _, target := range c.config.Targets[Device] { |
| 403 | arches = append(arches, target.Arch) |
| 404 | } |
| 405 | return arches |
| 406 | } |