2015-01-31 02:27:36 +01:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
package android
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2016-11-03 17:43:26 +01:00
|
|
|
"io/ioutil"
|
2015-01-31 02:27:36 +01:00
|
|
|
"os"
|
2015-04-02 23:37:16 +02:00
|
|
|
"path/filepath"
|
2015-01-31 02:27:36 +01:00
|
|
|
"runtime"
|
2016-07-20 04:08:14 +02:00
|
|
|
"strconv"
|
2015-09-24 00:26:20 +02:00
|
|
|
"strings"
|
2015-04-15 21:33:28 +02:00
|
|
|
"sync"
|
2015-12-18 01:39:19 +01:00
|
|
|
|
|
|
|
"github.com/google/blueprint/proptools"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
2015-12-18 01:39:19 +01:00
|
|
|
var Bool = proptools.Bool
|
2016-12-09 00:45:07 +01:00
|
|
|
var String = proptools.String
|
2015-12-18 01:39:19 +01:00
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
// The configuration file name
|
2015-07-14 09:39:06 +02:00
|
|
|
const configFileName = "soong.config"
|
|
|
|
const productVariablesFileName = "soong.variables"
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
// A FileConfigurableOptions contains options which can be configured by the
|
|
|
|
// config file. These will be included in the config struct.
|
|
|
|
type FileConfigurableOptions struct {
|
2016-01-13 08:07:05 +01:00
|
|
|
Mega_device *bool `json:",omitempty"`
|
2016-10-19 23:04:41 +02:00
|
|
|
Ndk_abis *bool `json:",omitempty"`
|
2016-06-14 02:19:03 +02:00
|
|
|
Host_bionic *bool `json:",omitempty"`
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-09-18 19:57:10 +02:00
|
|
|
func (f *FileConfigurableOptions) SetDefaultConfig() {
|
|
|
|
*f = FileConfigurableOptions{}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
// A Config object represents the entire build configuration for Android.
|
2015-04-11 00:43:55 +02:00
|
|
|
type Config struct {
|
|
|
|
*config
|
|
|
|
}
|
|
|
|
|
2017-03-30 02:29:06 +02:00
|
|
|
func (c Config) BuildDir() string {
|
|
|
|
return c.buildDir
|
|
|
|
}
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
// A DeviceConfig object represents the configuration for a particular device being built. For
|
|
|
|
// now there will only be one of these, but in the future there may be multiple devices being
|
|
|
|
// built
|
|
|
|
type DeviceConfig struct {
|
|
|
|
*deviceConfig
|
|
|
|
}
|
|
|
|
|
2015-04-08 02:11:30 +02:00
|
|
|
type config struct {
|
2015-01-31 02:27:36 +01:00
|
|
|
FileConfigurableOptions
|
2015-08-27 22:28:01 +02:00
|
|
|
ProductVariables productVariables
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-07-14 09:39:06 +02:00
|
|
|
ConfigFileName string
|
|
|
|
ProductVariablesFileName string
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
Targets map[OsClass][]Target
|
|
|
|
BuildOsVariant string
|
2015-07-09 03:13:11 +02:00
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
deviceConfig *deviceConfig
|
|
|
|
|
2015-07-14 09:39:06 +02:00
|
|
|
srcDir string // the path of the root source directory
|
|
|
|
buildDir string // the path of the build output directory
|
2015-04-15 21:33:28 +02:00
|
|
|
|
2015-09-12 02:06:19 +02:00
|
|
|
envLock sync.Mutex
|
|
|
|
envDeps map[string]string
|
|
|
|
envFrozen bool
|
2015-12-11 22:51:06 +01:00
|
|
|
|
|
|
|
inMake bool
|
2016-08-25 00:25:47 +02:00
|
|
|
|
2017-07-13 23:43:27 +02:00
|
|
|
captureBuild bool // true for tests, saves build parameters for each module
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
OncePer
|
|
|
|
}
|
|
|
|
|
|
|
|
type deviceConfig struct {
|
2017-07-07 01:59:48 +02:00
|
|
|
config *config
|
2016-08-18 00:24:12 +02:00
|
|
|
OncePer
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-08-27 22:28:01 +02:00
|
|
|
type jsonConfigurable interface {
|
2015-09-18 19:57:10 +02:00
|
|
|
SetDefaultConfig()
|
2015-08-27 22:28:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func loadConfig(config *config) error {
|
2015-07-14 09:39:06 +02:00
|
|
|
err := loadFromConfigFile(&config.FileConfigurableOptions, config.ConfigFileName)
|
2015-08-27 22:28:01 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-07-14 09:39:06 +02:00
|
|
|
return loadFromConfigFile(&config.ProductVariables, config.ProductVariablesFileName)
|
2015-08-27 22:28:01 +02:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2015-08-27 22:28:01 +02:00
|
|
|
// loads configuration options from a JSON file in the cwd.
|
|
|
|
func loadFromConfigFile(configurable jsonConfigurable, filename string) error {
|
2015-01-31 02:27:36 +01:00
|
|
|
// Try to open the file
|
2015-08-27 22:28:01 +02:00
|
|
|
configFileReader, err := os.Open(filename)
|
2015-01-31 02:27:36 +01:00
|
|
|
defer configFileReader.Close()
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
// Need to create a file, so that blueprint & ninja don't get in
|
|
|
|
// a dependency tracking loop.
|
|
|
|
// Make a file-configurable-options with defaults, write it out using
|
|
|
|
// a json writer.
|
2015-09-18 19:57:10 +02:00
|
|
|
configurable.SetDefaultConfig()
|
|
|
|
err = saveToConfigFile(configurable, filename)
|
2015-01-31 02:27:36 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Make a decoder for it
|
|
|
|
jsonDecoder := json.NewDecoder(configFileReader)
|
2015-08-27 22:28:01 +02:00
|
|
|
err = jsonDecoder.Decode(configurable)
|
2015-01-31 02:27:36 +01:00
|
|
|
if err != nil {
|
2015-08-27 22:28:01 +02:00
|
|
|
return fmt.Errorf("config file: %s did not parse correctly: "+err.Error(), filename)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No error
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-11-03 17:43:26 +01:00
|
|
|
// atomically writes the config file in case two copies of soong_build are running simultaneously
|
|
|
|
// (for example, docs generation and ninja manifest generation)
|
2015-08-27 22:28:01 +02:00
|
|
|
func saveToConfigFile(config jsonConfigurable, filename string) error {
|
2015-01-31 02:27:36 +01:00
|
|
|
data, err := json.MarshalIndent(&config, "", " ")
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("cannot marshal config data: %s", err.Error())
|
|
|
|
}
|
|
|
|
|
2016-11-03 17:43:26 +01:00
|
|
|
f, err := ioutil.TempFile(filepath.Dir(filename), "config")
|
2015-01-31 02:27:36 +01:00
|
|
|
if err != nil {
|
2015-08-27 22:28:01 +02:00
|
|
|
return fmt.Errorf("cannot create empty config file %s: %s\n", filename, err.Error())
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2016-11-03 17:43:26 +01:00
|
|
|
defer os.Remove(f.Name())
|
|
|
|
defer f.Close()
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2016-11-03 17:43:26 +01:00
|
|
|
_, err = f.Write(data)
|
2015-01-31 02:27:36 +01:00
|
|
|
if err != nil {
|
2015-08-27 22:28:01 +02:00
|
|
|
return fmt.Errorf("default config file: %s could not be written: %s", filename, err.Error())
|
|
|
|
}
|
|
|
|
|
2016-11-03 17:43:26 +01:00
|
|
|
_, err = f.WriteString("\n")
|
2015-08-27 22:28:01 +02:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("default config file: %s could not be written: %s", filename, err.Error())
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-11-03 17:43:26 +01:00
|
|
|
f.Close()
|
|
|
|
os.Rename(f.Name(), filename)
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
// TestConfig returns a Config object suitable for using for tests
|
2016-10-15 00:38:43 +02:00
|
|
|
func TestConfig(buildDir string) Config {
|
2017-07-07 01:59:48 +02:00
|
|
|
config := &config{
|
|
|
|
ProductVariables: productVariables{
|
|
|
|
DeviceName: stringPtr("test_device"),
|
|
|
|
},
|
|
|
|
|
2017-07-13 23:43:27 +02:00
|
|
|
buildDir: buildDir,
|
|
|
|
captureBuild: true,
|
2017-07-07 01:59:48 +02:00
|
|
|
}
|
|
|
|
config.deviceConfig = &deviceConfig{
|
|
|
|
config: config,
|
|
|
|
}
|
|
|
|
|
|
|
|
return Config{config}
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
// New creates a new Config object. The srcDir argument specifies the path to
|
|
|
|
// the root source directory. It also loads the config file, if found.
|
2015-07-14 09:39:06 +02:00
|
|
|
func NewConfig(srcDir, buildDir string) (Config, error) {
|
2015-01-31 02:27:36 +01:00
|
|
|
// Make a config with default options
|
2016-08-18 00:24:12 +02:00
|
|
|
config := &config{
|
|
|
|
ConfigFileName: filepath.Join(buildDir, configFileName),
|
|
|
|
ProductVariablesFileName: filepath.Join(buildDir, productVariablesFileName),
|
|
|
|
|
|
|
|
srcDir: srcDir,
|
|
|
|
buildDir: buildDir,
|
2015-03-25 22:43:57 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2017-07-07 01:59:48 +02:00
|
|
|
config.deviceConfig = &deviceConfig{
|
2016-08-18 00:24:12 +02:00
|
|
|
config: config,
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
// Sanity check the build and source directories. This won't catch strange
|
|
|
|
// configurations with symlinks, but at least checks the obvious cases.
|
|
|
|
absBuildDir, err := filepath.Abs(buildDir)
|
|
|
|
if err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
absSrcDir, err := filepath.Abs(srcDir)
|
|
|
|
if err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.HasPrefix(absSrcDir, absBuildDir) {
|
|
|
|
return Config{}, fmt.Errorf("Build dir must not contain source directory")
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
// Load any configurable options from the configuration file
|
2016-08-18 00:24:12 +02:00
|
|
|
err = loadConfig(config)
|
2015-01-31 02:27:36 +01:00
|
|
|
if err != nil {
|
2015-04-11 00:43:55 +02:00
|
|
|
return Config{}, err
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-12-11 22:51:06 +01:00
|
|
|
inMakeFile := filepath.Join(buildDir, ".soong.in_make")
|
|
|
|
if _, err := os.Stat(inMakeFile); err == nil {
|
|
|
|
config.inMake = true
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
targets, err := decodeTargetProductVariables(config)
|
2015-07-09 03:13:11 +02:00
|
|
|
if err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
|
|
|
|
2016-10-19 23:04:41 +02:00
|
|
|
var archConfig []archConfig
|
2016-01-13 08:07:05 +01:00
|
|
|
if Bool(config.Mega_device) {
|
2016-10-19 23:04:41 +02:00
|
|
|
archConfig = getMegaDeviceConfig()
|
|
|
|
} else if Bool(config.Ndk_abis) {
|
|
|
|
archConfig = getNdkAbisConfig()
|
|
|
|
}
|
|
|
|
|
|
|
|
if archConfig != nil {
|
|
|
|
deviceTargets, err := decodeArchSettings(archConfig)
|
2016-01-13 08:07:05 +01:00
|
|
|
if err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
2016-06-02 02:09:44 +02:00
|
|
|
targets[Device] = deviceTargets
|
2016-01-13 08:07:05 +01:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
config.Targets = targets
|
|
|
|
config.BuildOsVariant = targets[Host][0].String()
|
2015-07-09 03:13:11 +02:00
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
return Config{config}, nil
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-07-09 03:13:11 +02:00
|
|
|
func (c *config) RemoveAbandonedFiles() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-05-27 00:13:03 +02:00
|
|
|
func (c *config) BlueprintToolLocation() string {
|
|
|
|
return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin")
|
|
|
|
}
|
|
|
|
|
2017-05-08 23:15:59 +02:00
|
|
|
// HostSystemTool looks for non-hermetic tools from the system we're running on.
|
|
|
|
// Generally shouldn't be used, but useful to find the XCode SDK, etc.
|
|
|
|
func (c *config) HostSystemTool(name string) string {
|
|
|
|
for _, dir := range filepath.SplitList(c.Getenv("PATH")) {
|
|
|
|
path := filepath.Join(dir, name)
|
|
|
|
if s, err := os.Stat(path); err != nil {
|
|
|
|
continue
|
|
|
|
} else if m := s.Mode(); !s.IsDir() && m&0111 != 0 {
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return name
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
// PrebuiltOS returns the name of the host OS used in prebuilts directories
|
2015-04-08 02:11:30 +02:00
|
|
|
func (c *config) PrebuiltOS() string {
|
2015-01-31 02:27:36 +01:00
|
|
|
switch runtime.GOOS {
|
|
|
|
case "linux":
|
|
|
|
return "linux-x86"
|
|
|
|
case "darwin":
|
|
|
|
return "darwin-x86"
|
|
|
|
default:
|
|
|
|
panic("Unknown GOOS")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GoRoot returns the path to the root directory of the Go toolchain.
|
2015-04-08 02:11:30 +02:00
|
|
|
func (c *config) GoRoot() string {
|
2015-01-31 02:27:36 +01:00
|
|
|
return fmt.Sprintf("%s/prebuilts/go/%s", c.srcDir, c.PrebuiltOS())
|
|
|
|
}
|
|
|
|
|
2015-04-08 02:11:30 +02:00
|
|
|
func (c *config) CpPreserveSymlinksFlags() string {
|
2015-08-27 22:28:01 +02:00
|
|
|
switch runtime.GOOS {
|
2015-01-31 02:27:36 +01:00
|
|
|
case "darwin":
|
|
|
|
return "-R"
|
|
|
|
case "linux":
|
|
|
|
return "-d"
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2015-03-25 22:43:57 +01:00
|
|
|
|
2015-04-08 02:11:30 +02:00
|
|
|
func (c *config) Getenv(key string) string {
|
2015-03-25 22:43:57 +01:00
|
|
|
var val string
|
|
|
|
var exists bool
|
2015-04-15 21:33:28 +02:00
|
|
|
c.envLock.Lock()
|
2017-02-07 00:40:41 +01:00
|
|
|
defer c.envLock.Unlock()
|
|
|
|
if c.envDeps == nil {
|
|
|
|
c.envDeps = make(map[string]string)
|
|
|
|
}
|
2015-03-25 22:43:57 +01:00
|
|
|
if val, exists = c.envDeps[key]; !exists {
|
2015-09-12 02:06:19 +02:00
|
|
|
if c.envFrozen {
|
|
|
|
panic("Cannot access new environment variables after envdeps are frozen")
|
|
|
|
}
|
2017-05-08 23:15:59 +02:00
|
|
|
val, _ = originalEnv[key]
|
2015-03-25 22:43:57 +01:00
|
|
|
c.envDeps[key] = val
|
|
|
|
}
|
|
|
|
return val
|
|
|
|
}
|
|
|
|
|
2016-11-24 01:52:04 +01:00
|
|
|
func (c *config) GetenvWithDefault(key string, defaultValue string) string {
|
|
|
|
ret := c.Getenv(key)
|
|
|
|
if ret == "" {
|
|
|
|
return defaultValue
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) IsEnvTrue(key string) bool {
|
|
|
|
value := c.Getenv(key)
|
|
|
|
return value == "1" || value == "y" || value == "yes" || value == "on" || value == "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) IsEnvFalse(key string) bool {
|
|
|
|
value := c.Getenv(key)
|
|
|
|
return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
|
|
|
|
}
|
|
|
|
|
2015-04-08 02:11:30 +02:00
|
|
|
func (c *config) EnvDeps() map[string]string {
|
2015-09-12 02:06:19 +02:00
|
|
|
c.envLock.Lock()
|
2017-02-07 00:40:41 +01:00
|
|
|
defer c.envLock.Unlock()
|
2015-09-12 02:06:19 +02:00
|
|
|
c.envFrozen = true
|
2015-03-25 22:43:57 +01:00
|
|
|
return c.envDeps
|
|
|
|
}
|
2015-04-02 23:37:16 +02:00
|
|
|
|
2015-12-11 22:51:06 +01:00
|
|
|
func (c *config) EmbeddedInMake() bool {
|
|
|
|
return c.inMake
|
|
|
|
}
|
|
|
|
|
2015-04-02 23:37:16 +02:00
|
|
|
// DeviceName returns the name of the current device target
|
|
|
|
// TODO: take an AndroidModuleContext to select the device name for multi-device builds
|
2015-04-08 02:11:30 +02:00
|
|
|
func (c *config) DeviceName() string {
|
2015-09-23 01:56:09 +02:00
|
|
|
return *c.ProductVariables.DeviceName
|
2015-04-02 23:37:16 +02:00
|
|
|
}
|
|
|
|
|
2015-10-20 23:29:35 +02:00
|
|
|
func (c *config) DeviceUsesClang() bool {
|
|
|
|
if c.ProductVariables.DeviceUsesClang != nil {
|
|
|
|
return *c.ProductVariables.DeviceUsesClang
|
|
|
|
}
|
2016-03-01 23:54:24 +01:00
|
|
|
return true
|
2015-10-20 23:29:35 +02:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
func (c *config) ResourceOverlays() []SourcePath {
|
2015-04-13 22:58:27 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) PlatformVersion() string {
|
|
|
|
return "M"
|
|
|
|
}
|
|
|
|
|
2016-11-10 19:46:36 +01:00
|
|
|
func (c *config) PlatformSdkVersionInt() int {
|
|
|
|
return *c.ProductVariables.Platform_sdk_version
|
|
|
|
}
|
|
|
|
|
2015-04-13 22:58:27 +02:00
|
|
|
func (c *config) PlatformSdkVersion() string {
|
2016-11-10 19:46:36 +01:00
|
|
|
return strconv.Itoa(c.PlatformSdkVersionInt())
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2017-08-18 01:19:59 +02:00
|
|
|
func (c *config) MinSupportedSdkVersion() int {
|
2017-08-10 21:18:31 +02:00
|
|
|
return 14
|
2017-08-18 01:19:59 +02:00
|
|
|
}
|
|
|
|
|
2017-07-28 21:39:46 +02:00
|
|
|
// Codenames that are active in the current lunch target.
|
|
|
|
func (c *config) PlatformVersionActiveCodenames() []string {
|
|
|
|
return c.ProductVariables.Platform_version_active_codenames
|
|
|
|
}
|
|
|
|
|
|
|
|
// Codenames that are available in the branch but not included in the current
|
|
|
|
// lunch target.
|
|
|
|
func (c *config) PlatformVersionFutureCodenames() []string {
|
|
|
|
return c.ProductVariables.Platform_version_future_codenames
|
|
|
|
}
|
|
|
|
|
|
|
|
// All possible codenames in the current branch. NB: Not named AllCodenames
|
|
|
|
// because "all" has historically meant "active" in make, and still does in
|
|
|
|
// build.prop.
|
|
|
|
func (c *config) PlatformVersionCombinedCodenames() []string {
|
|
|
|
combined := []string{}
|
|
|
|
combined = append(combined, c.PlatformVersionActiveCodenames()...)
|
|
|
|
combined = append(combined, c.PlatformVersionFutureCodenames()...)
|
|
|
|
return combined
|
2017-03-28 23:54:55 +02:00
|
|
|
}
|
|
|
|
|
2015-04-13 22:58:27 +02:00
|
|
|
func (c *config) BuildNumber() string {
|
|
|
|
return "000000"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) ProductAaptConfig() []string {
|
|
|
|
return []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) ProductAaptPreferredConfig() string {
|
|
|
|
return "xhdpi"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) ProductAaptCharacteristics() string {
|
|
|
|
return "nosdcard"
|
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath {
|
|
|
|
return PathForSource(ctx, "build/target/product/security")
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
func (c *config) DefaultAppCertificate(ctx PathContext) SourcePath {
|
|
|
|
return c.DefaultAppCertificateDir(ctx).Join(ctx, "testkey")
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
2015-12-18 01:39:19 +01:00
|
|
|
|
|
|
|
func (c *config) AllowMissingDependencies() bool {
|
2016-03-16 20:35:33 +01:00
|
|
|
return Bool(c.ProductVariables.Allow_missing_dependencies)
|
2015-12-18 01:39:19 +01:00
|
|
|
}
|
2016-01-13 08:07:05 +01:00
|
|
|
|
2016-08-25 00:25:47 +02:00
|
|
|
func (c *config) DevicePrefer32BitExecutables() bool {
|
|
|
|
return Bool(c.ProductVariables.DevicePrefer32BitExecutables)
|
|
|
|
}
|
|
|
|
|
2016-01-14 20:22:23 +01:00
|
|
|
func (c *config) SkipDeviceInstall() bool {
|
2017-04-27 02:34:03 +02:00
|
|
|
return c.EmbeddedInMake()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) SkipMegaDeviceInstall(path string) bool {
|
|
|
|
return Bool(c.Mega_device) &&
|
|
|
|
strings.HasPrefix(path, filepath.Join(c.buildDir, "target", "product"))
|
2016-01-13 08:07:05 +01:00
|
|
|
}
|
2016-01-06 23:41:07 +01:00
|
|
|
|
|
|
|
func (c *config) SanitizeHost() []string {
|
2016-11-02 22:34:39 +01:00
|
|
|
return append([]string(nil), c.ProductVariables.SanitizeHost...)
|
2016-01-06 23:41:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) SanitizeDevice() []string {
|
2016-11-02 22:34:39 +01:00
|
|
|
return append([]string(nil), c.ProductVariables.SanitizeDevice...)
|
|
|
|
}
|
|
|
|
|
2017-06-28 18:10:48 +02:00
|
|
|
func (c *config) SanitizeDeviceDiag() []string {
|
|
|
|
return append([]string(nil), c.ProductVariables.SanitizeDeviceDiag...)
|
|
|
|
}
|
|
|
|
|
2016-11-02 22:34:39 +01:00
|
|
|
func (c *config) SanitizeDeviceArch() []string {
|
|
|
|
return append([]string(nil), c.ProductVariables.SanitizeDeviceArch...)
|
2016-01-06 23:41:07 +01:00
|
|
|
}
|
2016-06-02 02:09:44 +02:00
|
|
|
|
2017-01-19 22:54:55 +01:00
|
|
|
func (c *config) EnableCFI() bool {
|
2017-01-24 23:20:54 +01:00
|
|
|
if c.ProductVariables.EnableCFI == nil {
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
return *c.ProductVariables.EnableCFI
|
|
|
|
}
|
2017-01-19 22:54:55 +01:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (c *config) Android64() bool {
|
|
|
|
for _, t := range c.Targets[Device] {
|
|
|
|
if t.Arch.ArchType.Multilib == "lib64" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
2016-08-18 00:24:12 +02:00
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
func (c *config) UseGoma() bool {
|
|
|
|
return Bool(c.ProductVariables.UseGoma)
|
|
|
|
}
|
|
|
|
|
2016-09-27 00:45:04 +02:00
|
|
|
func (c *config) ClangTidy() bool {
|
|
|
|
return Bool(c.ProductVariables.ClangTidy)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) TidyChecks() string {
|
|
|
|
if c.ProductVariables.TidyChecks == nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return *c.ProductVariables.TidyChecks
|
|
|
|
}
|
|
|
|
|
2016-07-27 19:56:55 +02:00
|
|
|
func (c *config) LibartImgHostBaseAddress() string {
|
|
|
|
return "0x60000000"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) LibartImgDeviceBaseAddress() string {
|
2017-06-23 00:34:51 +02:00
|
|
|
archType := Common
|
|
|
|
if len(c.Targets[Device]) > 0 {
|
|
|
|
archType = c.Targets[Device][0].Arch.ArchType
|
|
|
|
}
|
|
|
|
switch archType {
|
2016-07-27 19:56:55 +02:00
|
|
|
default:
|
|
|
|
return "0x70000000"
|
|
|
|
case Mips, Mips64:
|
2017-05-31 01:36:58 +02:00
|
|
|
return "0x5C000000"
|
2016-07-27 19:56:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-19 22:44:41 +01:00
|
|
|
func (c *config) ArtUseReadBarrier() bool {
|
|
|
|
return Bool(c.ProductVariables.ArtUseReadBarrier)
|
|
|
|
}
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
func (c *deviceConfig) Arches() []Arch {
|
|
|
|
var arches []Arch
|
|
|
|
for _, target := range c.config.Targets[Device] {
|
|
|
|
arches = append(arches, target.Arch)
|
|
|
|
}
|
|
|
|
return arches
|
|
|
|
}
|
2016-11-18 23:54:24 +01:00
|
|
|
|
2016-12-06 02:16:02 +01:00
|
|
|
func (c *deviceConfig) VendorPath() string {
|
|
|
|
if c.config.ProductVariables.VendorPath != nil {
|
|
|
|
return *c.config.ProductVariables.VendorPath
|
|
|
|
}
|
|
|
|
return "vendor"
|
|
|
|
}
|
|
|
|
|
2017-03-20 02:30:37 +01:00
|
|
|
func (c *deviceConfig) CompileVndk() bool {
|
2016-11-18 23:54:24 +01:00
|
|
|
if c.config.ProductVariables.DeviceVndkVersion == nil {
|
2017-03-20 02:30:37 +01:00
|
|
|
return false
|
2016-11-18 23:54:24 +01:00
|
|
|
}
|
2017-03-20 02:30:37 +01:00
|
|
|
return *c.config.ProductVariables.DeviceVndkVersion == "current"
|
2016-11-18 23:54:24 +01:00
|
|
|
}
|
2016-12-09 00:45:07 +01:00
|
|
|
|
|
|
|
func (c *deviceConfig) BtConfigIncludeDir() string {
|
|
|
|
return String(c.config.ProductVariables.BtConfigIncludeDir)
|
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
|
2017-07-03 06:18:12 +02:00
|
|
|
func (c *deviceConfig) DeviceKernelHeaderDirs() []string {
|
|
|
|
return c.config.ProductVariables.DeviceKernelHeaders
|
|
|
|
}
|
|
|
|
|
2017-02-10 01:16:31 +01:00
|
|
|
func (c *deviceConfig) NativeCoverageEnabled() bool {
|
|
|
|
return Bool(c.config.ProductVariables.NativeCoverage)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
|
2017-02-27 18:01:54 +01:00
|
|
|
coverage := false
|
2017-02-10 01:16:31 +01:00
|
|
|
if c.config.ProductVariables.CoveragePaths != nil {
|
2017-07-13 23:46:05 +02:00
|
|
|
if prefixInList(path, *c.config.ProductVariables.CoveragePaths) {
|
|
|
|
coverage = true
|
2017-02-10 01:16:31 +01:00
|
|
|
}
|
|
|
|
}
|
2017-02-27 18:01:54 +01:00
|
|
|
if coverage && c.config.ProductVariables.CoverageExcludePaths != nil {
|
2017-07-13 23:46:05 +02:00
|
|
|
if prefixInList(path, *c.config.ProductVariables.CoverageExcludePaths) {
|
|
|
|
coverage = false
|
2017-02-27 18:01:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return coverage
|
2017-02-10 01:16:31 +01:00
|
|
|
}
|
2017-07-13 23:46:05 +02:00
|
|
|
|
|
|
|
func (c *config) IntegerOverflowDisabledForPath(path string) bool {
|
|
|
|
if c.ProductVariables.IntegerOverflowExcludePaths == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return prefixInList(path, *c.ProductVariables.IntegerOverflowExcludePaths)
|
|
|
|
}
|