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