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-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
2019-10-16 20:03:10 +02:00
Targets map [ OsType ] [ ] Target
BuildOSTarget Target // the Target for tools run on the build machine
BuildOSCommonTarget Target // the Target for common (java) tools run on the build machine
AndroidCommonTarget Target // the Target for common modules for the Android device
2015-07-09 03:13:11 +02:00
2019-09-17 23:45:31 +02:00
// multilibConflicts for an ArchType is true if there is earlier configured device architecture with the same
// multilib value.
multilibConflicts map [ ArchType ] bool
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-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 {
2019-04-23 00:51:26 +02:00
envCopy := make ( map [ string ] string )
for k , v := range env {
envCopy [ k ] = v
}
// Copy the real PATH value to the test environment, it's needed by HostSystemTool() used in x86_darwin_host.go
envCopy [ "PATH" ] = originalEnv [ "PATH" ]
2017-07-07 01:59:48 +02:00
config := & config {
2018-03-10 06:22:06 +01:00
productVariables : productVariables {
2019-04-03 01:10:56 +02:00
DeviceName : stringPtr ( "test_device" ) ,
2019-10-28 16:05:02 +01:00
Platform_sdk_version : intPtr ( 30 ) ,
2019-04-03 01:10:56 +02:00
DeviceSystemSdkVersions : [ ] string { "14" , "15" } ,
2019-10-28 16:05:02 +01:00
Platform_systemsdk_versions : [ ] string { "29" , "30" } ,
2019-04-03 01:10:56 +02:00
AAPTConfig : [ ] string { "normal" , "large" , "xlarge" , "hdpi" , "xhdpi" , "xxhdpi" } ,
AAPTPreferredConfig : stringPtr ( "xhdpi" ) ,
AAPTCharacteristics : stringPtr ( "nosdcard" ) ,
AAPTPrebuiltDPI : [ ] string { "xhdpi" , "xxhdpi" } ,
2019-06-25 22:35:30 +02:00
UncompressPrivAppDex : boolPtr ( true ) ,
2017-07-07 01:59:48 +02:00
} ,
2017-10-11 08:07:38 +02:00
buildDir : buildDir ,
captureBuild : true ,
2019-04-23 00:51:26 +02:00
env : envCopy ,
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
}
2019-03-26 12:39:31 +01:00
func TestArchConfigNativeBridge ( buildDir string , env map [ string ] string ) Config {
2019-05-15 01:01:24 +02:00
testConfig := TestArchConfig ( buildDir , env )
2019-03-26 12:39:31 +01:00
config := testConfig . config
2019-05-15 01:01:24 +02:00
config . Targets [ Android ] = [ ] Target {
2019-09-17 23:45:31 +02:00
{ Android , Arch { ArchType : X86_64 , ArchVariant : "silvermont" , Abi : [ ] string { "arm64-v8a" } } , NativeBridgeDisabled , "" , "" } ,
{ Android , Arch { ArchType : X86 , ArchVariant : "silvermont" , Abi : [ ] string { "armeabi-v7a" } } , NativeBridgeDisabled , "" , "" } ,
{ Android , Arch { ArchType : Arm64 , ArchVariant : "armv8-a" , Abi : [ ] string { "arm64-v8a" } } , NativeBridgeEnabled , "x86_64" , "arm64" } ,
{ Android , Arch { ArchType : Arm , ArchVariant : "armv7-a-neon" , Abi : [ ] string { "armeabi-v7a" } } , NativeBridgeEnabled , "x86" , "arm" } ,
2019-03-26 12:39:31 +01:00
}
return testConfig
}
2019-01-17 23:44:05 +01:00
func TestArchConfigFuchsia ( buildDir string , env map [ string ] string ) Config {
testConfig := TestConfig ( buildDir , env )
config := testConfig . config
config . Targets = map [ OsType ] [ ] Target {
Fuchsia : [ ] Target {
2019-09-17 23:45:31 +02:00
{ Fuchsia , Arch { ArchType : Arm64 , ArchVariant : "" } , NativeBridgeDisabled , "" , "" } ,
2019-01-17 23:44:05 +01:00
} ,
BuildOs : [ ] Target {
2019-07-11 10:23:53 +02:00
{ BuildOs , Arch { ArchType : X86_64 } , NativeBridgeDisabled , "" , "" } ,
2019-01-17 23:44:05 +01:00
} ,
}
return testConfig
}
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
2018-10-11 02:02:29 +02:00
config . Targets = map [ OsType ] [ ] Target {
Android : [ ] Target {
2019-09-17 23:45:31 +02:00
{ Android , Arch { ArchType : Arm64 , ArchVariant : "armv8-a" , Abi : [ ] string { "arm64-v8a" } } , NativeBridgeDisabled , "" , "" } ,
{ Android , Arch { ArchType : Arm , ArchVariant : "armv7-a-neon" , Abi : [ ] string { "armeabi-v7a" } } , NativeBridgeDisabled , "" , "" } ,
2017-09-16 02:33:55 +02:00
} ,
2018-10-11 02:02:29 +02:00
BuildOs : [ ] Target {
2019-07-11 10:23:53 +02:00
{ BuildOs , Arch { ArchType : X86_64 } , NativeBridgeDisabled , "" , "" } ,
{ BuildOs , Arch { ArchType : X86 } , NativeBridgeDisabled , "" , "" } ,
2017-09-16 02:33:55 +02:00
} ,
}
2019-05-15 01:01:24 +02:00
if runtime . GOOS == "darwin" {
config . Targets [ BuildOs ] = config . Targets [ BuildOs ] [ : 1 ]
}
2019-10-16 20:03:10 +02:00
config . BuildOSTarget = config . Targets [ BuildOs ] [ 0 ]
config . BuildOSCommonTarget = getCommonTargets ( config . Targets [ BuildOs ] ) [ 0 ]
config . AndroidCommonTarget = getCommonTargets ( config . Targets [ Android ] ) [ 0 ]
2019-05-09 06:29:15 +02:00
config . TestProductVariables . DeviceArch = proptools . StringPtr ( "arm64" )
config . TestProductVariables . DeviceArchVariant = proptools . StringPtr ( "armv8-a" )
config . TestProductVariables . DeviceSecondaryArch = proptools . StringPtr ( "arm" )
config . TestProductVariables . DeviceSecondaryArchVariant = proptools . StringPtr ( "armv7-a-neon" )
2018-10-05 08:28:25 +02:00
2017-09-16 02:33:55 +02:00
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 ,
2019-09-17 23:45:31 +02:00
srcDir : srcDir ,
buildDir : buildDir ,
multilibConflicts : make ( map [ ArchType ] bool ) ,
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 ( )
2018-10-25 01:10:32 +02:00
} else if config . NdkAbis ( ) {
2016-10-19 23:04:41 +02:00
archConfig = getNdkAbisConfig ( )
}
if archConfig != nil {
2019-01-12 04:02:16 +01:00
androidTargets , err := decodeArchSettings ( Android , archConfig )
2016-01-13 08:07:05 +01:00
if err != nil {
return Config { } , err
}
2018-10-11 02:02:29 +02:00
targets [ Android ] = androidTargets
2016-01-13 08:07:05 +01:00
}
2019-09-17 23:45:31 +02:00
multilib := make ( map [ string ] bool )
for _ , target := range targets [ Android ] {
if seen := multilib [ target . Arch . ArchType . Multilib ] ; seen {
config . multilibConflicts [ target . Arch . ArchType ] = true
}
multilib [ target . Arch . ArchType . Multilib ] = true
}
2016-06-02 02:09:44 +02:00
config . Targets = targets
2019-10-16 20:03:10 +02:00
config . BuildOSTarget = config . Targets [ BuildOs ] [ 0 ]
config . BuildOSCommonTarget = getCommonTargets ( config . Targets [ BuildOs ] ) [ 0 ]
if len ( config . Targets [ Android ] ) > 0 {
config . AndroidCommonTarget = getCommonTargets ( config . Targets [ Android ] ) [ 0 ]
}
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 {
2019-05-02 16:32:11 +02:00
switch c . Getenv ( "EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9" ) {
2019-10-01 14:57:31 +02:00
case "" , "true" :
2019-10-17 15:52:07 +02:00
// Do nothing
2017-09-30 02:58:17 +02:00
default :
2019-10-17 15:52:07 +02:00
return fmt . Errorf ( "The environment variable EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9 is no longer supported. Java language level 9 is now the global default." )
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 )
2018-11-17 06:05:32 +01:00
func ( c * config ) HostToolPath ( ctx PathContext , tool string ) Path {
return PathForOutput ( ctx , "host" , c . PrebuiltOS ( ) , "bin" , tool )
}
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 ( ) )
}
2019-04-11 07:59:54 +02:00
func ( c * config ) PrebuiltBuildTool ( ctx PathContext , tool string ) Path {
return PathForSource ( ctx , "prebuilts/build-tools" , c . PrebuiltOS ( ) , "bin" , tool )
}
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
}
2019-03-18 16:53:16 +01:00
func ( c * config ) DeviceResourceOverlays ( ) [ ] string {
return c . productVariables . DeviceResourceOverlays
}
func ( c * config ) ProductResourceOverlays ( ) [ ] string {
return c . productVariables . ProductResourceOverlays
2015-04-13 22:58:27 +02:00
}
2018-05-09 20:11:35 +02:00
func ( c * config ) PlatformVersionName ( ) string {
return String ( c . productVariables . Platform_version_name )
}
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 )
}
2019-04-03 07:56:43 +02:00
func ( c * config ) PlatformSecurityPatch ( ) string {
return String ( c . productVariables . Platform_security_patch )
}
func ( c * config ) PlatformPreviewSdkVersion ( ) string {
return String ( c . productVariables . Platform_preview_sdk_version )
}
func ( c * config ) PlatformMinSupportedTargetSdkVersion ( ) string {
return String ( c . productVariables . Platform_min_supported_target_sdk_version )
}
func ( c * config ) PlatformBaseOS ( ) string {
return String ( c . productVariables . Platform_base_os )
}
2017-08-18 01:19:59 +02:00
func ( c * config ) MinSupportedSdkVersion ( ) int {
2018-11-15 20:28:28 +01:00
return 16
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 {
2019-01-31 23:31:51 +01:00
return 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 {
2019-01-31 23:31:51 +01:00
return 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 {
2019-04-10 06:36:26 +02:00
return PathForSource ( ctx , "build/make/target/product/security" )
2017-12-02 02:16:02 +01:00
}
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
2018-12-24 03:31:58 +01:00
func ( c * config ) ApexKeyDir ( ctx ModuleContext ) SourcePath {
// TODO(b/121224311): define another variable such as TARGET_APEX_KEY_OVERRIDE
defaultCert := String ( c . productVariables . DefaultAppCertificate )
2019-04-10 06:36:26 +02:00
if defaultCert == "" || filepath . Dir ( defaultCert ) == "build/make/target/product/security" {
2018-12-24 03:31:58 +01:00
// When defaultCert is unset or is set to the testkeys path, use the APEX keys
// that is under the module dir
2019-03-05 21:46:40 +01:00
return pathForModuleSrc ( ctx )
2018-12-24 03:31:58 +01:00
} else {
// If not, APEX keys are under the specified directory
return PathForSource ( ctx , filepath . Dir ( defaultCert ) )
}
}
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
}
2019-04-18 23:27:12 +02:00
func ( c * config ) UnbundledBuildUsePrebuiltSdks ( ) bool {
2018-12-19 07:46:24 +01:00
return Bool ( c . productVariables . Unbundled_build ) && ! Bool ( c . productVariables . Unbundled_build_sdks_from_source )
}
2019-01-16 21:06:11 +01:00
func ( c * config ) Fuchsia ( ) bool {
return Bool ( c . productVariables . Fuchsia )
}
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
}
2018-09-06 01:28:13 +02:00
func ( c * config ) Debuggable ( ) bool {
return Bool ( c . productVariables . Debuggable )
}
2018-11-30 00:08:44 +01:00
func ( c * config ) Eng ( ) bool {
return Bool ( c . productVariables . Eng )
}
2018-10-02 00:30:23 +02:00
func ( c * config ) DevicePrefer32BitApps ( ) bool {
return Bool ( c . productVariables . DevicePrefer32BitApps )
}
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
}
2018-07-07 11:02:07 +02:00
func ( c * config ) DevicePrimaryArchType ( ) ArchType {
2018-10-11 02:02:29 +02:00
return c . Targets [ Android ] [ 0 ] . Arch . ArchType
2018-07-07 11:02:07 +02:00
}
2017-04-27 02:34:03 +02:00
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
}
2019-02-01 17:42:56 +01:00
func ( c * config ) DisableScudo ( ) bool {
return Bool ( c . productVariables . DisableScudo )
}
2018-11-21 17:59:37 +01:00
func ( c * config ) EnableXOM ( ) bool {
if c . productVariables . EnableXOM == nil {
2019-01-10 18:46:00 +01:00
return true
2018-11-21 17:59:37 +01:00
} else {
return Bool ( c . productVariables . EnableXOM )
}
}
2016-06-02 02:09:44 +02:00
func ( c * config ) Android64 ( ) bool {
2018-10-11 02:02:29 +02:00
for _ , t := range c . Targets [ Android ] {
2016-06-02 02:09:44 +02:00
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 {
2018-03-10 06:22:06 +01:00
return Bool ( c . productVariables . UseGoma )
2016-08-30 01:14:13 +02:00
}
2019-07-17 14:30:04 +02:00
func ( c * config ) UseRBE ( ) bool {
return Bool ( c . productVariables . UseRBE )
}
2018-06-20 07:47:35 +02:00
func ( c * config ) RunErrorProne ( ) bool {
return c . IsEnvTrue ( "RUN_ERROR_PRONE" )
}
2018-11-06 01:49:08 +01:00
func ( c * config ) XrefCorpusName ( ) string {
return c . Getenv ( "XREF_CORPUS" )
}
func ( c * config ) EmitXrefRules ( ) bool {
return c . XrefCorpusName ( ) != ""
}
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 {
2018-09-18 09:09:16 +02:00
archType := Common
2018-10-11 02:02:29 +02:00
if len ( c . Targets [ Android ] ) > 0 {
archType = c . Targets [ Android ] [ 0 ] . Arch . ArchType
2018-09-18 09:09:16 +02:00
}
switch archType {
default :
return "0x70000000"
case Mips , Mips64 :
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 {
2019-10-01 07:13:41 +02:00
if InList ( "*" , enforceList ) {
2018-03-12 23:30:26 +01:00
return true
}
2019-01-31 23:31:51 +01:00
return InList ( name , enforceList )
2018-03-12 23:30:26 +01:00
}
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 {
2019-01-31 23:31:51 +01:00
for _ , exclude := range excluded {
2018-03-12 23:30:26 +01:00
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
}
2018-10-05 23:20:06 +02:00
func ( c * config ) UncompressPrivAppDex ( ) bool {
return Bool ( c . productVariables . UncompressPrivAppDex )
}
func ( c * config ) ModulesLoadedByPrivilegedModules ( ) [ ] string {
return c . productVariables . ModulesLoadedByPrivilegedModules
}
2018-12-21 16:54:16 +01:00
func ( c * config ) BootJars ( ) [ ] string {
return c . productVariables . BootJars
}
2018-11-12 19:13:39 +01:00
func ( c * config ) DexpreoptGlobalConfig ( ) string {
return String ( c . productVariables . DexpreoptGlobalConfig )
}
2019-01-23 22:04:05 +01:00
func ( c * config ) FrameworksBaseDirExists ( ctx PathContext ) bool {
return ExistentPathForSource ( ctx , "frameworks" , "base" ) . Valid ( )
}
2019-05-14 11:52:49 +02:00
func ( c * config ) VndkSnapshotBuildArtifacts ( ) bool {
return Bool ( c . productVariables . VndkSnapshotBuildArtifacts )
}
2019-09-17 23:45:31 +02:00
func ( c * config ) HasMultilibConflict ( arch ArchType ) bool {
return c . multilibConflicts [ arch ]
}
2016-08-18 00:24:12 +02:00
func ( c * deviceConfig ) Arches ( ) [ ] Arch {
var arches [ ] Arch
2018-10-11 02:02:29 +02:00
for _ , target := range c . config . Targets [ Android ] {
2016-08-18 00:24:12 +02:00
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-11-13 05:19:56 +01:00
func ( c * deviceConfig ) VndkUseCoreVariant ( ) bool {
return Bool ( c . config . productVariables . VndkUseCoreVariant )
}
2018-01-15 07:05:10 +01:00
func ( c * deviceConfig ) SystemSdkVersions ( ) [ ] string {
2019-01-31 23:31:51 +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
}
2019-06-25 09:47:17 +02:00
func ( c * deviceConfig ) SystemExtPath ( ) string {
if c . config . productVariables . SystemExtPath != nil {
return * c . config . productVariables . SystemExtPath
2018-05-29 14:28:54 +02:00
}
2019-06-25 09:47:17 +02:00
return "system_ext"
2018-05-29 14:28:54 +02: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 {
2019-03-01 23:43:39 +01:00
if InList ( "*" , c . config . productVariables . CoveragePaths ) || 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 {
2019-01-31 23:31:51 +01:00
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
}
2018-05-20 23:34:48 +02:00
func ( c * deviceConfig ) PlatPublicSepolicyDirs ( ) [ ] string {
return c . config . productVariables . BoardPlatPublicSepolicyDirs
2018-03-26 05:00:00 +02:00
}
2018-05-20 23:34:48 +02:00
func ( c * deviceConfig ) PlatPrivateSepolicyDirs ( ) [ ] string {
return c . config . productVariables . BoardPlatPrivateSepolicyDirs
2018-03-26 05:00:00 +02:00
}
Build contexts files with Soong
This is to migrate sepolicy Makefiles into Soong. For the first part,
file_contexts, hwservice_contexts, property_contexts, and
service_contexts are migrated. Build-time tests for contexts files are
still in Makefile; they will also be done with Soong after porting the
module sepolicy.
The motivation of migrating is based on generating property_contexts
dynamically: if we were to amend contexts files at build time in the
future, it would be nicer to manage them in Soong. To do that, building
contexts files with Soong can be very helpful.
Bug: 127949646
Bug: 129377144
Test: 1) Build blueline-userdebug, flash, and boot.
Test: 2) Build blueline-userdebug with TARGET_FLATTEN_APEX=true, flash,
and boot.
Test: 3) Build aosp_arm-userdebug.
Change-Id: I49206e656564206d6f7265206361666665696e65
2019-04-15 13:21:29 +02:00
func ( c * deviceConfig ) SepolicyM4Defs ( ) [ ] string {
return c . config . productVariables . BoardSepolicyM4Defs
}
2019-01-05 04:57:48 +01:00
func ( c * deviceConfig ) OverrideManifestPackageNameFor ( name string ) ( manifestName string , overridden bool ) {
2019-01-18 23:27:16 +01:00
return findOverrideValue ( c . config . productVariables . ManifestPackageNameOverrides , name ,
"invalid override rule %q in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES should be <module_name>:<manifest_name>" )
}
func ( c * deviceConfig ) OverrideCertificateFor ( name string ) ( certificatePath string , overridden bool ) {
2019-02-28 17:22:30 +01:00
return findOverrideValue ( c . config . productVariables . CertificateOverrides , name ,
2019-01-18 23:27:16 +01:00
"invalid override rule %q in PRODUCT_CERTIFICATE_OVERRIDES should be <module_name>:<certificate_module_name>" )
}
2019-01-24 01:27:47 +01:00
func ( c * deviceConfig ) OverridePackageNameFor ( name string ) string {
newName , overridden := findOverrideValue (
c . config . productVariables . PackageNameOverrides ,
name ,
"invalid override rule %q in PRODUCT_PACKAGE_NAME_OVERRIDES should be <module_name>:<package_name>" )
if overridden {
return newName
}
return name
}
2019-01-18 23:27:16 +01:00
func findOverrideValue ( overrides [ ] string , name string , errorMsg string ) ( newValue string , overridden bool ) {
2019-01-05 04:57:48 +01:00
if overrides == nil || len ( overrides ) == 0 {
return "" , false
}
for _ , o := range overrides {
split := strings . Split ( o , ":" )
if len ( split ) != 2 {
// This shouldn't happen as this is first checked in make, but just in case.
2019-01-18 23:27:16 +01:00
panic ( fmt . Errorf ( errorMsg , o ) )
2019-01-05 04:57:48 +01:00
}
if matchPattern ( split [ 0 ] , name ) {
return substPattern ( split [ 0 ] , split [ 1 ] , name ) , true
}
}
return "" , false
}
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
}
2019-01-31 23:31:51 +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
}
2019-01-31 23:31:51 +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
}
2019-01-31 23:31:51 +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-11-21 17:59:37 +01:00
func ( c * config ) XOMDisabledForPath ( path string ) bool {
if c . productVariables . XOMExcludePaths == nil {
return false
}
2019-01-31 23:31:51 +01:00
return PrefixInList ( path , c . productVariables . XOMExcludePaths )
2018-11-21 17:59:37 +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
}
2018-10-25 01:10:32 +02:00
func ( c * config ) NdkAbis ( ) bool {
return Bool ( c . productVariables . Ndk_abis )
}
2018-11-28 17:30:10 +01:00
func ( c * config ) ExcludeDraftNdkApis ( ) bool {
return Bool ( c . productVariables . Exclude_draft_ndk_apis )
}
2018-11-07 18:50:25 +01:00
func ( c * config ) FlattenApex ( ) bool {
2019-08-12 20:56:16 +02:00
return Bool ( c . productVariables . Flatten_apex )
2018-11-07 18:50:25 +01:00
}
2019-01-07 04:07:27 +01:00
func ( c * config ) EnforceSystemCertificate ( ) bool {
return Bool ( c . productVariables . EnforceSystemCertificate )
}
func ( c * config ) EnforceSystemCertificateWhitelist ( ) [ ] string {
return c . productVariables . EnforceSystemCertificateWhitelist
}
2019-10-29 07:44:45 +01:00
func ( c * config ) EnforceProductPartitionInterface ( ) bool {
return Bool ( c . productVariables . EnforceProductPartitionInterface )
}
2019-12-05 08:27:44 +01:00
func ( c * config ) InstallExtraFlattenedApexes ( ) bool {
return Bool ( c . productVariables . InstallExtraFlattenedApexes )
}
2019-01-31 23:12:44 +01:00
func ( c * config ) ProductHiddenAPIStubs ( ) [ ] string {
return c . productVariables . ProductHiddenAPIStubs
2019-01-17 00:15:52 +01:00
}
2019-01-31 23:12:44 +01:00
func ( c * config ) ProductHiddenAPIStubsSystem ( ) [ ] string {
return c . productVariables . ProductHiddenAPIStubsSystem
2019-01-17 00:15:52 +01:00
}
2019-01-31 23:12:44 +01:00
func ( c * config ) ProductHiddenAPIStubsTest ( ) [ ] string {
return c . productVariables . ProductHiddenAPIStubsTest
2019-01-17 00:15:52 +01:00
}
2019-04-10 21:27:35 +02:00
2019-04-18 19:08:46 +02:00
func ( c * deviceConfig ) TargetFSConfigGen ( ) [ ] string {
2019-04-10 21:27:35 +02:00
return c . config . productVariables . TargetFSConfigGen
}
Build contexts files with Soong
This is to migrate sepolicy Makefiles into Soong. For the first part,
file_contexts, hwservice_contexts, property_contexts, and
service_contexts are migrated. Build-time tests for contexts files are
still in Makefile; they will also be done with Soong after porting the
module sepolicy.
The motivation of migrating is based on generating property_contexts
dynamically: if we were to amend contexts files at build time in the
future, it would be nicer to manage them in Soong. To do that, building
contexts files with Soong can be very helpful.
Bug: 127949646
Bug: 129377144
Test: 1) Build blueline-userdebug, flash, and boot.
Test: 2) Build blueline-userdebug with TARGET_FLATTEN_APEX=true, flash,
and boot.
Test: 3) Build aosp_arm-userdebug.
Change-Id: I49206e656564206d6f7265206361666665696e65
2019-04-15 13:21:29 +02:00
func ( c * config ) ProductPublicSepolicyDirs ( ) [ ] string {
return c . productVariables . ProductPublicSepolicyDirs
}
func ( c * config ) ProductPrivateSepolicyDirs ( ) [ ] string {
return c . productVariables . ProductPrivateSepolicyDirs
}
func ( c * config ) ProductCompatibleProperty ( ) bool {
return Bool ( c . productVariables . ProductCompatibleProperty )
}
2019-05-09 06:29:15 +02:00
2019-05-16 21:28:22 +02:00
func ( c * config ) MissingUsesLibraries ( ) [ ] string {
return c . productVariables . MissingUsesLibraries
}
2019-05-09 06:29:15 +02:00
func ( c * deviceConfig ) BoardVndkRuntimeDisable ( ) bool {
return Bool ( c . config . productVariables . BoardVndkRuntimeDisable )
}
func ( c * deviceConfig ) DeviceArch ( ) string {
return String ( c . config . productVariables . DeviceArch )
}
func ( c * deviceConfig ) DeviceArchVariant ( ) string {
return String ( c . config . productVariables . DeviceArchVariant )
}
func ( c * deviceConfig ) DeviceSecondaryArch ( ) string {
return String ( c . config . productVariables . DeviceSecondaryArch )
}
func ( c * deviceConfig ) DeviceSecondaryArchVariant ( ) string {
return String ( c . config . productVariables . DeviceSecondaryArchVariant )
}