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
|
|
|
|
2017-12-12 00:52:26 +01:00
|
|
|
"github.com/google/blueprint/bootstrap"
|
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
|
2018-01-15 07:05:10 +01:00
|
|
|
var FutureApiLevel = 10000
|
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
|
|
|
|
}
|
|
|
|
|
2018-03-26 21:41:18 +02: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 02:11:30 +02:00
|
|
|
type config struct {
|
2015-01-31 02:27:36 +01:00
|
|
|
FileConfigurableOptions
|
2018-03-10 06:22:06 +01:00
|
|
|
productVariables productVariables
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-03-13 02:06:05 +01:00
|
|
|
// Only available on configs created by TestConfig
|
|
|
|
TestProductVariables *productVariables
|
|
|
|
|
2017-12-12 00:52:26 +01:00
|
|
|
PrimaryBuilder string
|
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
|
|
|
|
2017-10-11 08:07:38 +02:00
|
|
|
env map[string]string
|
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-09-06 06:56:44 +02: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-13 23:43:27 +02:00
|
|
|
|
2017-09-30 02:58:17 +02:00
|
|
|
useOpenJDK9 bool // Use OpenJDK9, but possibly target 1.8
|
|
|
|
targetOpenJDK9 bool // Use OpenJDK9 and target 1.9
|
|
|
|
|
2017-12-12 00:52:26 +01:00
|
|
|
stopBefore bootstrap.StopBefore
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-03-26 21:41:18 +02:00
|
|
|
type vendorConfig map[string]string
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-03-10 06:22:06 +01: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
|
|
|
|
}
|
2018-02-27 20:26:02 +01:00
|
|
|
} else if err != nil {
|
|
|
|
return fmt.Errorf("config file: could not open %s: %s", filename, err.Error())
|
2015-01-31 02:27:36 +01:00
|
|
|
} 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 {
|
2018-02-27 20:26:02 +01:00
|
|
|
return fmt.Errorf("config file: %s did not parse correctly: %s", filename, err.Error())
|
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
|
2017-10-11 08:07:38 +02:00
|
|
|
func TestConfig(buildDir string, env map[string]string) Config {
|
2017-07-07 01:59:48 +02:00
|
|
|
config := &config{
|
2018-03-10 06:22:06 +01:00
|
|
|
productVariables: productVariables{
|
2017-11-23 01:19:37 +01: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 01:59:48 +02:00
|
|
|
},
|
|
|
|
|
2017-10-11 08:07:38 +02:00
|
|
|
buildDir: buildDir,
|
|
|
|
captureBuild: true,
|
|
|
|
env: env,
|
2017-07-07 01:59:48 +02:00
|
|
|
}
|
|
|
|
config.deviceConfig = &deviceConfig{
|
|
|
|
config: config,
|
|
|
|
}
|
2018-03-10 06:22:06 +01:00
|
|
|
config.TestProductVariables = &config.productVariables
|
2017-07-07 01:59:48 +02:00
|
|
|
|
2017-09-30 02:58:17 +02:00
|
|
|
if err := config.fromEnv(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2017-07-07 01:59:48 +02:00
|
|
|
return Config{config}
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
|
|
|
|
2017-09-16 02:33:55 +02:00
|
|
|
// TestConfig returns a Config object suitable for using for tests that need to run the arch mutator
|
2017-10-11 08:07:38 +02:00
|
|
|
func TestArchConfig(buildDir string, env map[string]string) Config {
|
|
|
|
testConfig := TestConfig(buildDir, env)
|
2017-09-16 02:33:55 +02: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 16:05:00 +02:00
|
|
|
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true}},
|
|
|
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true}},
|
2017-09-16 02:33:55 +02:00
|
|
|
},
|
|
|
|
Host: []Target{
|
|
|
|
{BuildOs, Arch{ArchType: X86_64}},
|
|
|
|
{BuildOs, Arch{ArchType: X86}},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return testConfig
|
|
|
|
}
|
|
|
|
|
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),
|
|
|
|
|
2017-10-11 08:07:38 +02:00
|
|
|
env: originalEnv,
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
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
|
|
|
|
2017-09-30 02:58:17 +02:00
|
|
|
if err := config.fromEnv(); err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
return Config{config}, nil
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2017-09-30 02:58:17 +02:00
|
|
|
func (c *config) fromEnv() error {
|
|
|
|
switch c.Getenv("EXPERIMENTAL_USE_OPENJDK9") {
|
|
|
|
case "":
|
2017-11-17 15:14:29 +01:00
|
|
|
if c.Getenv("RUN_ERROR_PRONE") != "true" {
|
|
|
|
// Use OpenJDK9, but target 1.8
|
|
|
|
c.useOpenJDK9 = true
|
|
|
|
}
|
2017-11-15 22:16:25 +01:00
|
|
|
case "false":
|
|
|
|
// Use OpenJDK8
|
2017-09-30 02:58:17 +02:00
|
|
|
case "1.8":
|
|
|
|
// Use OpenJDK9, but target 1.8
|
|
|
|
c.useOpenJDK9 = true
|
|
|
|
case "true":
|
|
|
|
// Use OpenJDK9 and target 1.9
|
|
|
|
c.useOpenJDK9 = true
|
|
|
|
c.targetOpenJDK9 = true
|
|
|
|
default:
|
2017-11-17 15:14:29 +01:00
|
|
|
return fmt.Errorf(`Invalid value for EXPERIMENTAL_USE_OPENJDK9, should be "", "false", "1.8", or "true"`)
|
2017-09-30 02:58:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-12-12 00:52:26 +01:00
|
|
|
func (c *config) StopBefore() bootstrap.StopBefore {
|
|
|
|
return c.stopBefore
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) SetStopBefore(stopBefore bootstrap.StopBefore) {
|
|
|
|
c.stopBefore = stopBefore
|
2015-07-09 03:13:11 +02:00
|
|
|
}
|
|
|
|
|
2017-12-12 00:52:26 +01:00
|
|
|
var _ bootstrap.ConfigStopBefore = (*config)(nil)
|
|
|
|
|
2016-05-27 00:13:03 +02:00
|
|
|
func (c *config) BlueprintToolLocation() string {
|
|
|
|
return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin")
|
|
|
|
}
|
|
|
|
|
2017-12-12 00:52:26 +01:00
|
|
|
var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil)
|
|
|
|
|
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-10-11 08:07:38 +02:00
|
|
|
val, _ = c.env[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
|
|
|
|
}
|
|
|
|
|
2018-01-11 01:06:12 +01:00
|
|
|
func (c *config) BuildId() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return String(c.productVariables.BuildId)
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) BuildNumberFromFile() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return String(c.productVariables.BuildNumberFromFile)
|
2018-01-11 01:06:12 +01:00
|
|
|
}
|
|
|
|
|
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 {
|
2018-03-10 06:22:06 +01:00
|
|
|
return *c.productVariables.DeviceName
|
2015-04-02 23:37:16 +02:00
|
|
|
}
|
|
|
|
|
2017-11-23 01:19:37 +01:00
|
|
|
func (c *config) ResourceOverlays() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.productVariables.ResourceOverlays == nil {
|
2017-11-23 01:19:37 +01:00
|
|
|
return nil
|
|
|
|
}
|
2018-03-10 06:22:06 +01:00
|
|
|
return *c.productVariables.ResourceOverlays
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2016-11-10 19:46:36 +01:00
|
|
|
func (c *config) PlatformSdkVersionInt() int {
|
2018-03-10 06:22:06 +01:00
|
|
|
return *c.productVariables.Platform_sdk_version
|
2016-11-10 19:46:36 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-04-18 20:06:47 +02:00
|
|
|
func (c *config) PlatformSdkCodename() string {
|
|
|
|
return String(c.productVariables.Platform_sdk_codename)
|
|
|
|
}
|
|
|
|
|
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-08-31 21:30:37 +02:00
|
|
|
func (c *config) DefaultAppTargetSdkInt() int {
|
2018-03-10 06:22:06 +01:00
|
|
|
if Bool(c.productVariables.Platform_sdk_final) {
|
2017-08-31 21:30:37 +02:00
|
|
|
return c.PlatformSdkVersionInt()
|
|
|
|
} else {
|
2018-01-15 07:05:10 +01:00
|
|
|
return FutureApiLevel
|
2017-08-31 21:30:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-18 20:06:47 +02:00
|
|
|
func (c *config) DefaultAppTargetSdk() string {
|
|
|
|
if Bool(c.productVariables.Platform_sdk_final) {
|
|
|
|
return c.PlatformSdkVersion()
|
|
|
|
} else {
|
|
|
|
return c.PlatformSdkCodename()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-23 01:19:37 +01:00
|
|
|
func (c *config) AppsDefaultVersionName() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return String(c.productVariables.AppsDefaultVersionName)
|
2017-11-23 01:19:37 +01:00
|
|
|
}
|
|
|
|
|
2017-07-28 21:39:46 +02:00
|
|
|
// Codenames that are active in the current lunch target.
|
|
|
|
func (c *config) PlatformVersionActiveCodenames() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return c.productVariables.Platform_version_active_codenames
|
2017-07-28 21:39:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Codenames that are available in the branch but not included in the current
|
|
|
|
// lunch target.
|
|
|
|
func (c *config) PlatformVersionFutureCodenames() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return c.productVariables.Platform_version_future_codenames
|
2017-07-28 21:39:46 +02: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-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2017-10-31 01:32:15 +01:00
|
|
|
func (c *config) ProductAAPTConfig() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return stringSlice(c.productVariables.AAPTConfig)
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2017-10-31 01:32:15 +01:00
|
|
|
func (c *config) ProductAAPTPreferredConfig() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return String(c.productVariables.AAPTPreferredConfig)
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2017-10-31 01:32:15 +01:00
|
|
|
func (c *config) ProductAAPTCharacteristics() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return String(c.productVariables.AAPTCharacteristics)
|
2017-10-31 01:32:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) ProductAAPTPrebuiltDPI() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return stringSlice(c.productVariables.AAPTPrebuiltDPI)
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2015-09-24 00:26:20 +02:00
|
|
|
func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath {
|
2018-03-10 06:22:06 +01:00
|
|
|
defaultCert := String(c.productVariables.DefaultAppCertificate)
|
2017-12-02 02:16:02 +01:00
|
|
|
if defaultCert != "" {
|
|
|
|
return PathForSource(ctx, filepath.Dir(defaultCert))
|
|
|
|
} else {
|
|
|
|
return PathForSource(ctx, "build/target/product/security")
|
|
|
|
}
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2017-12-14 20:22:55 +01:00
|
|
|
func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) {
|
2018-03-10 06:22:06 +01:00
|
|
|
defaultCert := String(c.productVariables.DefaultAppCertificate)
|
2017-12-02 02:16:02 +01:00
|
|
|
if defaultCert != "" {
|
2017-12-14 20:22:55 +01:00
|
|
|
return PathForSource(ctx, defaultCert+".x509.pem"), PathForSource(ctx, defaultCert+".pk8")
|
2017-12-02 02:16:02 +01:00
|
|
|
} else {
|
2017-12-14 20:22:55 +01:00
|
|
|
defaultDir := c.DefaultAppCertificateDir(ctx)
|
|
|
|
return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8")
|
2017-12-02 02:16:02 +01:00
|
|
|
}
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
2015-12-18 01:39:19 +01:00
|
|
|
|
|
|
|
func (c *config) AllowMissingDependencies() bool {
|
2018-03-10 06:22:06 +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
|
|
|
|
2017-09-19 02:41:52 +02:00
|
|
|
func (c *config) UnbundledBuild() bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.productVariables.Unbundled_build)
|
2017-09-19 02:41:52 +02:00
|
|
|
}
|
|
|
|
|
2017-10-24 19:51:45 +02:00
|
|
|
func (c *config) IsPdkBuild() bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.productVariables.Pdk)
|
2017-10-24 19:51:45 +02:00
|
|
|
}
|
|
|
|
|
2017-10-31 21:55:34 +01:00
|
|
|
func (c *config) MinimizeJavaDebugInfo() bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.productVariables.MinimizeJavaDebugInfo) && !Bool(c.productVariables.Eng)
|
2017-10-31 21:55:34 +01:00
|
|
|
}
|
|
|
|
|
2016-08-25 00:25:47 +02:00
|
|
|
func (c *config) DevicePrefer32BitExecutables() bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.productVariables.DevicePrefer32BitExecutables)
|
2016-08-25 00:25:47 +02:00
|
|
|
}
|
|
|
|
|
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 {
|
2018-03-10 06:22:06 +01:00
|
|
|
return append([]string(nil), c.productVariables.SanitizeHost...)
|
2016-01-06 23:41:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) SanitizeDevice() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return append([]string(nil), c.productVariables.SanitizeDevice...)
|
2016-11-02 22:34:39 +01:00
|
|
|
}
|
|
|
|
|
2017-06-28 18:10:48 +02:00
|
|
|
func (c *config) SanitizeDeviceDiag() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return append([]string(nil), c.productVariables.SanitizeDeviceDiag...)
|
2017-06-28 18:10:48 +02:00
|
|
|
}
|
|
|
|
|
2016-11-02 22:34:39 +01:00
|
|
|
func (c *config) SanitizeDeviceArch() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
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 {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.productVariables.EnableCFI == nil {
|
2017-01-24 23:20:54 +01:00
|
|
|
return true
|
|
|
|
} else {
|
2018-03-10 06:22:06 +01:00
|
|
|
return *c.productVariables.EnableCFI
|
2017-01-24 23:20:54 +01:00
|
|
|
}
|
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
|
|
|
|
2017-12-13 09:28:49 +01:00
|
|
|
func (c *config) UseD8Desugar() bool {
|
2017-12-20 10:15:56 +01:00
|
|
|
return !c.IsEnvFalse("USE_D8_DESUGAR")
|
2017-12-13 09:28:49 +01:00
|
|
|
}
|
|
|
|
|
2016-08-30 01:14:13 +02:00
|
|
|
func (c *config) UseGoma() bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.productVariables.UseGoma)
|
2016-08-30 01:14:13 +02:00
|
|
|
}
|
|
|
|
|
2017-09-30 02:58:17 +02:00
|
|
|
// Returns true if OpenJDK9 prebuilts are being used
|
|
|
|
func (c *config) UseOpenJDK9() bool {
|
|
|
|
return c.useOpenJDK9
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns true if -source 1.9 -target 1.9 is being passed to javac
|
|
|
|
func (c *config) TargetOpenJDK9() bool {
|
|
|
|
return c.targetOpenJDK9
|
|
|
|
}
|
|
|
|
|
2018-04-03 20:33:34 +02:00
|
|
|
func (c *config) UseClangLld() bool {
|
|
|
|
return Bool(c.productVariables.UseClangLld)
|
|
|
|
}
|
|
|
|
|
2016-09-27 00:45:04 +02:00
|
|
|
func (c *config) ClangTidy() bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.productVariables.ClangTidy)
|
2016-09-27 00:45:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) TidyChecks() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.productVariables.TidyChecks == nil {
|
2016-09-27 00:45:04 +02:00
|
|
|
return ""
|
|
|
|
}
|
2018-03-10 06:22:06 +01:00
|
|
|
return *c.productVariables.TidyChecks
|
2016-09-27 00:45:04 +02:00
|
|
|
}
|
|
|
|
|
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 {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.productVariables.ArtUseReadBarrier)
|
2016-12-19 22:44:41 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 23:30:26 +01:00
|
|
|
func (c *config) EnforceRROForModule(name string) bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
enforceList := c.productVariables.EnforceRROTargets
|
2018-03-12 23:30:26 +01: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 06:22:06 +01:00
|
|
|
excluded := c.productVariables.EnforceRROExcludedOverlays
|
2018-03-12 23:30:26 +01: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 06:22:06 +01:00
|
|
|
return append([]string(nil), c.productVariables.NamespacesToExport...)
|
2018-03-12 23:30:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) HostStaticBinaries() bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.productVariables.HostStaticBinaries)
|
2018-03-12 23:30:26 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2018-03-08 20:00:50 +01:00
|
|
|
func (c *deviceConfig) BinderBitness() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
is32BitBinder := c.config.productVariables.Binder32bit
|
2018-03-08 20:00:50 +01:00
|
|
|
if is32BitBinder != nil && *is32BitBinder {
|
|
|
|
return "32"
|
|
|
|
}
|
|
|
|
return "64"
|
|
|
|
}
|
|
|
|
|
2016-12-06 02:16:02 +01:00
|
|
|
func (c *deviceConfig) VendorPath() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.config.productVariables.VendorPath != nil {
|
|
|
|
return *c.config.productVariables.VendorPath
|
2016-12-06 02:16:02 +01: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 04:10:28 +01:00
|
|
|
func (c *deviceConfig) VndkVersion() string {
|
2018-03-10 06:22:06 +01: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 04:10:28 +01:00
|
|
|
}
|
|
|
|
|
2017-12-07 09:18:15 +01:00
|
|
|
func (c *deviceConfig) PlatformVndkVersion() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return String(c.config.productVariables.Platform_vndk_version)
|
2017-12-07 09:18:15 +01: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 04:10:28 +01:00
|
|
|
func (c *deviceConfig) ExtraVndkVersions() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return c.config.productVariables.ExtraVndkVersions
|
2016-11-18 23:54:24 +01:00
|
|
|
}
|
2016-12-09 00:45:07 +01:00
|
|
|
|
2018-01-15 07:05:10 +01:00
|
|
|
func (c *deviceConfig) SystemSdkVersions() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.config.productVariables.DeviceSystemSdkVersions == nil {
|
2018-01-15 07:05:10 +01:00
|
|
|
return nil
|
|
|
|
}
|
2018-03-10 06:22:06 +01:00
|
|
|
return *c.config.productVariables.DeviceSystemSdkVersions
|
2018-01-15 07:05:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) PlatformSystemSdkVersions() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return c.config.productVariables.Platform_systemsdk_versions
|
2018-01-15 07:05:10 +01:00
|
|
|
}
|
|
|
|
|
2017-11-08 08:03:48 +01:00
|
|
|
func (c *deviceConfig) OdmPath() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.config.productVariables.OdmPath != nil {
|
|
|
|
return *c.config.productVariables.OdmPath
|
2017-11-08 08:03:48 +01:00
|
|
|
}
|
|
|
|
return "odm"
|
|
|
|
}
|
|
|
|
|
2018-01-10 11:00:15 +01:00
|
|
|
func (c *deviceConfig) ProductPath() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.config.productVariables.ProductPath != nil {
|
|
|
|
return *c.config.productVariables.ProductPath
|
2017-11-08 08:03:48 +01:00
|
|
|
}
|
2018-01-10 11:00:15 +01:00
|
|
|
return "product"
|
2017-11-08 08:03:48 +01:00
|
|
|
}
|
|
|
|
|
2016-12-09 00:45:07 +01:00
|
|
|
func (c *deviceConfig) BtConfigIncludeDir() string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return String(c.config.productVariables.BtConfigIncludeDir)
|
2016-12-09 00:45:07 +01:00
|
|
|
}
|
2017-02-10 01:16:31 +01:00
|
|
|
|
2017-07-03 06:18:12 +02:00
|
|
|
func (c *deviceConfig) DeviceKernelHeaderDirs() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return c.config.productVariables.DeviceKernelHeaders
|
2017-07-03 06:18:12 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 01:16:31 +01:00
|
|
|
func (c *deviceConfig) NativeCoverageEnabled() bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
return Bool(c.config.productVariables.NativeCoverage)
|
2017-02-10 01:16:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
|
2017-02-27 18:01:54 +01:00
|
|
|
coverage := false
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.config.productVariables.CoveragePaths != nil {
|
|
|
|
if PrefixInList(path, *c.config.productVariables.CoveragePaths) {
|
2017-07-13 23:46:05 +02:00
|
|
|
coverage = true
|
2017-02-10 01:16:31 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-10 06:22:06 +01:00
|
|
|
if coverage && c.config.productVariables.CoverageExcludePaths != nil {
|
|
|
|
if PrefixInList(path, *c.config.productVariables.CoverageExcludePaths) {
|
2017-07-13 23:46:05 +02:00
|
|
|
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
|
|
|
|
2018-01-30 08:11:42 +01:00
|
|
|
func (c *deviceConfig) PgoAdditionalProfileDirs() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return c.config.productVariables.PgoAdditionalProfileDirs
|
2018-01-30 08:11:42 +01:00
|
|
|
}
|
|
|
|
|
2018-03-26 05:00:00 +02:00
|
|
|
func (c *deviceConfig) VendorSepolicyDirs() []string {
|
|
|
|
return c.config.productVariables.BoardVendorSepolicyDirs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) OdmSepolicyDirs() []string {
|
|
|
|
return c.config.productVariables.BoardOdmSepolicyDirs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) PlatPublicSepolicyDir() string {
|
|
|
|
return c.config.productVariables.BoardPlatPublicSepolicyDir
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) PlatPrivateSepolicyDir() string {
|
|
|
|
return c.config.productVariables.BoardPlatPrivateSepolicyDir
|
|
|
|
}
|
|
|
|
|
2017-07-13 23:46:05 +02:00
|
|
|
func (c *config) IntegerOverflowDisabledForPath(path string) bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.productVariables.IntegerOverflowExcludePaths == nil {
|
2017-07-13 23:46:05 +02:00
|
|
|
return false
|
|
|
|
}
|
2018-03-10 06:22:06 +01:00
|
|
|
return PrefixInList(path, *c.productVariables.IntegerOverflowExcludePaths)
|
2017-07-13 23:46:05 +02:00
|
|
|
}
|
2017-10-31 10:26:14 +01:00
|
|
|
|
|
|
|
func (c *config) CFIDisabledForPath(path string) bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.productVariables.CFIExcludePaths == nil {
|
2017-10-31 10:26:14 +01:00
|
|
|
return false
|
|
|
|
}
|
2018-03-10 06:22:06 +01:00
|
|
|
return PrefixInList(path, *c.productVariables.CFIExcludePaths)
|
2017-10-31 10:26:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) CFIEnabledForPath(path string) bool {
|
2018-03-10 06:22:06 +01:00
|
|
|
if c.productVariables.CFIIncludePaths == nil {
|
2017-10-31 10:26:14 +01:00
|
|
|
return false
|
|
|
|
}
|
2018-03-10 06:22:06 +01:00
|
|
|
return PrefixInList(path, *c.productVariables.CFIIncludePaths)
|
2017-10-31 10:26:14 +01:00
|
|
|
}
|
2017-12-04 20:24:31 +01:00
|
|
|
|
2018-03-26 21:41:18 +02: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-04 20:24:31 +01:00
|
|
|
func stringSlice(s *[]string) []string {
|
|
|
|
if s != nil {
|
|
|
|
return *s
|
|
|
|
} else {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|