2015-01-31 09:27:36 +08: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 06:37:25 +08:00
|
|
|
package android
|
2015-01-31 09:27:36 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2016-11-04 00:43:26 +08:00
|
|
|
"io/ioutil"
|
2015-01-31 09:27:36 +08:00
|
|
|
"os"
|
2015-04-03 05:37:16 +08:00
|
|
|
"path/filepath"
|
2015-01-31 09:27:36 +08:00
|
|
|
"runtime"
|
2016-07-20 10:08:14 +08:00
|
|
|
"strconv"
|
2015-09-24 06:26:20 +08:00
|
|
|
"strings"
|
2015-04-16 03:33:28 +08:00
|
|
|
"sync"
|
2015-12-18 08:39:19 +08:00
|
|
|
|
2017-12-12 07:52:26 +08:00
|
|
|
"github.com/google/blueprint/bootstrap"
|
2015-12-18 08:39:19 +08:00
|
|
|
"github.com/google/blueprint/proptools"
|
2015-01-31 09:27:36 +08:00
|
|
|
)
|
|
|
|
|
2015-12-18 08:39:19 +08:00
|
|
|
var Bool = proptools.Bool
|
2016-12-09 07:45:07 +08:00
|
|
|
var String = proptools.String
|
2018-01-15 14:05:10 +08:00
|
|
|
var FutureApiLevel = 10000
|
2015-12-18 08:39:19 +08:00
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
// The configuration file name
|
2015-07-14 15:39:06 +08:00
|
|
|
const configFileName = "soong.config"
|
|
|
|
const productVariablesFileName = "soong.variables"
|
2015-01-31 09:27:36 +08: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 15:07:05 +08:00
|
|
|
Mega_device *bool `json:",omitempty"`
|
2016-10-20 05:04:41 +08:00
|
|
|
Ndk_abis *bool `json:",omitempty"`
|
2016-06-14 08:19:03 +08:00
|
|
|
Host_bionic *bool `json:",omitempty"`
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-09-19 01:57:10 +08:00
|
|
|
func (f *FileConfigurableOptions) SetDefaultConfig() {
|
|
|
|
*f = FileConfigurableOptions{}
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-08-18 06:24:12 +08:00
|
|
|
// A Config object represents the entire build configuration for Android.
|
2015-04-11 06:43:55 +08:00
|
|
|
type Config struct {
|
|
|
|
*config
|
|
|
|
}
|
|
|
|
|
2017-03-30 08:29:06 +08:00
|
|
|
func (c Config) BuildDir() string {
|
|
|
|
return c.buildDir
|
|
|
|
}
|
|
|
|
|
2016-08-18 06:24:12 +08: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
|
|
|
|
}
|
|
|
|
|
2018-03-27 03:41:18 +08:00
|
|
|
type VendorConfig interface {
|
|
|
|
// Bool interprets the variable named `name` as a boolean, returning true if, after
|
|
|
|
// lowercasing, it matches one of "1", "y", "yes", "on", or "true". Unset, or any other
|
|
|
|
// value will return false.
|
|
|
|
Bool(name string) bool
|
|
|
|
|
|
|
|
// String returns the string value of `name`. If the variable was not set, it will
|
|
|
|
// return the empty string.
|
|
|
|
String(name string) string
|
|
|
|
|
|
|
|
// IsSet returns whether the variable `name` was set by Make.
|
|
|
|
IsSet(name string) bool
|
|
|
|
}
|
|
|
|
|
2015-04-08 08:11:30 +08:00
|
|
|
type config struct {
|
2015-01-31 09:27:36 +08:00
|
|
|
FileConfigurableOptions
|
2018-03-10 13:22:06 +08:00
|
|
|
productVariables productVariables
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2018-03-13 09:06:05 +08:00
|
|
|
// Only available on configs created by TestConfig
|
|
|
|
TestProductVariables *productVariables
|
|
|
|
|
2017-12-12 07:52:26 +08:00
|
|
|
PrimaryBuilder string
|
2015-07-14 15:39:06 +08:00
|
|
|
ConfigFileName string
|
|
|
|
ProductVariablesFileName string
|
|
|
|
|
2018-07-02 23:34:51 +08:00
|
|
|
Targets map[OsClass][]Target
|
|
|
|
BuildOsVariant string
|
|
|
|
BuildOsCommonVariant string
|
2015-07-09 09:13:11 +08:00
|
|
|
|
2016-08-18 06:24:12 +08:00
|
|
|
deviceConfig *deviceConfig
|
|
|
|
|
2015-07-14 15:39:06 +08:00
|
|
|
srcDir string // the path of the root source directory
|
|
|
|
buildDir string // the path of the build output directory
|
2015-04-16 03:33:28 +08:00
|
|
|
|
2017-10-11 14:07:38 +08:00
|
|
|
env map[string]string
|
2015-09-12 08:06:19 +08:00
|
|
|
envLock sync.Mutex
|
|
|
|
envDeps map[string]string
|
|
|
|
envFrozen bool
|
2015-12-12 05:51:06 +08:00
|
|
|
|
|
|
|
inMake bool
|
2016-08-25 06:25:47 +08:00
|
|
|
|
2017-09-06 12:56:44 +08:00
|
|
|
captureBuild bool // true for tests, saves build parameters for each module
|
|
|
|
ignoreEnvironment bool // true for tests, returns empty from all Getenv calls
|
2017-07-14 05:43:27 +08:00
|
|
|
|
2018-06-20 13:49:39 +08:00
|
|
|
targetOpenJDK9 bool // Target 1.9
|
2017-09-30 08:58:17 +08:00
|
|
|
|
2017-12-12 07:52:26 +08:00
|
|
|
stopBefore bootstrap.StopBefore
|
|
|
|
|
2016-08-18 06:24:12 +08:00
|
|
|
OncePer
|
|
|
|
}
|
|
|
|
|
|
|
|
type deviceConfig struct {
|
2017-07-07 07:59:48 +08:00
|
|
|
config *config
|
2016-08-18 06:24:12 +08:00
|
|
|
OncePer
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2018-03-27 03:41:18 +08:00
|
|
|
type vendorConfig map[string]string
|
|
|
|
|
2015-08-28 04:28:01 +08:00
|
|
|
type jsonConfigurable interface {
|
2015-09-19 01:57:10 +08:00
|
|
|
SetDefaultConfig()
|
2015-08-28 04:28:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func loadConfig(config *config) error {
|
2015-07-14 15:39:06 +08:00
|
|
|
err := loadFromConfigFile(&config.FileConfigurableOptions, config.ConfigFileName)
|
2015-08-28 04:28:01 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-10 13:22:06 +08:00
|
|
|
return loadFromConfigFile(&config.productVariables, config.ProductVariablesFileName)
|
2015-08-28 04:28:01 +08:00
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2015-08-28 04:28:01 +08:00
|
|
|
// loads configuration options from a JSON file in the cwd.
|
|
|
|
func loadFromConfigFile(configurable jsonConfigurable, filename string) error {
|
2015-01-31 09:27:36 +08:00
|
|
|
// Try to open the file
|
2015-08-28 04:28:01 +08:00
|
|
|
configFileReader, err := os.Open(filename)
|
2015-01-31 09:27:36 +08: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-19 01:57:10 +08:00
|
|
|
configurable.SetDefaultConfig()
|
|
|
|
err = saveToConfigFile(configurable, filename)
|
2015-01-31 09:27:36 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-28 03:26:02 +08:00
|
|
|
} else if err != nil {
|
|
|
|
return fmt.Errorf("config file: could not open %s: %s", filename, err.Error())
|
2015-01-31 09:27:36 +08:00
|
|
|
} else {
|
|
|
|
// Make a decoder for it
|
|
|
|
jsonDecoder := json.NewDecoder(configFileReader)
|
2015-08-28 04:28:01 +08:00
|
|
|
err = jsonDecoder.Decode(configurable)
|
2015-01-31 09:27:36 +08:00
|
|
|
if err != nil {
|
2018-02-28 03:26:02 +08:00
|
|
|
return fmt.Errorf("config file: %s did not parse correctly: %s", filename, err.Error())
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No error
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-11-04 00:43:26 +08: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-28 04:28:01 +08:00
|
|
|
func saveToConfigFile(config jsonConfigurable, filename string) error {
|
2015-01-31 09:27:36 +08:00
|
|
|
data, err := json.MarshalIndent(&config, "", " ")
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("cannot marshal config data: %s", err.Error())
|
|
|
|
}
|
|
|
|
|
2016-11-04 00:43:26 +08:00
|
|
|
f, err := ioutil.TempFile(filepath.Dir(filename), "config")
|
2015-01-31 09:27:36 +08:00
|
|
|
if err != nil {
|
2015-08-28 04:28:01 +08:00
|
|
|
return fmt.Errorf("cannot create empty config file %s: %s\n", filename, err.Error())
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
2016-11-04 00:43:26 +08:00
|
|
|
defer os.Remove(f.Name())
|
|
|
|
defer f.Close()
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2016-11-04 00:43:26 +08:00
|
|
|
_, err = f.Write(data)
|
2015-01-31 09:27:36 +08:00
|
|
|
if err != nil {
|
2015-08-28 04:28:01 +08:00
|
|
|
return fmt.Errorf("default config file: %s could not be written: %s", filename, err.Error())
|
|
|
|
}
|
|
|
|
|
2016-11-04 00:43:26 +08:00
|
|
|
_, err = f.WriteString("\n")
|
2015-08-28 04:28:01 +08:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("default config file: %s could not be written: %s", filename, err.Error())
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2016-11-04 00:43:26 +08:00
|
|
|
f.Close()
|
|
|
|
os.Rename(f.Name(), filename)
|
|
|
|
|
2015-01-31 09:27:36 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-10-07 07:12:58 +08:00
|
|
|
// TestConfig returns a Config object suitable for using for tests
|
2017-10-11 14:07:38 +08:00
|
|
|
func TestConfig(buildDir string, env map[string]string) Config {
|
2017-07-07 07:59:48 +08:00
|
|
|
config := &config{
|
2018-03-10 13:22:06 +08:00
|
|
|
productVariables: productVariables{
|
2017-11-23 08:19:37 +08:00
|
|
|
DeviceName: stringPtr("test_device"),
|
|
|
|
Platform_sdk_version: intPtr(26),
|
|
|
|
AAPTConfig: &[]string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
|
|
|
|
AAPTPreferredConfig: stringPtr("xhdpi"),
|
|
|
|
AAPTCharacteristics: stringPtr("nosdcard"),
|
|
|
|
AAPTPrebuiltDPI: &[]string{"xhdpi", "xxhdpi"},
|
2017-07-07 07:59:48 +08:00
|
|
|
},
|
|
|
|
|
2017-10-11 14:07:38 +08:00
|
|
|
buildDir: buildDir,
|
|
|
|
captureBuild: true,
|
|
|
|
env: env,
|
2017-07-07 07:59:48 +08:00
|
|
|
}
|
|
|
|
config.deviceConfig = &deviceConfig{
|
|
|
|
config: config,
|
|
|
|
}
|
2018-03-10 13:22:06 +08:00
|
|
|
config.TestProductVariables = &config.productVariables
|
2017-07-07 07:59:48 +08:00
|
|
|
|
2017-09-30 08:58:17 +08:00
|
|
|
if err := config.fromEnv(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2017-07-07 07:59:48 +08:00
|
|
|
return Config{config}
|
2016-10-07 07:12:58 +08:00
|
|
|
}
|
|
|
|
|
2017-09-16 08:33:55 +08:00
|
|
|
// TestConfig returns a Config object suitable for using for tests that need to run the arch mutator
|
2017-10-11 14:07:38 +08:00
|
|
|
func TestArchConfig(buildDir string, env map[string]string) Config {
|
|
|
|
testConfig := TestConfig(buildDir, env)
|
2017-09-16 08:33:55 +08:00
|
|
|
config := testConfig.config
|
|
|
|
|
|
|
|
config.Targets = map[OsClass][]Target{
|
|
|
|
Device: []Target{
|
Squash vendor sources before linkageMutator runs
linkageMutator removes srcs property of the shared variant of a lib in
order to reuse *.o files compiled for the static variant also to the
shared variant.
However, this causes problem when vendor-specific srcs are specified in
target: {vendor: {srcs: ["..."]}}. For example, let's assume
cc_library {
name: "libfoo",
srcs: ["foo.c"],
target: {
vendor: {
srcs: ["bar.c"],
},
},
}
Then,
static_vendor: inputs = foo.o, bar.o
shared_vendor: inputs = foo.o (from static_vendor), bar.o (from
static_vendor), bar.o
So, bar.o is included twice and this causes multiple symbol definition
error.
In order to handle the problem, vendor mutator is applied before the
linkage mutator and the vendor-specific srcs are squashed in the vendor
mutator.
Bug: 67731122
Test: build
Test: cc_test.go
Change-Id: I2a5390295dddfc41260e9b6f02746908cdf47228
2017-10-12 22:05:00 +08:00
|
|
|
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true}},
|
|
|
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true}},
|
2017-09-16 08:33:55 +08:00
|
|
|
},
|
|
|
|
Host: []Target{
|
|
|
|
{BuildOs, Arch{ArchType: X86_64}},
|
|
|
|
{BuildOs, Arch{ArchType: X86}},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-10-05 14:28:25 +08:00
|
|
|
config.BuildOsVariant = config.Targets[Host][0].String()
|
|
|
|
|
2017-09-16 08:33:55 +08:00
|
|
|
return testConfig
|
|
|
|
}
|
|
|
|
|
2015-01-31 09:27:36 +08: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 15:39:06 +08:00
|
|
|
func NewConfig(srcDir, buildDir string) (Config, error) {
|
2015-01-31 09:27:36 +08:00
|
|
|
// Make a config with default options
|
2016-08-18 06:24:12 +08:00
|
|
|
config := &config{
|
|
|
|
ConfigFileName: filepath.Join(buildDir, configFileName),
|
|
|
|
ProductVariablesFileName: filepath.Join(buildDir, productVariablesFileName),
|
|
|
|
|
2017-10-11 14:07:38 +08:00
|
|
|
env: originalEnv,
|
|
|
|
|
2016-08-18 06:24:12 +08:00
|
|
|
srcDir: srcDir,
|
|
|
|
buildDir: buildDir,
|
2015-03-26 05:43:57 +08:00
|
|
|
}
|
2015-01-31 09:27:36 +08:00
|
|
|
|
2017-07-07 07:59:48 +08:00
|
|
|
config.deviceConfig = &deviceConfig{
|
2016-08-18 06:24:12 +08:00
|
|
|
config: config,
|
|
|
|
}
|
|
|
|
|
2015-09-24 06:26:20 +08: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 09:27:36 +08:00
|
|
|
// Load any configurable options from the configuration file
|
2016-08-18 06:24:12 +08:00
|
|
|
err = loadConfig(config)
|
2015-01-31 09:27:36 +08:00
|
|
|
if err != nil {
|
2015-04-11 06:43:55 +08:00
|
|
|
return Config{}, err
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2015-12-12 05:51:06 +08:00
|
|
|
inMakeFile := filepath.Join(buildDir, ".soong.in_make")
|
|
|
|
if _, err := os.Stat(inMakeFile); err == nil {
|
|
|
|
config.inMake = true
|
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
targets, err := decodeTargetProductVariables(config)
|
2015-07-09 09:13:11 +08:00
|
|
|
if err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
|
|
|
|
2016-10-20 05:04:41 +08:00
|
|
|
var archConfig []archConfig
|
2016-01-13 15:07:05 +08:00
|
|
|
if Bool(config.Mega_device) {
|
2016-10-20 05:04:41 +08:00
|
|
|
archConfig = getMegaDeviceConfig()
|
|
|
|
} else if Bool(config.Ndk_abis) {
|
|
|
|
archConfig = getNdkAbisConfig()
|
|
|
|
}
|
|
|
|
|
|
|
|
if archConfig != nil {
|
|
|
|
deviceTargets, err := decodeArchSettings(archConfig)
|
2016-01-13 15:07:05 +08:00
|
|
|
if err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
2016-06-02 08:09:44 +08:00
|
|
|
targets[Device] = deviceTargets
|
2016-01-13 15:07:05 +08:00
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08:00
|
|
|
config.Targets = targets
|
|
|
|
config.BuildOsVariant = targets[Host][0].String()
|
2018-07-02 23:34:51 +08:00
|
|
|
config.BuildOsCommonVariant = getCommonTargets(targets[Host])[0].String()
|
2015-07-09 09:13:11 +08:00
|
|
|
|
2017-09-30 08:58:17 +08:00
|
|
|
if err := config.fromEnv(); err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
|
|
|
|
2016-08-18 06:24:12 +08:00
|
|
|
return Config{config}, nil
|
2015-01-31 09:27:36 +08:00
|
|
|
}
|
|
|
|
|
2017-09-30 08:58:17 +08:00
|
|
|
func (c *config) fromEnv() error {
|
|
|
|
switch c.Getenv("EXPERIMENTAL_USE_OPENJDK9") {
|
2018-06-20 13:49:39 +08:00
|
|
|
case "", "1.8":
|
|
|
|
// Nothing, we always use OpenJDK9
|
2017-09-30 08:58:17 +08:00
|
|
|
case "true":
|
|
|
|
// Use OpenJDK9 and target 1.9
|
|
|
|
c.targetOpenJDK9 = true
|
|
|
|
default:
|
2018-06-20 13:49:39 +08:00
|
|
|
return fmt.Errorf(`Invalid value for EXPERIMENTAL_USE_OPENJDK9, should be "", "1.8", or "true"`)
|
2017-09-30 08:58:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:52:26 +08:00
|
|
|
func (c *config) StopBefore() bootstrap.StopBefore {
|
|
|
|
return c.stopBefore
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) SetStopBefore(stopBefore bootstrap.StopBefore) {
|
|
|
|
c.stopBefore = stopBefore
|
2015-07-09 09:13:11 +08:00
|
|
|
}
|
|
|
|
|
2017-12-12 07:52:26 +08:00
|
|
|
var _ bootstrap.ConfigStopBefore = (*config)(nil)
|
|
|
|
|
2016-05-27 06:13:03 +08:00
|
|
|
func (c *config) BlueprintToolLocation() string {
|
|
|
|
return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin")
|
|
|
|
}
|
|
|
|
|
2017-12-12 07:52:26 +08:00
|
|
|
var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil)
|
|
|
|
|
2017-05-09 05:15:59 +08: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 09:27:36 +08:00
|
|
|
// PrebuiltOS returns the name of the host OS used in prebuilts directories
|
2015-04-08 08:11:30 +08:00
|
|
|
func (c *config) PrebuiltOS() string {
|
2015-01-31 09:27:36 +08: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 08:11:30 +08:00
|
|
|
func (c *config) GoRoot() string {
|
2015-01-31 09:27:36 +08:00
|
|
|
return fmt.Sprintf("%s/prebuilts/go/%s", c.srcDir, c.PrebuiltOS())
|
|
|
|
}
|
|
|
|
|
2015-04-08 08:11:30 +08:00
|
|
|
func (c *config) CpPreserveSymlinksFlags() string {
|
2015-08-28 04:28:01 +08:00
|
|
|
switch runtime.GOOS {
|
2015-01-31 09:27:36 +08:00
|
|
|
case "darwin":
|
|
|
|
return "-R"
|
|
|
|
case "linux":
|
|
|
|
return "-d"
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2015-03-26 05:43:57 +08:00
|
|
|
|
2015-04-08 08:11:30 +08:00
|
|
|
func (c *config) Getenv(key string) string {
|
2015-03-26 05:43:57 +08:00
|
|
|
var val string
|
|
|
|
var exists bool
|
2015-04-16 03:33:28 +08:00
|
|
|
c.envLock.Lock()
|
2017-02-07 07:40:41 +08:00
|
|
|
defer c.envLock.Unlock()
|
|
|
|
if c.envDeps == nil {
|
|
|
|
c.envDeps = make(map[string]string)
|
|
|
|
}
|
2015-03-26 05:43:57 +08:00
|
|
|
if val, exists = c.envDeps[key]; !exists {
|
2015-09-12 08:06:19 +08:00
|
|
|
if c.envFrozen {
|
|
|
|
panic("Cannot access new environment variables after envdeps are frozen")
|
|
|
|
}
|
2017-10-11 14:07:38 +08:00
|
|
|
val, _ = c.env[key]
|
2015-03-26 05:43:57 +08:00
|
|
|
c.envDeps[key] = val
|
|
|
|
}
|
|
|
|
return val
|
|
|
|
}
|
|
|
|
|
2016-11-24 08:52:04 +08: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 08:11:30 +08:00
|
|
|
func (c *config) EnvDeps() map[string]string {
|
2015-09-12 08:06:19 +08:00
|
|
|
c.envLock.Lock()
|
2017-02-07 07:40:41 +08:00
|
|
|
defer c.envLock.Unlock()
|
2015-09-12 08:06:19 +08:00
|
|
|
c.envFrozen = true
|
2015-03-26 05:43:57 +08:00
|
|
|
return c.envDeps
|
|
|
|
}
|
2015-04-03 05:37:16 +08:00
|
|
|
|
2015-12-12 05:51:06 +08:00
|
|
|
func (c *config) EmbeddedInMake() bool {
|
|
|
|
return c.inMake
|
|
|
|
}
|
|
|
|
|
2018-01-11 08:06:12 +08:00
|
|
|
func (c *config) BuildId() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return String(c.productVariables.BuildId)
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) BuildNumberFromFile() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return String(c.productVariables.BuildNumberFromFile)
|
2018-01-11 08:06:12 +08:00
|
|
|
}
|
|
|
|
|
2015-04-03 05:37:16 +08: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 08:11:30 +08:00
|
|
|
func (c *config) DeviceName() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return *c.productVariables.DeviceName
|
2015-04-03 05:37:16 +08:00
|
|
|
}
|
|
|
|
|
2017-11-23 08:19:37 +08:00
|
|
|
func (c *config) ResourceOverlays() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.productVariables.ResourceOverlays == nil {
|
2017-11-23 08:19:37 +08:00
|
|
|
return nil
|
|
|
|
}
|
2018-03-10 13:22:06 +08:00
|
|
|
return *c.productVariables.ResourceOverlays
|
2015-04-14 04:58:27 +08:00
|
|
|
}
|
|
|
|
|
2018-05-10 02:11:35 +08:00
|
|
|
func (c *config) PlatformVersionName() string {
|
|
|
|
return String(c.productVariables.Platform_version_name)
|
|
|
|
}
|
|
|
|
|
2016-11-11 02:46:36 +08:00
|
|
|
func (c *config) PlatformSdkVersionInt() int {
|
2018-03-10 13:22:06 +08:00
|
|
|
return *c.productVariables.Platform_sdk_version
|
2016-11-11 02:46:36 +08:00
|
|
|
}
|
|
|
|
|
2015-04-14 04:58:27 +08:00
|
|
|
func (c *config) PlatformSdkVersion() string {
|
2016-11-11 02:46:36 +08:00
|
|
|
return strconv.Itoa(c.PlatformSdkVersionInt())
|
2015-04-14 04:58:27 +08:00
|
|
|
}
|
|
|
|
|
2018-04-19 02:06:47 +08:00
|
|
|
func (c *config) PlatformSdkCodename() string {
|
|
|
|
return String(c.productVariables.Platform_sdk_codename)
|
|
|
|
}
|
|
|
|
|
2017-08-18 07:19:59 +08:00
|
|
|
func (c *config) MinSupportedSdkVersion() int {
|
2017-08-11 03:18:31 +08:00
|
|
|
return 14
|
2017-08-18 07:19:59 +08:00
|
|
|
}
|
|
|
|
|
2017-09-01 03:30:37 +08:00
|
|
|
func (c *config) DefaultAppTargetSdkInt() int {
|
2018-03-10 13:22:06 +08:00
|
|
|
if Bool(c.productVariables.Platform_sdk_final) {
|
2017-09-01 03:30:37 +08:00
|
|
|
return c.PlatformSdkVersionInt()
|
|
|
|
} else {
|
2018-01-15 14:05:10 +08:00
|
|
|
return FutureApiLevel
|
2017-09-01 03:30:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-19 02:06:47 +08:00
|
|
|
func (c *config) DefaultAppTargetSdk() string {
|
|
|
|
if Bool(c.productVariables.Platform_sdk_final) {
|
|
|
|
return c.PlatformSdkVersion()
|
|
|
|
} else {
|
|
|
|
return c.PlatformSdkCodename()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-23 08:19:37 +08:00
|
|
|
func (c *config) AppsDefaultVersionName() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return String(c.productVariables.AppsDefaultVersionName)
|
2017-11-23 08:19:37 +08:00
|
|
|
}
|
|
|
|
|
2017-07-29 03:39:46 +08:00
|
|
|
// Codenames that are active in the current lunch target.
|
|
|
|
func (c *config) PlatformVersionActiveCodenames() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return c.productVariables.Platform_version_active_codenames
|
2017-07-29 03:39:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Codenames that are available in the branch but not included in the current
|
|
|
|
// lunch target.
|
|
|
|
func (c *config) PlatformVersionFutureCodenames() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return c.productVariables.Platform_version_future_codenames
|
2017-07-29 03:39:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2015-04-14 04:58:27 +08:00
|
|
|
}
|
|
|
|
|
2017-10-31 08:32:15 +08:00
|
|
|
func (c *config) ProductAAPTConfig() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return stringSlice(c.productVariables.AAPTConfig)
|
2015-04-14 04:58:27 +08:00
|
|
|
}
|
|
|
|
|
2017-10-31 08:32:15 +08:00
|
|
|
func (c *config) ProductAAPTPreferredConfig() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return String(c.productVariables.AAPTPreferredConfig)
|
2015-04-14 04:58:27 +08:00
|
|
|
}
|
|
|
|
|
2017-10-31 08:32:15 +08:00
|
|
|
func (c *config) ProductAAPTCharacteristics() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return String(c.productVariables.AAPTCharacteristics)
|
2017-10-31 08:32:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) ProductAAPTPrebuiltDPI() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return stringSlice(c.productVariables.AAPTPrebuiltDPI)
|
2015-04-14 04:58:27 +08:00
|
|
|
}
|
|
|
|
|
2015-09-24 06:26:20 +08:00
|
|
|
func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath {
|
2018-03-10 13:22:06 +08:00
|
|
|
defaultCert := String(c.productVariables.DefaultAppCertificate)
|
2017-12-02 09:16:02 +08:00
|
|
|
if defaultCert != "" {
|
|
|
|
return PathForSource(ctx, filepath.Dir(defaultCert))
|
|
|
|
} else {
|
|
|
|
return PathForSource(ctx, "build/target/product/security")
|
|
|
|
}
|
2015-04-14 04:58:27 +08:00
|
|
|
}
|
|
|
|
|
2017-12-15 03:22:55 +08:00
|
|
|
func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) {
|
2018-03-10 13:22:06 +08:00
|
|
|
defaultCert := String(c.productVariables.DefaultAppCertificate)
|
2017-12-02 09:16:02 +08:00
|
|
|
if defaultCert != "" {
|
2017-12-15 03:22:55 +08:00
|
|
|
return PathForSource(ctx, defaultCert+".x509.pem"), PathForSource(ctx, defaultCert+".pk8")
|
2017-12-02 09:16:02 +08:00
|
|
|
} else {
|
2017-12-15 03:22:55 +08:00
|
|
|
defaultDir := c.DefaultAppCertificateDir(ctx)
|
|
|
|
return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8")
|
2017-12-02 09:16:02 +08:00
|
|
|
}
|
2015-04-14 04:58:27 +08:00
|
|
|
}
|
2015-12-18 08:39:19 +08:00
|
|
|
|
|
|
|
func (c *config) AllowMissingDependencies() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.Allow_missing_dependencies)
|
2015-12-18 08:39:19 +08:00
|
|
|
}
|
2016-01-13 15:07:05 +08:00
|
|
|
|
2017-09-19 08:41:52 +08:00
|
|
|
func (c *config) UnbundledBuild() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.Unbundled_build)
|
2017-09-19 08:41:52 +08:00
|
|
|
}
|
|
|
|
|
2017-10-25 01:51:45 +08:00
|
|
|
func (c *config) IsPdkBuild() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.Pdk)
|
2017-10-25 01:51:45 +08:00
|
|
|
}
|
|
|
|
|
2017-11-01 04:55:34 +08:00
|
|
|
func (c *config) MinimizeJavaDebugInfo() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.MinimizeJavaDebugInfo) && !Bool(c.productVariables.Eng)
|
2017-11-01 04:55:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-06 07:28:13 +08:00
|
|
|
func (c *config) Debuggable() bool {
|
|
|
|
return Bool(c.productVariables.Debuggable)
|
|
|
|
}
|
|
|
|
|
2018-10-02 06:30:23 +08:00
|
|
|
func (c *config) DevicePrefer32BitApps() bool {
|
|
|
|
return Bool(c.productVariables.DevicePrefer32BitApps)
|
|
|
|
}
|
|
|
|
|
2016-08-25 06:25:47 +08:00
|
|
|
func (c *config) DevicePrefer32BitExecutables() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.DevicePrefer32BitExecutables)
|
2016-08-25 06:25:47 +08:00
|
|
|
}
|
|
|
|
|
2018-07-07 17:02:07 +08:00
|
|
|
func (c *config) DevicePrimaryArchType() ArchType {
|
|
|
|
return c.Targets[Device][0].Arch.ArchType
|
|
|
|
}
|
|
|
|
|
2016-01-15 03:22:23 +08:00
|
|
|
func (c *config) SkipDeviceInstall() bool {
|
2017-04-27 08:34:03 +08: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 15:07:05 +08:00
|
|
|
}
|
2016-01-07 06:41:07 +08:00
|
|
|
|
|
|
|
func (c *config) SanitizeHost() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return append([]string(nil), c.productVariables.SanitizeHost...)
|
2016-01-07 06:41:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) SanitizeDevice() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return append([]string(nil), c.productVariables.SanitizeDevice...)
|
2016-11-03 05:34:39 +08:00
|
|
|
}
|
|
|
|
|
2017-06-29 00:10:48 +08:00
|
|
|
func (c *config) SanitizeDeviceDiag() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return append([]string(nil), c.productVariables.SanitizeDeviceDiag...)
|
2017-06-29 00:10:48 +08:00
|
|
|
}
|
|
|
|
|
2016-11-03 05:34:39 +08:00
|
|
|
func (c *config) SanitizeDeviceArch() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return append([]string(nil), c.productVariables.SanitizeDeviceArch...)
|
2016-01-07 06:41:07 +08:00
|
|
|
}
|
2016-06-02 08:09:44 +08:00
|
|
|
|
2017-01-20 05:54:55 +08:00
|
|
|
func (c *config) EnableCFI() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.productVariables.EnableCFI == nil {
|
2017-01-25 06:20:54 +08:00
|
|
|
return true
|
|
|
|
} else {
|
2018-03-10 13:22:06 +08:00
|
|
|
return *c.productVariables.EnableCFI
|
2017-01-25 06:20:54 +08:00
|
|
|
}
|
2017-01-20 05:54:55 +08:00
|
|
|
}
|
|
|
|
|
2016-06-02 08:09:44 +08: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 06:24:12 +08:00
|
|
|
|
2016-08-30 07:14:13 +08:00
|
|
|
func (c *config) UseGoma() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.UseGoma)
|
2016-08-30 07:14:13 +08:00
|
|
|
}
|
|
|
|
|
2018-06-20 13:47:35 +08:00
|
|
|
func (c *config) RunErrorProne() bool {
|
|
|
|
return c.IsEnvTrue("RUN_ERROR_PRONE")
|
|
|
|
}
|
|
|
|
|
2017-09-30 08:58:17 +08:00
|
|
|
// Returns true if -source 1.9 -target 1.9 is being passed to javac
|
|
|
|
func (c *config) TargetOpenJDK9() bool {
|
|
|
|
return c.targetOpenJDK9
|
|
|
|
}
|
|
|
|
|
2018-04-04 02:33:34 +08:00
|
|
|
func (c *config) UseClangLld() bool {
|
|
|
|
return Bool(c.productVariables.UseClangLld)
|
|
|
|
}
|
|
|
|
|
2016-09-27 06:45:04 +08:00
|
|
|
func (c *config) ClangTidy() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.ClangTidy)
|
2016-09-27 06:45:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) TidyChecks() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.productVariables.TidyChecks == nil {
|
2016-09-27 06:45:04 +08:00
|
|
|
return ""
|
|
|
|
}
|
2018-03-10 13:22:06 +08:00
|
|
|
return *c.productVariables.TidyChecks
|
2016-09-27 06:45:04 +08:00
|
|
|
}
|
|
|
|
|
2016-07-28 01:56:55 +08:00
|
|
|
func (c *config) LibartImgHostBaseAddress() string {
|
|
|
|
return "0x60000000"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) LibartImgDeviceBaseAddress() string {
|
2018-09-18 15:09:16 +08:00
|
|
|
archType := Common
|
|
|
|
if len(c.Targets[Device]) > 0 {
|
|
|
|
archType = c.Targets[Device][0].Arch.ArchType
|
|
|
|
}
|
|
|
|
switch archType {
|
|
|
|
default:
|
|
|
|
return "0x70000000"
|
|
|
|
case Mips, Mips64:
|
|
|
|
return "0x5C000000"
|
|
|
|
}
|
2016-07-28 01:56:55 +08:00
|
|
|
}
|
|
|
|
|
2016-12-20 05:44:41 +08:00
|
|
|
func (c *config) ArtUseReadBarrier() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.ArtUseReadBarrier)
|
2016-12-20 05:44:41 +08:00
|
|
|
}
|
|
|
|
|
2018-03-13 06:30:26 +08:00
|
|
|
func (c *config) EnforceRROForModule(name string) bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
enforceList := c.productVariables.EnforceRROTargets
|
2018-03-13 06:30:26 +08:00
|
|
|
if enforceList != nil {
|
|
|
|
if len(*enforceList) == 1 && (*enforceList)[0] == "*" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return InList(name, *enforceList)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) EnforceRROExcludedOverlay(path string) bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
excluded := c.productVariables.EnforceRROExcludedOverlays
|
2018-03-13 06:30:26 +08:00
|
|
|
if excluded != nil {
|
|
|
|
for _, exclude := range *excluded {
|
|
|
|
if strings.HasPrefix(path, exclude) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) ExportedNamespaces() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return append([]string(nil), c.productVariables.NamespacesToExport...)
|
2018-03-13 06:30:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) HostStaticBinaries() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.productVariables.HostStaticBinaries)
|
2018-03-13 06:30:26 +08:00
|
|
|
}
|
|
|
|
|
2016-08-18 06:24:12 +08: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-19 06:54:24 +08:00
|
|
|
|
2018-03-09 03:00:50 +08:00
|
|
|
func (c *deviceConfig) BinderBitness() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
is32BitBinder := c.config.productVariables.Binder32bit
|
2018-03-09 03:00:50 +08:00
|
|
|
if is32BitBinder != nil && *is32BitBinder {
|
|
|
|
return "32"
|
|
|
|
}
|
|
|
|
return "64"
|
|
|
|
}
|
|
|
|
|
2016-12-06 09:16:02 +08:00
|
|
|
func (c *deviceConfig) VendorPath() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.config.productVariables.VendorPath != nil {
|
|
|
|
return *c.config.productVariables.VendorPath
|
2016-12-06 09:16:02 +08:00
|
|
|
}
|
|
|
|
return "vendor"
|
|
|
|
}
|
|
|
|
|
Install VNDK snapshot libraries for system build
When BOARD_VNDK_VERSION := <VNDK version>, or
PRODUCT_EXTRA_VNDK_VERSIONS includes the needed <VNDK version> list,
the prebuilt VNDK libs in prebuilts/vndk/ directory will be
installed.
Each prebuilt VNDK module uses "vndk_prebuilt_shared" for shared
VNDK/VNDK-SP libs.
Following is the sample configuration of a vndk snapshot module:
vndk_prebuilt_shared {
name: "libfoo",
version: "27",
vendor_available: true,
vndk: {
enabled: true,
},
arch: {
arm64: {
srcs: ["arm/lib64/libfoo.so"],
},
arm: {
srcs: ["arm/lib/libfoo.so"],
},
},
}
The Android.bp for the snapshot modules will be auto-generated by a
script.
Bug: 38304393
Bug: 65377115
Bug: 68123344
Test: set BOARD_VNDK_VERSION := 27
copy a snapshot for v27
build with make command
Change-Id: Ib93107530dbabb4a24583f4d6e4f0c513c9adfec
2017-11-17 11:10:28 +08:00
|
|
|
func (c *deviceConfig) VndkVersion() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return String(c.config.productVariables.DeviceVndkVersion)
|
Install VNDK snapshot libraries for system build
When BOARD_VNDK_VERSION := <VNDK version>, or
PRODUCT_EXTRA_VNDK_VERSIONS includes the needed <VNDK version> list,
the prebuilt VNDK libs in prebuilts/vndk/ directory will be
installed.
Each prebuilt VNDK module uses "vndk_prebuilt_shared" for shared
VNDK/VNDK-SP libs.
Following is the sample configuration of a vndk snapshot module:
vndk_prebuilt_shared {
name: "libfoo",
version: "27",
vendor_available: true,
vndk: {
enabled: true,
},
arch: {
arm64: {
srcs: ["arm/lib64/libfoo.so"],
},
arm: {
srcs: ["arm/lib/libfoo.so"],
},
},
}
The Android.bp for the snapshot modules will be auto-generated by a
script.
Bug: 38304393
Bug: 65377115
Bug: 68123344
Test: set BOARD_VNDK_VERSION := 27
copy a snapshot for v27
build with make command
Change-Id: Ib93107530dbabb4a24583f4d6e4f0c513c9adfec
2017-11-17 11:10:28 +08:00
|
|
|
}
|
|
|
|
|
2017-12-07 16:18:15 +08:00
|
|
|
func (c *deviceConfig) PlatformVndkVersion() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return String(c.config.productVariables.Platform_vndk_version)
|
2017-12-07 16:18:15 +08:00
|
|
|
}
|
|
|
|
|
Install VNDK snapshot libraries for system build
When BOARD_VNDK_VERSION := <VNDK version>, or
PRODUCT_EXTRA_VNDK_VERSIONS includes the needed <VNDK version> list,
the prebuilt VNDK libs in prebuilts/vndk/ directory will be
installed.
Each prebuilt VNDK module uses "vndk_prebuilt_shared" for shared
VNDK/VNDK-SP libs.
Following is the sample configuration of a vndk snapshot module:
vndk_prebuilt_shared {
name: "libfoo",
version: "27",
vendor_available: true,
vndk: {
enabled: true,
},
arch: {
arm64: {
srcs: ["arm/lib64/libfoo.so"],
},
arm: {
srcs: ["arm/lib/libfoo.so"],
},
},
}
The Android.bp for the snapshot modules will be auto-generated by a
script.
Bug: 38304393
Bug: 65377115
Bug: 68123344
Test: set BOARD_VNDK_VERSION := 27
copy a snapshot for v27
build with make command
Change-Id: Ib93107530dbabb4a24583f4d6e4f0c513c9adfec
2017-11-17 11:10:28 +08:00
|
|
|
func (c *deviceConfig) ExtraVndkVersions() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return c.config.productVariables.ExtraVndkVersions
|
2016-11-19 06:54:24 +08:00
|
|
|
}
|
2016-12-09 07:45:07 +08:00
|
|
|
|
2018-01-15 14:05:10 +08:00
|
|
|
func (c *deviceConfig) SystemSdkVersions() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.config.productVariables.DeviceSystemSdkVersions == nil {
|
2018-01-15 14:05:10 +08:00
|
|
|
return nil
|
|
|
|
}
|
2018-03-10 13:22:06 +08:00
|
|
|
return *c.config.productVariables.DeviceSystemSdkVersions
|
2018-01-15 14:05:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) PlatformSystemSdkVersions() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return c.config.productVariables.Platform_systemsdk_versions
|
2018-01-15 14:05:10 +08:00
|
|
|
}
|
|
|
|
|
2017-11-08 15:03:48 +08:00
|
|
|
func (c *deviceConfig) OdmPath() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.config.productVariables.OdmPath != nil {
|
|
|
|
return *c.config.productVariables.OdmPath
|
2017-11-08 15:03:48 +08:00
|
|
|
}
|
|
|
|
return "odm"
|
|
|
|
}
|
|
|
|
|
2018-01-10 18:00:15 +08:00
|
|
|
func (c *deviceConfig) ProductPath() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.config.productVariables.ProductPath != nil {
|
|
|
|
return *c.config.productVariables.ProductPath
|
2017-11-08 15:03:48 +08:00
|
|
|
}
|
2018-01-10 18:00:15 +08:00
|
|
|
return "product"
|
2017-11-08 15:03:48 +08:00
|
|
|
}
|
|
|
|
|
2018-05-29 20:28:54 +08:00
|
|
|
func (c *deviceConfig) ProductServicesPath() string {
|
|
|
|
if c.config.productVariables.ProductServicesPath != nil {
|
|
|
|
return *c.config.productVariables.ProductServicesPath
|
|
|
|
}
|
2018-08-17 07:57:57 +08:00
|
|
|
return "product_services"
|
2018-05-29 20:28:54 +08:00
|
|
|
}
|
|
|
|
|
2016-12-09 07:45:07 +08:00
|
|
|
func (c *deviceConfig) BtConfigIncludeDir() string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return String(c.config.productVariables.BtConfigIncludeDir)
|
2016-12-09 07:45:07 +08:00
|
|
|
}
|
2017-02-10 08:16:31 +08:00
|
|
|
|
2017-07-03 12:18:12 +08:00
|
|
|
func (c *deviceConfig) DeviceKernelHeaderDirs() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return c.config.productVariables.DeviceKernelHeaders
|
2017-07-03 12:18:12 +08:00
|
|
|
}
|
|
|
|
|
2017-02-10 08:16:31 +08:00
|
|
|
func (c *deviceConfig) NativeCoverageEnabled() bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
return Bool(c.config.productVariables.NativeCoverage)
|
2017-02-10 08:16:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
|
2017-02-28 01:01:54 +08:00
|
|
|
coverage := false
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.config.productVariables.CoveragePaths != nil {
|
|
|
|
if PrefixInList(path, *c.config.productVariables.CoveragePaths) {
|
2017-07-14 05:46:05 +08:00
|
|
|
coverage = true
|
2017-02-10 08:16:31 +08:00
|
|
|
}
|
|
|
|
}
|
2018-03-10 13:22:06 +08:00
|
|
|
if coverage && c.config.productVariables.CoverageExcludePaths != nil {
|
|
|
|
if PrefixInList(path, *c.config.productVariables.CoverageExcludePaths) {
|
2017-07-14 05:46:05 +08:00
|
|
|
coverage = false
|
2017-02-28 01:01:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return coverage
|
2017-02-10 08:16:31 +08:00
|
|
|
}
|
2017-07-14 05:46:05 +08:00
|
|
|
|
2018-01-30 15:11:42 +08:00
|
|
|
func (c *deviceConfig) PgoAdditionalProfileDirs() []string {
|
2018-03-10 13:22:06 +08:00
|
|
|
return c.config.productVariables.PgoAdditionalProfileDirs
|
2018-01-30 15:11:42 +08:00
|
|
|
}
|
|
|
|
|
2018-03-26 11:00:00 +08:00
|
|
|
func (c *deviceConfig) VendorSepolicyDirs() []string {
|
|
|
|
return c.config.productVariables.BoardVendorSepolicyDirs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) OdmSepolicyDirs() []string {
|
|
|
|
return c.config.productVariables.BoardOdmSepolicyDirs
|
|
|
|
}
|
|
|
|
|
2018-05-21 05:34:48 +08:00
|
|
|
func (c *deviceConfig) PlatPublicSepolicyDirs() []string {
|
|
|
|
return c.config.productVariables.BoardPlatPublicSepolicyDirs
|
2018-03-26 11:00:00 +08:00
|
|
|
}
|
|
|
|
|
2018-05-21 05:34:48 +08:00
|
|
|
func (c *deviceConfig) PlatPrivateSepolicyDirs() []string {
|
|
|
|
return c.config.productVariables.BoardPlatPrivateSepolicyDirs
|
2018-03-26 11:00:00 +08:00
|
|
|
}
|
|
|
|
|
2017-07-14 05:46:05 +08:00
|
|
|
func (c *config) IntegerOverflowDisabledForPath(path string) bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.productVariables.IntegerOverflowExcludePaths == nil {
|
2017-07-14 05:46:05 +08:00
|
|
|
return false
|
|
|
|
}
|
2018-03-10 13:22:06 +08:00
|
|
|
return PrefixInList(path, *c.productVariables.IntegerOverflowExcludePaths)
|
2017-07-14 05:46:05 +08:00
|
|
|
}
|
2017-10-31 17:26:14 +08:00
|
|
|
|
|
|
|
func (c *config) CFIDisabledForPath(path string) bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.productVariables.CFIExcludePaths == nil {
|
2017-10-31 17:26:14 +08:00
|
|
|
return false
|
|
|
|
}
|
2018-03-10 13:22:06 +08:00
|
|
|
return PrefixInList(path, *c.productVariables.CFIExcludePaths)
|
2017-10-31 17:26:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) CFIEnabledForPath(path string) bool {
|
2018-03-10 13:22:06 +08:00
|
|
|
if c.productVariables.CFIIncludePaths == nil {
|
2017-10-31 17:26:14 +08:00
|
|
|
return false
|
|
|
|
}
|
2018-03-10 13:22:06 +08:00
|
|
|
return PrefixInList(path, *c.productVariables.CFIIncludePaths)
|
2017-10-31 17:26:14 +08:00
|
|
|
}
|
2017-12-05 03:24:31 +08:00
|
|
|
|
2018-03-27 03:41:18 +08:00
|
|
|
func (c *config) VendorConfig(name string) VendorConfig {
|
|
|
|
return vendorConfig(c.productVariables.VendorVars[name])
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c vendorConfig) Bool(name string) bool {
|
|
|
|
v := strings.ToLower(c[name])
|
|
|
|
return v == "1" || v == "y" || v == "yes" || v == "on" || v == "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c vendorConfig) String(name string) string {
|
|
|
|
return c[name]
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c vendorConfig) IsSet(name string) bool {
|
|
|
|
_, ok := c[name]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2017-12-05 03:24:31 +08:00
|
|
|
func stringSlice(s *[]string) []string {
|
|
|
|
if s != nil {
|
|
|
|
return *s
|
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|