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