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"
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
2019-12-14 05:41:13 +01:00
"github.com/google/blueprint"
2017-12-12 00:52:26 +01:00
"github.com/google/blueprint/bootstrap"
2019-12-14 05:41:13 +01:00
"github.com/google/blueprint/pathtools"
2015-12-18 01:39:19 +01:00
"github.com/google/blueprint/proptools"
2019-11-23 01:03:51 +01:00
"android/soong/android/soongconfig"
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
2020-08-06 16:00:37 +02:00
var StringDefault = proptools . StringDefault
Abstract sdk_version string using sdkSpec type
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
2020-01-20 18:03:43 +01:00
2020-07-24 01:43:25 +02:00
const FutureApiLevelInt = 10000
var FutureApiLevel = ApiLevel {
value : "current" ,
number : FutureApiLevelInt ,
isPreview : true ,
}
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 {
2020-09-17 12:09:58 +02:00
Mega_device * bool ` json:",omitempty" `
Host_bionic * bool ` json:",omitempty" `
Host_bionic_arm64 * 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
}
2019-11-23 01:03:51 +01:00
type VendorConfig soongconfig . SoongConfig
2018-03-26 21:41:18 +02:00
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
2020-09-29 08:23:17 +02:00
BazelContext BazelContext
2017-12-12 00:52:26 +01:00
PrimaryBuilder string
2015-07-14 09:39:06 +02:00
ConfigFileName string
ProductVariablesFileName string
2020-10-10 02:25:15 +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
AndroidFirstDeviceTarget Target // the first Target for 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
2020-06-23 23:37:05 +02:00
srcDir string // the path of the root source directory
buildDir string // the path of the build output directory
moduleListFile string // the path to the file which lists blueprint files to parse.
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
2019-12-14 05:41:13 +01:00
fs pathtools . FileSystem
mockBpList string
2020-06-08 01:56:32 +02:00
// If testAllowNonExistentPaths is true then PathForSource and PathForModuleSrc won't error
// in tests when a path doesn't exist.
testAllowNonExistentPaths bool
2016-08-18 00:24:12 +02:00
OncePer
}
type deviceConfig struct {
2017-07-07 01:59:48 +02:00
config * config
2016-08-18 00:24:12 +02:00
OncePer
2015-01-31 02:27:36 +01:00
}
2015-08-27 22:28:01 +02:00
type jsonConfigurable interface {
2015-09-18 19:57:10 +02:00
SetDefaultConfig ( )
2015-08-27 22:28:01 +02:00
}
func loadConfig ( config * config ) error {
2020-01-11 02:11:46 +01:00
err := loadFromConfigFile ( & config . FileConfigurableOptions , absolutePath ( config . ConfigFileName ) )
2015-08-27 22:28:01 +02:00
if err != nil {
return err
}
2020-01-11 02:11:46 +01:00
return loadFromConfigFile ( & config . productVariables , absolutePath ( 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
}
2020-01-11 02:11:46 +01:00
// NullConfig returns a mostly empty Config for use by standalone tools like dexpreopt_gen that
// use the android package.
func NullConfig ( buildDir string ) Config {
return Config {
config : & config {
buildDir : buildDir ,
fs : pathtools . OsFs ,
} ,
}
}
2016-10-07 01:12:58 +02:00
// TestConfig returns a Config object suitable for using for tests
2019-12-14 05:41:13 +01:00
func TestConfig ( buildDir string , env map [ string ] string , bp string , fs map [ string ] [ ] byte ) 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 {
2020-07-24 02:32:15 +02:00
DeviceName : stringPtr ( "test_device" ) ,
Platform_sdk_version : intPtr ( 30 ) ,
Platform_sdk_codename : stringPtr ( "S" ) ,
Platform_version_active_codenames : [ ] string { "S" } ,
DeviceSystemSdkVersions : [ ] string { "14" , "15" } ,
Platform_systemsdk_versions : [ ] string { "29" , "30" } ,
AAPTConfig : [ ] string { "normal" , "large" , "xlarge" , "hdpi" , "xhdpi" , "xxhdpi" } ,
AAPTPreferredConfig : stringPtr ( "xhdpi" ) ,
AAPTCharacteristics : stringPtr ( "nosdcard" ) ,
AAPTPrebuiltDPI : [ ] string { "xhdpi" , "xxhdpi" } ,
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 ,
2020-06-08 01:56:32 +02:00
// Set testAllowNonExistentPaths so that test contexts don't need to specify every path
// passed to PathForSource or PathForModuleSrc.
testAllowNonExistentPaths : true ,
2020-09-29 08:23:17 +02:00
BazelContext : noopBazelContext { } ,
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
2019-12-14 05:41:13 +01:00
config . mockFileSystem ( bp , fs )
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-12-14 05:41:13 +01:00
func TestArchConfigNativeBridge ( buildDir string , env map [ string ] string , bp string , fs map [ string ] [ ] byte ) Config {
testConfig := TestArchConfig ( buildDir , env , bp , fs )
2019-03-26 12:39:31 +01:00
config := testConfig . config
2019-05-15 01:01:24 +02:00
config . Targets [ Android ] = [ ] Target {
2020-09-14 12:43:17 +02:00
{ Android , Arch { ArchType : X86_64 , ArchVariant : "silvermont" , Abi : [ ] string { "arm64-v8a" } } , NativeBridgeDisabled , "" , "" , false } ,
{ Android , Arch { ArchType : X86 , ArchVariant : "silvermont" , Abi : [ ] string { "armeabi-v7a" } } , NativeBridgeDisabled , "" , "" , false } ,
{ Android , Arch { ArchType : Arm64 , ArchVariant : "armv8-a" , Abi : [ ] string { "arm64-v8a" } } , NativeBridgeEnabled , "x86_64" , "arm64" , false } ,
{ Android , Arch { ArchType : Arm , ArchVariant : "armv7-a-neon" , Abi : [ ] string { "armeabi-v7a" } } , NativeBridgeEnabled , "x86" , "arm" , false } ,
2019-03-26 12:39:31 +01:00
}
return testConfig
}
2019-12-14 05:41:13 +01:00
func TestArchConfigFuchsia ( buildDir string , env map [ string ] string , bp string , fs map [ string ] [ ] byte ) Config {
testConfig := TestConfig ( buildDir , env , bp , fs )
2019-01-17 23:44:05 +01:00
config := testConfig . config
config . Targets = map [ OsType ] [ ] Target {
Fuchsia : [ ] Target {
2020-09-14 12:43:17 +02:00
{ Fuchsia , Arch { ArchType : Arm64 , ArchVariant : "" , Abi : [ ] string { "arm64-v8a" } } , NativeBridgeDisabled , "" , "" , false } ,
2019-01-17 23:44:05 +01:00
} ,
BuildOs : [ ] Target {
2020-09-14 12:43:17 +02:00
{ BuildOs , Arch { ArchType : X86_64 } , NativeBridgeDisabled , "" , "" , false } ,
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
2019-12-14 05:41:13 +01:00
func TestArchConfig ( buildDir string , env map [ string ] string , bp string , fs map [ string ] [ ] byte ) Config {
testConfig := TestConfig ( buildDir , env , bp , fs )
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 {
2020-09-14 12:43:17 +02:00
{ Android , Arch { ArchType : Arm64 , ArchVariant : "armv8-a" , Abi : [ ] string { "arm64-v8a" } } , NativeBridgeDisabled , "" , "" , false } ,
{ Android , Arch { ArchType : Arm , ArchVariant : "armv7-a-neon" , Abi : [ ] string { "armeabi-v7a" } } , NativeBridgeDisabled , "" , "" , false } ,
2017-09-16 02:33:55 +02:00
} ,
2018-10-11 02:02:29 +02:00
BuildOs : [ ] Target {
2020-09-14 12:43:17 +02:00
{ BuildOs , Arch { ArchType : X86_64 } , NativeBridgeDisabled , "" , "" , false } ,
{ BuildOs , Arch { ArchType : X86 } , NativeBridgeDisabled , "" , "" , false } ,
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 ]
2020-10-10 02:25:15 +02:00
config . AndroidFirstDeviceTarget = firstTarget ( config . Targets [ Android ] , "lib64" , "lib32" ) [ 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
}
2020-09-29 08:23:17 +02:00
// Returns a config object which is "reset" for another bootstrap run.
// Only per-run data is reset. Data which needs to persist across multiple
// runs in the same program execution is carried over (such as Bazel context
// or environment deps).
func ConfigForAdditionalRun ( c Config ) ( Config , error ) {
newConfig , err := NewConfig ( c . srcDir , c . buildDir , c . moduleListFile )
if err != nil {
return Config { } , err
}
newConfig . BazelContext = c . BazelContext
newConfig . envDeps = c . envDeps
return newConfig , nil
}
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.
2020-06-23 23:37:05 +02:00
func NewConfig ( srcDir , buildDir string , moduleListFile 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 ) ,
2019-12-14 05:41:13 +01:00
2020-06-23 23:37:05 +02:00
moduleListFile : moduleListFile ,
fs : pathtools . NewOsFs ( absSrcDir ) ,
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 ,
}
2020-07-28 22:27:34 +02:00
// Soundness check of the build and source directories. This won't catch strange
// configurations with symlinks, but at least checks the obvious case.
2015-09-24 00:26:20 +02:00
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" )
2020-01-11 02:11:46 +01:00
if _ , err := os . Stat ( absolutePath ( inMakeFile ) ) ; err == nil {
2015-12-11 22:51:06 +01:00
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
}
2020-02-25 20:26:33 +01:00
// Make the CommonOS OsType available for all products.
targets [ CommonOS ] = [ ] Target { commonTargetMap [ CommonOS . Name ] }
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 ( )
Add script for building all target arch's needed in AML (Android Mainline)
prebuilts.
This runs Soong in skip-make mode, using normal in-make mode only to query
platform versions.
The same ${OUT_DIR} cannot be used for both skip-make and in-make builds,
because Soong generates a smaller build.ninja file in in-make builds where
many build targets are expected to be provided by the mk files. Thus this
script avoids using ${OUT_DIR} if it's an in-make build, defaulting instead
to out-aml/.
The script is based on build-ndk-prebuilts.sh, but uses a separate Soong
variable Aml_abis to enable the appropriate target architectures for
Mainline modules. Aml_abis is very similar to Ndk_abis, except "armeabi-v7a"
is used instead of "armeabi", which is necessary to match prebuilt
dependencies, e.g. for LLVM.
Test: build/soong/scripts/build-aml-prebuilts.sh libart libdexfile_external
(verify that libraries for arm, arm64, x86, x86_64 are built)
Test: build/soong/scripts/build-aml-prebuilts.sh \
out-aml/soong/.intermediates/external/conscrypt/conscrypt-module-sdk/android_common/conscrypt-module-sdk-current.zip
(verify that the zip file contains libconscrypt_jni.so's for all four arches)
Test: build/soong/scripts/build-aml-prebuilts.sh com.android.art.{release,debug,testing,host}
(verify that the build completes)
Test: Two identical build/soong/scripts/build-aml-prebuilts.sh runs after each other
(verify that the 2nd run completes both Soong and ninja steps quickly without any building)
Change-Id: I35712f9f8f0b1cbb77107314c5927c6720e6c3bf
2019-11-15 16:00:31 +01:00
} else if config . AmlAbis ( ) {
archConfig = getAmlAbisConfig ( )
2016-10-19 23:04:41 +02:00
}
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 ]
2020-10-10 02:25:15 +02:00
config . AndroidFirstDeviceTarget = firstTarget ( config . Targets [ Android ] , "lib64" , "lib32" ) [ 0 ]
2019-10-16 20:03:10 +02:00
}
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
}
2020-06-17 02:51:46 +02:00
if Bool ( config . productVariables . GcovCoverage ) && Bool ( config . productVariables . ClangCoverage ) {
return Config { } , fmt . Errorf ( "GcovCoverage and ClangCoverage cannot both be set" )
}
config . productVariables . Native_coverage = proptools . BoolPtr (
Bool ( config . productVariables . GcovCoverage ) ||
Bool ( config . productVariables . ClangCoverage ) )
2020-09-29 08:23:17 +02:00
config . BazelContext , err = NewBazelContext ( config )
if 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
}
2020-01-11 02:11:46 +01:00
var TestConfigOsFs = map [ string ] [ ] byte { }
2019-12-14 05:41:13 +01:00
// mockFileSystem replaces all reads with accesses to the provided map of
// filenames to contents stored as a byte slice.
func ( c * config ) mockFileSystem ( bp string , fs map [ string ] [ ] byte ) {
mockFS := map [ string ] [ ] byte { }
if _ , exists := mockFS [ "Android.bp" ] ; ! exists {
mockFS [ "Android.bp" ] = [ ] byte ( bp )
}
for k , v := range fs {
mockFS [ k ] = v
}
// no module list file specified; find every file named Blueprints or Android.bp
pathsToParse := [ ] string { }
for candidate := range mockFS {
base := filepath . Base ( candidate )
if base == "Blueprints" || base == "Android.bp" {
pathsToParse = append ( pathsToParse , candidate )
}
}
if len ( pathsToParse ) < 1 {
panic ( fmt . Sprintf ( "No Blueprint or Android.bp files found in mock filesystem: %v\n" , mockFS ) )
}
mockFS [ blueprint . MockModuleListFile ] = [ ] byte ( strings . Join ( pathsToParse , "\n" ) )
c . fs = pathtools . MockFs ( mockFS )
c . mockBpList = blueprint . MockModuleListFile
}
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 )
}
2019-12-09 22:47:14 +01:00
func ( c * config ) HostJNIToolPath ( ctx PathContext , path string ) Path {
ext := ".so"
if runtime . GOOS == "darwin" {
ext = ".dylib"
}
return PathForOutput ( ctx , "host" , c . PrebuiltOS ( ) , "lib64" , path + ext )
}
func ( c * config ) HostJavaToolPath ( ctx PathContext , path string ) Path {
return PathForOutput ( ctx , "host" , c . PrebuiltOS ( ) , "framework" , path )
}
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
}
2020-02-22 01:55:46 +01:00
func ( c * config ) BuildNumberFile ( ctx PathContext ) Path {
return PathForOutput ( ctx , String ( c . productVariables . BuildNumberFile ) )
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 )
}
2020-07-24 02:32:15 +02:00
func ( c * config ) PlatformSdkVersion ( ) ApiLevel {
return uncheckedFinalApiLevel ( * c . productVariables . Platform_sdk_version )
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 )
}
Replace stringly-typed API levels.
Handling of API levels within Soong is currently fairly difficult
since it isn't always clear based on context what kind of API level a
given string represents, how much canonicalizing and error checking
the code receiving the string are expected to do, or how those errors
should be treated.
The API level struct does not export its raw data, so as to keep its
"constructor" private to the android package, and to prevent misuse of
the `number` field, which is only an implementation detail for preview
API levels. API levels can be parsed with either
`android.ApiLevelFromUser`, which returns any errors to the caller, or
`android.ApiLevelOrPanic`, which is used in the case where the input
is trusted and any errors in parsing should panic. Even within the
`android` package, these APIs should be preferred over direct
construction.
For cases where there are context specific parsing requirements, such
as handling the "minimum" alias in the cc module,
`nativeApiLevelFromUser` and `nativeApiLevelOrPanic` should be used
instead.
Test: treehugger
Bug: http://b/154667674
Change-Id: Id52921fda32cb437fb1775ac2183299dedc0cf20
2020-07-06 23:49:35 +02:00
func ( c * config ) MinSupportedSdkVersion ( ) ApiLevel {
return uncheckedFinalApiLevel ( 16 )
}
func ( c * config ) FinalApiLevels ( ) [ ] ApiLevel {
var levels [ ] ApiLevel
2020-07-24 02:32:15 +02:00
for i := 1 ; i <= c . PlatformSdkVersion ( ) . FinalOrFutureInt ( ) ; i ++ {
Replace stringly-typed API levels.
Handling of API levels within Soong is currently fairly difficult
since it isn't always clear based on context what kind of API level a
given string represents, how much canonicalizing and error checking
the code receiving the string are expected to do, or how those errors
should be treated.
The API level struct does not export its raw data, so as to keep its
"constructor" private to the android package, and to prevent misuse of
the `number` field, which is only an implementation detail for preview
API levels. API levels can be parsed with either
`android.ApiLevelFromUser`, which returns any errors to the caller, or
`android.ApiLevelOrPanic`, which is used in the case where the input
is trusted and any errors in parsing should panic. Even within the
`android` package, these APIs should be preferred over direct
construction.
For cases where there are context specific parsing requirements, such
as handling the "minimum" alias in the cc module,
`nativeApiLevelFromUser` and `nativeApiLevelOrPanic` should be used
instead.
Test: treehugger
Bug: http://b/154667674
Change-Id: Id52921fda32cb437fb1775ac2183299dedc0cf20
2020-07-06 23:49:35 +02:00
levels = append ( levels , uncheckedFinalApiLevel ( i ) )
}
return levels
}
func ( c * config ) PreviewApiLevels ( ) [ ] ApiLevel {
var levels [ ] ApiLevel
for i , codename := range c . PlatformVersionActiveCodenames ( ) {
levels = append ( levels , ApiLevel {
value : codename ,
number : i ,
isPreview : true ,
} )
}
return levels
}
func ( c * config ) AllSupportedApiLevels ( ) [ ] ApiLevel {
var levels [ ] ApiLevel
levels = append ( levels , c . FinalApiLevels ( ) ... )
return append ( levels , c . PreviewApiLevels ( ) ... )
2017-08-18 01:19:59 +02:00
}
2020-07-24 02:32:15 +02:00
func ( c * config ) DefaultAppTargetSdk ( ctx EarlyModuleContext ) ApiLevel {
2018-04-18 20:06:47 +02:00
if Bool ( c . productVariables . Platform_sdk_final ) {
return c . PlatformSdkVersion ( )
} else {
2020-07-24 02:32:15 +02:00
codename := c . PlatformSdkCodename ( )
if codename == "" {
return NoneApiLevel
}
if codename == "REL" {
panic ( "Platform_sdk_codename should not be REL when Platform_sdk_final is true" )
}
return ApiLevelOrPanic ( ctx , codename )
2018-04-18 20:06:47 +02:00
}
}
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
}
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
2020-07-07 18:09:23 +02:00
// Returns true if a full platform source tree cannot be assumed.
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
}
2020-06-17 02:13:15 +02:00
// Returns true if building apps that aren't bundled with the platform.
// UnbundledBuild() is always true when this is true.
func ( c * config ) UnbundledBuildApps ( ) bool {
return Bool ( c . productVariables . Unbundled_build_apps )
}
2020-07-07 18:09:23 +02:00
// Returns true if building modules against prebuilt SDKs.
func ( c * config ) AlwaysUsePrebuiltSdks ( ) bool {
return Bool ( c . productVariables . Always_use_prebuilt_sdks )
2018-12-19 07:46:24 +01:00
}
2019-01-16 21:06:11 +01:00
func ( c * config ) Fuchsia ( ) bool {
return Bool ( c . productVariables . Fuchsia )
}
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-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 )
}
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 )
}
2020-01-27 20:19:44 +01:00
func ( c * config ) UseRBEJAVAC ( ) bool {
return Bool ( c . productVariables . UseRBEJAVAC )
}
func ( c * config ) UseRBER8 ( ) bool {
return Bool ( c . productVariables . UseRBER8 )
}
func ( c * config ) UseRBED8 ( ) bool {
return Bool ( c . productVariables . UseRBED8 )
}
2019-11-15 22:18:43 +01:00
func ( c * config ) UseRemoteBuild ( ) bool {
return c . UseGoma ( ) || c . 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" )
}
2020-01-10 02:34:23 +01:00
// Returns Compilation Unit encoding to use. Can be 'json' (default), 'proto' or 'all'.
func ( c * config ) XrefCuEncoding ( ) string {
if enc := c . Getenv ( "KYTHE_KZIP_ENCODING" ) ; enc != "" {
return enc
}
return "json"
}
2018-11-06 01:49:08 +01:00
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 {
2020-03-07 01:55:28 +01:00
return "0x70000000"
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
2020-03-09 04:37:05 +01:00
// TODO(b/150820813) Some modules depend on static overlay, remove this after eliminating the dependency.
exemptedList := c . productVariables . EnforceRROExemptedTargets
2020-07-09 17:58:14 +02:00
if len ( exemptedList ) > 0 {
2020-03-09 04:37:05 +01:00
if InList ( name , exemptedList ) {
return false
}
}
2020-07-09 17:58:14 +02:00
if len ( enforceList ) > 0 {
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
}
2020-10-07 03:56:10 +02:00
func ( c * config ) EnforceRROExemptedForModule ( name string ) bool {
return InList ( name , c . productVariables . EnforceRROExemptedTargets )
}
2018-03-12 23:30:26 +01:00
func ( c * config ) EnforceRROExcludedOverlay ( path string ) bool {
2018-03-10 06:22:06 +01:00
excluded := c . productVariables . EnforceRROExcludedOverlays
2020-07-09 17:58:14 +02:00
if len ( excluded ) > 0 {
2020-02-11 16:54:35 +01:00
return HasAnyPrefix ( path , excluded )
2018-03-12 23:30:26 +01:00
}
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
}
2020-01-11 02:11:46 +01:00
func ( c * config ) DexpreoptGlobalConfig ( ctx PathContext ) ( [ ] byte , error ) {
if c . productVariables . DexpreoptGlobalConfig == nil {
return nil , nil
}
path := absolutePath ( * c . productVariables . DexpreoptGlobalConfig )
ctx . AddNinjaFileDeps ( path )
return ioutil . ReadFile ( path )
2018-11-12 19:13:39 +01:00
}
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
}
2020-08-06 16:00:37 +02:00
func ( c * deviceConfig ) CurrentApiLevelForVendorModules ( ) string {
return StringDefault ( c . config . productVariables . DeviceCurrentApiLevelForVendorModules , "current" )
}
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
}
2019-11-18 11:52:14 +01:00
func ( c * deviceConfig ) ProductVndkVersion ( ) string {
return String ( c . config . productVariables . ProductVndkVersion )
}
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
}
2020-03-20 08:22:27 +01:00
func ( c * deviceConfig ) SamplingPGO ( ) bool {
return Bool ( c . config . productVariables . SamplingPGO )
}
2020-06-09 14:07:36 +02:00
// JavaCoverageEnabledForPath returns whether Java code coverage is enabled for
// path. Coverage is enabled by default when the product variable
// JavaCoveragePaths is empty. If JavaCoveragePaths is not empty, coverage is
// enabled for any path which is part of this variable (and not part of the
// JavaCoverageExcludePaths product variable). Value "*" in JavaCoveragePaths
// represents any path.
func ( c * deviceConfig ) JavaCoverageEnabledForPath ( path string ) bool {
coverage := false
2020-06-24 22:36:59 +02:00
if len ( c . config . productVariables . JavaCoveragePaths ) == 0 ||
2020-06-09 14:07:36 +02:00
InList ( "*" , c . config . productVariables . JavaCoveragePaths ) ||
HasAnyPrefix ( path , c . config . productVariables . JavaCoveragePaths ) {
coverage = true
}
2020-07-09 17:58:14 +02:00
if coverage && len ( c . config . productVariables . JavaCoverageExcludePaths ) > 0 {
2020-06-09 14:07:36 +02:00
if HasAnyPrefix ( path , c . config . productVariables . JavaCoverageExcludePaths ) {
coverage = false
}
}
return coverage
}
2020-06-17 02:51:46 +02:00
// Returns true if gcov or clang coverage is enabled.
2017-02-10 01:16:31 +01:00
func ( c * deviceConfig ) NativeCoverageEnabled ( ) bool {
2020-06-17 02:51:46 +02:00
return Bool ( c . config . productVariables . GcovCoverage ) ||
Bool ( c . config . productVariables . ClangCoverage )
2017-02-10 01:16:31 +01:00
}
2019-12-07 00:22:41 +01:00
func ( c * deviceConfig ) ClangCoverageEnabled ( ) bool {
return Bool ( c . config . productVariables . ClangCoverage )
}
2017-02-10 01:16:31 +01:00
2020-06-17 02:51:46 +02:00
func ( c * deviceConfig ) GcovCoverageEnabled ( ) bool {
return Bool ( c . config . productVariables . GcovCoverage )
}
2020-06-09 13:44:06 +02:00
// NativeCoverageEnabledForPath returns whether (GCOV- or Clang-based) native
// code coverage is enabled for path. By default, coverage is not enabled for a
// given path unless it is part of the NativeCoveragePaths product variable (and
// not part of the NativeCoverageExcludePaths product variable). Value "*" in
// NativeCoveragePaths represents any path.
func ( c * deviceConfig ) NativeCoverageEnabledForPath ( path string ) bool {
2017-02-27 18:01:54 +01:00
coverage := false
2020-07-09 17:58:14 +02:00
if len ( c . config . productVariables . NativeCoveragePaths ) > 0 {
2020-06-09 13:44:06 +02:00
if InList ( "*" , c . config . productVariables . NativeCoveragePaths ) || HasAnyPrefix ( path , c . config . productVariables . NativeCoveragePaths ) {
2017-07-13 23:46:05 +02:00
coverage = true
2017-02-10 01:16:31 +01:00
}
}
2020-07-09 17:58:14 +02:00
if coverage && len ( c . config . productVariables . NativeCoverageExcludePaths ) > 0 {
2020-06-09 13:44:06 +02:00
if HasAnyPrefix ( path , c . config . productVariables . NativeCoverageExcludePaths ) {
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
}
2020-05-17 18:28:35 +02:00
func ( c * deviceConfig ) SystemExtPublicSepolicyDirs ( ) [ ] string {
return c . config . productVariables . SystemExtPublicSepolicyDirs
2018-03-26 05:00:00 +02:00
}
2020-05-17 18:28:35 +02:00
func ( c * deviceConfig ) SystemExtPrivateSepolicyDirs ( ) [ ] string {
return c . config . productVariables . SystemExtPrivateSepolicyDirs
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 {
2020-07-09 17:58:14 +02:00
if len ( c . productVariables . IntegerOverflowExcludePaths ) == 0 {
2017-07-13 23:46:05 +02:00
return false
}
2020-02-11 16:54:35 +01:00
return HasAnyPrefix ( 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 {
2020-07-09 17:58:14 +02:00
if len ( c . productVariables . CFIExcludePaths ) == 0 {
2017-10-31 10:26:14 +01:00
return false
}
2020-02-11 16:54:35 +01:00
return HasAnyPrefix ( path , c . productVariables . CFIExcludePaths )
2017-10-31 10:26:14 +01:00
}
func ( c * config ) CFIEnabledForPath ( path string ) bool {
2020-07-09 17:58:14 +02:00
if len ( c . productVariables . CFIIncludePaths ) == 0 {
2017-10-31 10:26:14 +01:00
return false
}
2020-02-11 16:54:35 +01:00
return HasAnyPrefix ( 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 {
2019-11-23 01:03:51 +01:00
return soongconfig . Config ( c . productVariables . VendorVars [ name ] )
2018-03-26 21:41:18 +02:00
}
2018-10-25 01:10:32 +02:00
func ( c * config ) NdkAbis ( ) bool {
return Bool ( c . productVariables . Ndk_abis )
}
Add script for building all target arch's needed in AML (Android Mainline)
prebuilts.
This runs Soong in skip-make mode, using normal in-make mode only to query
platform versions.
The same ${OUT_DIR} cannot be used for both skip-make and in-make builds,
because Soong generates a smaller build.ninja file in in-make builds where
many build targets are expected to be provided by the mk files. Thus this
script avoids using ${OUT_DIR} if it's an in-make build, defaulting instead
to out-aml/.
The script is based on build-ndk-prebuilts.sh, but uses a separate Soong
variable Aml_abis to enable the appropriate target architectures for
Mainline modules. Aml_abis is very similar to Ndk_abis, except "armeabi-v7a"
is used instead of "armeabi", which is necessary to match prebuilt
dependencies, e.g. for LLVM.
Test: build/soong/scripts/build-aml-prebuilts.sh libart libdexfile_external
(verify that libraries for arm, arm64, x86, x86_64 are built)
Test: build/soong/scripts/build-aml-prebuilts.sh \
out-aml/soong/.intermediates/external/conscrypt/conscrypt-module-sdk/android_common/conscrypt-module-sdk-current.zip
(verify that the zip file contains libconscrypt_jni.so's for all four arches)
Test: build/soong/scripts/build-aml-prebuilts.sh com.android.art.{release,debug,testing,host}
(verify that the build completes)
Test: Two identical build/soong/scripts/build-aml-prebuilts.sh runs after each other
(verify that the 2nd run completes both Soong and ninja steps quickly without any building)
Change-Id: I35712f9f8f0b1cbb77107314c5927c6720e6c3bf
2019-11-15 16:00:31 +01:00
func ( c * config ) AmlAbis ( ) bool {
return Bool ( c . productVariables . Aml_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 )
}
2020-06-11 20:32:11 +02:00
func ( c * config ) EnforceSystemCertificateAllowList ( ) [ ] string {
return c . productVariables . EnforceSystemCertificateAllowList
2019-01-07 04:07:27 +01:00
}
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 ) 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 )
}
2020-01-22 01:12:26 +01:00
func ( c * deviceConfig ) BoardUsesRecoveryAsBoot ( ) bool {
return Bool ( c . config . productVariables . BoardUsesRecoveryAsBoot )
}
2020-07-29 18:51:57 +02:00
func ( c * deviceConfig ) BoardKernelBinaries ( ) [ ] string {
return c . config . productVariables . BoardKernelBinaries
}
2020-07-01 15:31:13 +02:00
2020-08-05 23:36:09 +02:00
func ( c * deviceConfig ) BoardKernelModuleInterfaceVersions ( ) [ ] string {
return c . config . productVariables . BoardKernelModuleInterfaceVersions
}
2020-10-22 00:40:17 +02:00
func ( c * deviceConfig ) BoardMoveRecoveryResourcesToVendorBoot ( ) bool {
return Bool ( c . config . productVariables . BoardMoveRecoveryResourcesToVendorBoot )
}
2020-07-01 15:31:13 +02:00
// The ConfiguredJarList struct provides methods for handling a list of (apex, jar) pairs.
// Such lists are used in the build system for things like bootclasspath jars or system server jars.
// The apex part is either an apex name, or a special names "platform" or "system_ext". Jar is a
// module name. The pairs come from Make product variables as a list of colon-separated strings.
//
// Examples:
// - "com.android.art:core-oj"
// - "platform:framework"
// - "system_ext:foo"
//
type ConfiguredJarList struct {
apexes [ ] string // A list of apex components.
jars [ ] string // A list of jar components.
}
// The length of the list.
func ( l * ConfiguredJarList ) Len ( ) int {
return len ( l . jars )
}
// Jar component of idx-th pair on the list.
func ( l * ConfiguredJarList ) Jar ( idx int ) string {
return l . jars [ idx ]
}
// If the list contains a pair with the given jar.
func ( l * ConfiguredJarList ) ContainsJar ( jar string ) bool {
return InList ( jar , l . jars )
}
// If the list contains the given (apex, jar) pair.
func ( l * ConfiguredJarList ) containsApexJarPair ( apex , jar string ) bool {
for i := 0 ; i < l . Len ( ) ; i ++ {
2020-10-23 19:28:55 +02:00
if apex == l . apexes [ i ] && jar == l . jars [ i ] {
2020-07-01 15:31:13 +02:00
return true
}
}
return false
}
// Index of the first pair with the given jar on the list, or -1 if none.
func ( l * ConfiguredJarList ) IndexOfJar ( jar string ) int {
return IndexList ( jar , l . jars )
}
// Append an (apex, jar) pair to the list.
2020-10-27 04:22:29 +01:00
func ( l * ConfiguredJarList ) Append ( apex string , jar string ) {
l . apexes = append ( l . apexes , apex )
l . jars = append ( l . jars , jar )
2020-07-01 15:31:13 +02:00
}
// Filter out sublist.
2020-10-27 04:22:29 +01:00
func ( l * ConfiguredJarList ) RemoveList ( list ConfiguredJarList ) {
2020-07-01 15:31:13 +02:00
apexes := make ( [ ] string , 0 , l . Len ( ) )
jars := make ( [ ] string , 0 , l . Len ( ) )
for i , jar := range l . jars {
2020-10-23 19:28:55 +02:00
apex := l . apexes [ i ]
2020-07-01 15:31:13 +02:00
if ! list . containsApexJarPair ( apex , jar ) {
apexes = append ( apexes , apex )
jars = append ( jars , jar )
}
}
2020-10-27 04:22:29 +01:00
l . apexes = apexes
l . jars = jars
}
// A copy of itself.
func ( l * ConfiguredJarList ) CopyOf ( ) ConfiguredJarList {
return ConfiguredJarList { CopyOf ( l . apexes ) , CopyOf ( l . jars ) }
2020-07-01 15:31:13 +02:00
}
// A copy of the list of strings containing jar components.
func ( l * ConfiguredJarList ) CopyOfJars ( ) [ ] string {
return CopyOf ( l . jars )
}
// A copy of the list of strings with colon-separated (apex, jar) pairs.
func ( l * ConfiguredJarList ) CopyOfApexJarPairs ( ) [ ] string {
pairs := make ( [ ] string , 0 , l . Len ( ) )
for i , jar := range l . jars {
2020-10-23 19:28:55 +02:00
apex := l . apexes [ i ]
2020-07-01 15:31:13 +02:00
pairs = append ( pairs , apex + ":" + jar )
}
return pairs
}
// A list of build paths based on the given directory prefix.
func ( l * ConfiguredJarList ) BuildPaths ( ctx PathContext , dir OutputPath ) WritablePaths {
paths := make ( WritablePaths , l . Len ( ) )
for i , jar := range l . jars {
paths [ i ] = dir . Join ( ctx , ModuleStem ( jar ) + ".jar" )
}
return paths
}
func ModuleStem ( module string ) string {
// b/139391334: the stem of framework-minus-apex is framework. This is hard coded here until we
// find a good way to query the stem of a module before any other mutators are run.
if module == "framework-minus-apex" {
return "framework"
}
return module
}
// A list of on-device paths.
func ( l * ConfiguredJarList ) DevicePaths ( cfg Config , ostype OsType ) [ ] string {
paths := make ( [ ] string , l . Len ( ) )
for i , jar := range l . jars {
apex := l . apexes [ i ]
name := ModuleStem ( jar ) + ".jar"
var subdir string
if apex == "platform" {
subdir = "system/framework"
} else if apex == "system_ext" {
subdir = "system_ext/framework"
} else {
subdir = filepath . Join ( "apex" , apex , "javalib" )
}
if ostype . Class == Host {
paths [ i ] = filepath . Join ( cfg . Getenv ( "OUT_DIR" ) , "host" , cfg . PrebuiltOS ( ) , subdir , name )
} else {
paths [ i ] = filepath . Join ( "/" , subdir , name )
}
}
return paths
}
// Expected format for apexJarValue = <apex name>:<jar name>
func splitConfiguredJarPair ( ctx PathContext , str string ) ( string , string ) {
pair := strings . SplitN ( str , ":" , 2 )
if len ( pair ) == 2 {
return pair [ 0 ] , pair [ 1 ]
} else {
2020-08-25 13:45:15 +02:00
ReportPathErrorf ( ctx , "malformed (apex, jar) pair: '%s', expected format: <apex>:<jar>" , str )
2020-07-01 15:31:13 +02:00
return "error-apex" , "error-jar"
}
}
func CreateConfiguredJarList ( ctx PathContext , list [ ] string ) ConfiguredJarList {
2020-10-27 04:22:29 +01:00
apexes := make ( [ ] string , 0 , len ( list ) )
jars := make ( [ ] string , 0 , len ( list ) )
l := ConfiguredJarList { apexes , jars }
2020-07-01 15:31:13 +02:00
2020-10-27 04:22:29 +01:00
for _ , apexjar := range list {
2020-07-01 15:31:13 +02:00
apex , jar := splitConfiguredJarPair ( ctx , apexjar )
2020-10-27 04:22:29 +01:00
l . Append ( apex , jar )
2020-07-01 15:31:13 +02:00
}
2020-10-27 04:22:29 +01:00
return l
2020-07-01 15:31:13 +02:00
}
func EmptyConfiguredJarList ( ) ConfiguredJarList {
return ConfiguredJarList { }
}
var earlyBootJarsKey = NewOnceKey ( "earlyBootJars" )
func ( c * config ) BootJars ( ) [ ] string {
return c . Once ( earlyBootJarsKey , func ( ) interface { } {
ctx := NullPathContext { Config { c } }
list := CreateConfiguredJarList ( ctx ,
append ( CopyOf ( c . productVariables . BootJars ) , c . productVariables . UpdatableBootJars ... ) )
return list . CopyOfJars ( )
} ) . ( [ ] string )
}