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
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// This is the primary location to write and read all configuration values and
|
|
|
|
// product variables necessary for soong_build's operation.
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
import (
|
2022-08-05 00:49:20 +02:00
|
|
|
"bytes"
|
2015-01-31 02:27:36 +01:00
|
|
|
"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"
|
2022-01-20 21:15:02 +01:00
|
|
|
"reflect"
|
2015-01-31 02:27:36 +01:00
|
|
|
"runtime"
|
2020-12-21 14:53:05 +01: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
|
|
|
|
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"
|
2021-05-12 20:51:49 +02:00
|
|
|
"android/soong/bazel"
|
2021-03-12 20:28:25 +01:00
|
|
|
"android/soong/remoteexec"
|
2022-02-03 14:42:10 +01:00
|
|
|
"android/soong/starlark_fmt"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// Bool re-exports proptools.Bool for the android package.
|
2015-12-18 01:39:19 +01:00
|
|
|
var Bool = proptools.Bool
|
2020-11-23 05:52:50 +01:00
|
|
|
|
|
|
|
// String re-exports proptools.String for the android package.
|
2016-12-09 00:45:07 +01:00
|
|
|
var String = proptools.String
|
2020-11-23 05:52:50 +01:00
|
|
|
|
|
|
|
// StringDefault re-exports proptools.StringDefault for the android package.
|
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-11-23 05:52:50 +01:00
|
|
|
// FutureApiLevelInt is a placeholder constant for unreleased API levels.
|
2020-07-24 01:43:25 +02:00
|
|
|
const FutureApiLevelInt = 10000
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// FutureApiLevel represents unreleased API levels.
|
2020-07-24 01:43:25 +02:00
|
|
|
var FutureApiLevel = ApiLevel{
|
|
|
|
value: "current",
|
|
|
|
number: FutureApiLevelInt,
|
|
|
|
isPreview: true,
|
|
|
|
}
|
2015-12-18 01:39:19 +01:00
|
|
|
|
2020-11-25 04:59:26 +01:00
|
|
|
// The product variables file name, containing product config from Kati.
|
2015-07-14 09:39:06 +02:00
|
|
|
const productVariablesFileName = "soong.variables"
|
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
|
|
|
|
}
|
|
|
|
|
2022-08-20 20:48:32 +02:00
|
|
|
type SoongBuildMode int
|
|
|
|
|
|
|
|
// Build modes that soong_build can run as.
|
|
|
|
const (
|
|
|
|
// Don't use bazel at all during module analysis.
|
|
|
|
AnalysisNoBazel SoongBuildMode = iota
|
|
|
|
|
|
|
|
// Bp2build mode: Generate BUILD files from blueprint files and exit.
|
|
|
|
Bp2build
|
|
|
|
|
|
|
|
// Generate BUILD files which faithfully represent the dependency graph of
|
|
|
|
// blueprint modules. Individual BUILD targets will not, however, faitfhully
|
|
|
|
// express build semantics.
|
|
|
|
GenerateQueryView
|
|
|
|
|
2022-09-28 22:43:08 +02:00
|
|
|
// Generate BUILD files for API contributions to API surfaces
|
|
|
|
ApiBp2build
|
|
|
|
|
2022-08-20 20:48:32 +02:00
|
|
|
// Create a JSON representation of the module graph and exit.
|
|
|
|
GenerateModuleGraph
|
|
|
|
|
|
|
|
// Generate a documentation file for module type definitions and exit.
|
|
|
|
GenerateDocFile
|
|
|
|
|
|
|
|
// Use bazel during analysis of many allowlisted build modules. The allowlist
|
|
|
|
// is considered a "developer mode" allowlist, as some modules may be
|
|
|
|
// allowlisted on an experimental basis.
|
|
|
|
BazelDevMode
|
|
|
|
|
|
|
|
// Use bazel during analysis of build modules from an allowlist carefully
|
|
|
|
// curated by the build team to be proven stable.
|
|
|
|
BazelProdMode
|
|
|
|
)
|
|
|
|
|
2021-08-31 10:42:08 +02:00
|
|
|
// SoongOutDir returns the build output directory for the configuration.
|
2021-08-26 15:07:24 +02:00
|
|
|
func (c Config) SoongOutDir() string {
|
|
|
|
return c.soongOutDir
|
2017-03-30 02:29:06 +02:00
|
|
|
}
|
|
|
|
|
2021-08-26 15:07:24 +02:00
|
|
|
func (c Config) OutDir() string {
|
2021-09-01 16:25:51 +02:00
|
|
|
return c.outDir
|
2021-03-12 08:31:32 +01:00
|
|
|
}
|
|
|
|
|
2021-09-02 09:58:09 +02:00
|
|
|
func (c Config) RunGoTests() bool {
|
|
|
|
return c.runGoTests
|
|
|
|
}
|
|
|
|
|
2021-03-17 15:03:14 +01:00
|
|
|
func (c Config) DebugCompilation() bool {
|
|
|
|
return false // Never compile Go code in the main build for debugging
|
|
|
|
}
|
|
|
|
|
2021-09-02 09:58:09 +02:00
|
|
|
func (c Config) Subninjas() []string {
|
|
|
|
return []string{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Config) PrimaryBuilderInvocations() []bootstrap.PrimaryBuilderInvocation {
|
|
|
|
return []bootstrap.PrimaryBuilderInvocation{}
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01: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.
|
2016-08-18 00:24:12 +02:00
|
|
|
type DeviceConfig struct {
|
|
|
|
*deviceConfig
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// VendorConfig represents the configuration for vendor-specific behavior.
|
2019-11-23 01:03:51 +01:00
|
|
|
type VendorConfig soongconfig.SoongConfig
|
2018-03-26 21:41:18 +02:00
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// Definition of general build configuration for soong_build. Some of these
|
2020-11-25 04:59:26 +01:00
|
|
|
// product configuration values are read from Kati-generated soong.variables.
|
2015-04-08 02:11:30 +02:00
|
|
|
type config struct {
|
2020-11-23 05:52:50 +01:00
|
|
|
// Options configurable with soong.variables
|
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-11-23 05:52:50 +01:00
|
|
|
// A specialized context object for Bazel/Soong mixed builds and migration
|
|
|
|
// purposes.
|
2020-09-29 08:23:17 +02:00
|
|
|
BazelContext BazelContext
|
|
|
|
|
2015-07-14 09:39:06 +02:00
|
|
|
ProductVariablesFileName string
|
|
|
|
|
2021-07-20 18:47:41 +02:00
|
|
|
// BuildOS stores the OsType for the OS that the build is running on.
|
|
|
|
BuildOS OsType
|
|
|
|
|
|
|
|
// BuildArch stores the ArchType for the CPU that the build is running on.
|
|
|
|
BuildArch ArchType
|
|
|
|
|
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
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// multilibConflicts for an ArchType is true if there is earlier configured
|
|
|
|
// device architecture with the same multilib value.
|
2019-09-17 23:45:31 +02:00
|
|
|
multilibConflicts map[ArchType]bool
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
deviceConfig *deviceConfig
|
|
|
|
|
2021-09-01 16:25:51 +02:00
|
|
|
outDir string // The output directory (usually out/)
|
|
|
|
soongOutDir string
|
2020-06-23 23:37:05 +02:00
|
|
|
moduleListFile string // the path to the file which lists blueprint files to parse.
|
2015-04-15 21:33:28 +02:00
|
|
|
|
2021-09-08 15:31:14 +02:00
|
|
|
runGoTests bool
|
2021-09-02 09:58:09 +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
|
|
|
|
2020-11-23 06:22:30 +01:00
|
|
|
// Changes behavior based on whether Kati runs after soong_build, or if soong_build
|
|
|
|
// runs standalone.
|
|
|
|
katiEnabled 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
|
|
|
|
2019-12-14 05:41:13 +01:00
|
|
|
fs pathtools.FileSystem
|
|
|
|
mockBpList string
|
|
|
|
|
2022-08-20 20:48:32 +02:00
|
|
|
BuildMode SoongBuildMode
|
2022-08-24 00:29:05 +02:00
|
|
|
Bp2buildPackageConfig Bp2BuildConversionAllowlist
|
2021-11-19 15:29:43 +01:00
|
|
|
Bp2buildSoongConfigDefinitions soongconfig.Bp2BuildSoongConfigDefinitions
|
2021-03-10 08:05:59 +01:00
|
|
|
|
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.
|
2021-02-15 16:41:33 +01:00
|
|
|
TestAllowNonExistentPaths bool
|
2020-06-08 01:56:32 +02:00
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// The list of files that when changed, must invalidate soong_build to
|
|
|
|
// regenerate build.ninja.
|
2020-10-30 02:23:58 +01:00
|
|
|
ninjaFileDepsSet sync.Map
|
|
|
|
|
2016-08-18 00:24:12 +02:00
|
|
|
OncePer
|
2022-04-21 20:33:17 +02:00
|
|
|
|
2022-08-20 20:48:32 +02:00
|
|
|
// These fields are only used for metrics collection. A module should be added
|
|
|
|
// to these maps only if its implementation supports Bazel handling in mixed
|
|
|
|
// builds. A module being in the "enabled" list indicates that there is a
|
|
|
|
// variant of that module for which bazel-handling actually took place.
|
|
|
|
// A module being in the "disabled" list indicates that there is a variant of
|
|
|
|
// that module for which bazel-handling was denied.
|
2022-04-21 20:33:17 +02:00
|
|
|
mixedBuildsLock sync.Mutex
|
|
|
|
mixedBuildEnabledModules map[string]struct{}
|
|
|
|
mixedBuildDisabledModules map[string]struct{}
|
2016-08-18 00:24:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
return loadFromConfigFile(&config.productVariables, absolutePath(config.ProductVariablesFileName))
|
2015-08-27 22:28:01 +02:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// loadFromConfigFile loads and decodes configuration options from a JSON file
|
|
|
|
// in the current working directory.
|
2021-05-12 20:51:49 +02:00
|
|
|
func loadFromConfigFile(configurable *productVariables, 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-12 20:51:49 +02:00
|
|
|
if Bool(configurable.GcovCoverage) && Bool(configurable.ClangCoverage) {
|
|
|
|
return fmt.Errorf("GcovCoverage and ClangCoverage cannot both be set")
|
|
|
|
}
|
|
|
|
|
|
|
|
configurable.Native_coverage = proptools.BoolPtr(
|
|
|
|
Bool(configurable.GcovCoverage) ||
|
|
|
|
Bool(configurable.ClangCoverage))
|
|
|
|
|
2021-08-10 00:44:44 +02:00
|
|
|
// when Platform_sdk_final is true (or PLATFORM_VERSION_CODENAME is REL), use Platform_sdk_version;
|
|
|
|
// if false (pre-released version, for example), use Platform_sdk_codename.
|
|
|
|
if Bool(configurable.Platform_sdk_final) {
|
|
|
|
if configurable.Platform_sdk_version != nil {
|
|
|
|
configurable.Platform_sdk_version_or_codename =
|
|
|
|
proptools.StringPtr(strconv.Itoa(*(configurable.Platform_sdk_version)))
|
|
|
|
} else {
|
|
|
|
return fmt.Errorf("Platform_sdk_version cannot be pointed by a NULL pointer")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
configurable.Platform_sdk_version_or_codename =
|
|
|
|
proptools.StringPtr(String(configurable.Platform_sdk_codename))
|
|
|
|
}
|
|
|
|
|
2021-05-12 20:51:49 +02:00
|
|
|
return saveToBazelConfigFile(configurable, filepath.Dir(filename))
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
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)
|
2021-05-12 20:51:49 +02:00
|
|
|
func saveToConfigFile(config *productVariables, 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 {
|
2020-11-23 05:52:50 +01:00
|
|
|
return fmt.Errorf("cannot create empty config file %s: %s", 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
|
|
|
|
}
|
|
|
|
|
2021-05-12 20:51:49 +02:00
|
|
|
func saveToBazelConfigFile(config *productVariables, outDir string) error {
|
|
|
|
dir := filepath.Join(outDir, bazel.SoongInjectionDirName, "product_config")
|
|
|
|
err := createDirIfNonexistent(dir, os.ModePerm)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Could not create dir %s: %s", dir, err)
|
|
|
|
}
|
|
|
|
|
2022-01-20 21:15:02 +01:00
|
|
|
nonArchVariantProductVariables := []string{}
|
|
|
|
archVariantProductVariables := []string{}
|
|
|
|
p := variableProperties{}
|
|
|
|
t := reflect.TypeOf(p.Product_variables)
|
|
|
|
for i := 0; i < t.NumField(); i++ {
|
|
|
|
f := t.Field(i)
|
|
|
|
nonArchVariantProductVariables = append(nonArchVariantProductVariables, strings.ToLower(f.Name))
|
|
|
|
if proptools.HasTag(f, "android", "arch_variant") {
|
|
|
|
archVariantProductVariables = append(archVariantProductVariables, strings.ToLower(f.Name))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 14:42:10 +01:00
|
|
|
nonArchVariantProductVariablesJson := starlark_fmt.PrintStringList(nonArchVariantProductVariables, 0)
|
2022-01-20 21:15:02 +01:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("cannot marshal product variable data: %s", err.Error())
|
|
|
|
}
|
|
|
|
|
2022-02-03 14:42:10 +01:00
|
|
|
archVariantProductVariablesJson := starlark_fmt.PrintStringList(archVariantProductVariables, 0)
|
2022-01-20 21:15:02 +01:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("cannot marshal arch variant product variable data: %s", err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
configJson, err := json.MarshalIndent(&config, "", " ")
|
2021-05-12 20:51:49 +02:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("cannot marshal config data: %s", err.Error())
|
|
|
|
}
|
2022-08-05 00:49:20 +02:00
|
|
|
// The backslashes need to be escaped because this text is going to be put
|
|
|
|
// inside a Starlark string literal.
|
|
|
|
configJson = bytes.ReplaceAll(configJson, []byte("\\"), []byte("\\\\"))
|
2021-05-12 20:51:49 +02:00
|
|
|
|
|
|
|
bzl := []string{
|
|
|
|
bazel.GeneratedBazelFileWarning,
|
2022-01-20 21:15:02 +01:00
|
|
|
fmt.Sprintf(`_product_vars = json.decode("""%s""")`, configJson),
|
|
|
|
fmt.Sprintf(`_product_var_constraints = %s`, nonArchVariantProductVariablesJson),
|
|
|
|
fmt.Sprintf(`_arch_variant_product_var_constraints = %s`, archVariantProductVariablesJson),
|
|
|
|
"\n", `
|
|
|
|
product_vars = _product_vars
|
|
|
|
product_var_constraints = _product_var_constraints
|
|
|
|
arch_variant_product_var_constraints = _arch_variant_product_var_constraints
|
|
|
|
`,
|
2021-05-12 20:51:49 +02:00
|
|
|
}
|
2022-08-05 00:49:20 +02:00
|
|
|
err = os.WriteFile(filepath.Join(dir, "product_variables.bzl"), []byte(strings.Join(bzl, "\n")), 0644)
|
2021-05-12 20:51:49 +02:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Could not write .bzl config file %s", err)
|
|
|
|
}
|
2022-08-05 00:49:20 +02:00
|
|
|
err = os.WriteFile(filepath.Join(dir, "BUILD"), []byte(bazel.GeneratedBazelFileWarning), 0644)
|
2021-05-12 20:51:49 +02:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Could not write BUILD config file %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2021-09-01 16:25:51 +02:00
|
|
|
func NullConfig(outDir, soongOutDir string) Config {
|
2020-01-11 02:11:46 +01:00
|
|
|
return Config{
|
|
|
|
config: &config{
|
2021-09-01 16:25:51 +02:00
|
|
|
outDir: outDir,
|
2021-08-26 15:07:24 +02:00
|
|
|
soongOutDir: soongOutDir,
|
|
|
|
fs: pathtools.OsFs,
|
2020-01-11 02:11:46 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// NewConfig creates a new Config object. The srcDir argument specifies the path
|
|
|
|
// to the root source directory. It also loads the config file, if found.
|
2022-08-20 20:48:32 +02:00
|
|
|
func NewConfig(moduleListFile string, buildMode SoongBuildMode, runGoTests bool, outDir, soongOutDir string, availableEnv map[string]string) (Config, error) {
|
2020-11-23 05:52:50 +01:00
|
|
|
// Make a config with default options.
|
2016-08-18 00:24:12 +02:00
|
|
|
config := &config{
|
2021-08-26 15:07:24 +02:00
|
|
|
ProductVariablesFileName: filepath.Join(soongOutDir, productVariablesFileName),
|
2016-08-18 00:24:12 +02:00
|
|
|
|
2021-04-12 14:04:24 +02:00
|
|
|
env: availableEnv,
|
2017-10-11 08:07:38 +02:00
|
|
|
|
2021-09-08 15:31:14 +02:00
|
|
|
outDir: outDir,
|
|
|
|
soongOutDir: soongOutDir,
|
|
|
|
runGoTests: runGoTests,
|
|
|
|
multilibConflicts: make(map[ArchType]bool),
|
2019-12-14 05:41:13 +01:00
|
|
|
|
2022-04-21 20:33:17 +02:00
|
|
|
moduleListFile: moduleListFile,
|
|
|
|
fs: pathtools.NewOsFs(absSrcDir),
|
|
|
|
mixedBuildDisabledModules: make(map[string]struct{}),
|
|
|
|
mixedBuildEnabledModules: make(map[string]struct{}),
|
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.
|
2021-08-26 15:07:24 +02:00
|
|
|
absBuildDir, err := filepath.Abs(soongOutDir)
|
2015-09-24 00:26:20 +02:00
|
|
|
if err != nil {
|
|
|
|
return Config{}, err
|
|
|
|
}
|
|
|
|
|
2021-08-16 17:05:09 +02:00
|
|
|
absSrcDir, err := filepath.Abs(".")
|
2015-09-24 00:26:20 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-08-26 15:07:24 +02:00
|
|
|
KatiEnabledMarkerFile := filepath.Join(soongOutDir, ".soong.kati_enabled")
|
2020-11-23 06:22:30 +01:00
|
|
|
if _, err := os.Stat(absolutePath(KatiEnabledMarkerFile)); err == nil {
|
|
|
|
config.katiEnabled = true
|
2015-12-11 22:51:06 +01:00
|
|
|
}
|
|
|
|
|
2021-07-20 18:47:41 +02:00
|
|
|
determineBuildOS(config)
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// Sets up the map of target OSes to the finer grained compilation targets
|
|
|
|
// that are configured from the product variables.
|
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
|
2020-11-25 04:59:26 +01:00
|
|
|
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 {
|
2022-02-28 20:16:16 +01:00
|
|
|
androidTargets, err := decodeAndroidArchSettings(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
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// Map of OS to compilation targets.
|
2016-06-02 02:09:44 +02:00
|
|
|
config.Targets = targets
|
2020-11-23 05:52:50 +01:00
|
|
|
|
|
|
|
// Compilation targets for host tools.
|
2021-07-20 18:47:41 +02:00
|
|
|
config.BuildOSTarget = config.Targets[config.BuildOS][0]
|
|
|
|
config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0]
|
2020-11-23 05:52:50 +01:00
|
|
|
|
|
|
|
// Compilation targets for Android.
|
2019-10-16 20:03:10 +02:00
|
|
|
if len(config.Targets[Android]) > 0 {
|
|
|
|
config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0]
|
2022-06-01 17:45:02 +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
|
|
|
|
2022-08-20 20:48:32 +02:00
|
|
|
config.BuildMode = buildMode
|
2020-09-29 08:23:17 +02:00
|
|
|
config.BazelContext, err = NewBazelContext(config)
|
2022-08-24 00:29:05 +02:00
|
|
|
config.Bp2buildPackageConfig = GetBp2BuildAllowList()
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
return Config{config}, err
|
|
|
|
}
|
2020-01-11 02:11:46 +01:00
|
|
|
|
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)
|
2021-09-02 11:46:24 +02:00
|
|
|
if base == "Android.bp" {
|
2019-12-14 05:41:13 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-08-20 20:48:32 +02:00
|
|
|
// Returns true if "Bazel builds" is enabled. In this mode, part of build
|
|
|
|
// analysis is handled by Bazel.
|
|
|
|
func (c *config) IsMixedBuildsEnabled() bool {
|
|
|
|
return c.BuildMode == BazelProdMode || c.BuildMode == BazelDevMode
|
|
|
|
}
|
|
|
|
|
2021-03-16 08:55:23 +01:00
|
|
|
func (c *config) SetAllowMissingDependencies() {
|
|
|
|
c.productVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// BlueprintToolLocation returns the directory containing build system tools
|
|
|
|
// from Blueprint, like soong_zip and merge_zips.
|
2021-09-01 08:57:48 +02:00
|
|
|
func (c *config) HostToolDir() string {
|
2021-10-26 00:40:32 +02:00
|
|
|
if c.KatiEnabled() {
|
|
|
|
return filepath.Join(c.outDir, "host", c.PrebuiltOS(), "bin")
|
|
|
|
} else {
|
|
|
|
return filepath.Join(c.soongOutDir, "host", c.PrebuiltOS(), "bin")
|
|
|
|
}
|
2016-05-27 00:13:03 +02:00
|
|
|
}
|
|
|
|
|
2018-11-17 06:05:32 +01:00
|
|
|
func (c *config) HostToolPath(ctx PathContext, tool string) Path {
|
2021-10-26 04:15:55 +02:00
|
|
|
path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin", false, tool)
|
|
|
|
return path
|
2018-11-17 06:05:32 +01:00
|
|
|
}
|
|
|
|
|
2021-10-26 04:15:55 +02:00
|
|
|
func (c *config) HostJNIToolPath(ctx PathContext, lib string) Path {
|
2019-12-09 22:47:14 +01:00
|
|
|
ext := ".so"
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
ext = ".dylib"
|
|
|
|
}
|
2021-10-26 04:15:55 +02:00
|
|
|
path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "lib64", false, lib+ext)
|
|
|
|
return path
|
2019-12-09 22:47:14 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:31:22 +01:00
|
|
|
func (c *config) HostJavaToolPath(ctx PathContext, tool string) Path {
|
|
|
|
path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "framework", false, tool)
|
2021-11-04 18:22:51 +01:00
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +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 {
|
2021-08-16 17:05:09 +02:00
|
|
|
return fmt.Sprintf("prebuilts/go/%s", c.PrebuiltOS())
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// PrebuiltBuildTool returns the path to a tool in the prebuilts directory containing
|
|
|
|
// checked-in tools, like Kati, Ninja or Toybox, for the current host OS.
|
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)
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// CpPreserveSymlinksFlags returns the host-specific flag for the cp(1) command
|
|
|
|
// to preserve symlinks.
|
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"
|
|
|
|
}
|
|
|
|
|
2022-05-24 13:13:50 +02:00
|
|
|
func (c *config) TargetsJava17() bool {
|
|
|
|
return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_17")
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// EnvDeps returns the environment variables this build depends on. The first
|
|
|
|
// call to this function blocks future reads from the environment.
|
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
|
|
|
|
2020-11-23 06:22:30 +01:00
|
|
|
func (c *config) KatiEnabled() bool {
|
|
|
|
return c.katiEnabled
|
2015-12-11 22:51:06 +01:00
|
|
|
}
|
|
|
|
|
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-11-23 05:52:50 +01:00
|
|
|
// BuildNumberFile returns the path to a text file containing metadata
|
|
|
|
// representing the current build's number.
|
|
|
|
//
|
|
|
|
// Rules that want to reference the build number should read from this file
|
|
|
|
// without depending on it. They will run whenever their other dependencies
|
|
|
|
// require them to run and get the current build number. This ensures they don't
|
|
|
|
// rebuild on every incremental build when the build number changes.
|
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
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// DeviceName returns the name of the current device target.
|
2015-04-02 23:37:16 +02:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2022-03-21 20:34:02 +01:00
|
|
|
// DeviceProduct returns the current product target. There could be multiple of
|
|
|
|
// these per device type.
|
|
|
|
//
|
2022-08-19 04:04:11 +02:00
|
|
|
// NOTE: Do not base conditional logic on this value. It may break product inheritance.
|
2022-03-21 20:34:02 +01:00
|
|
|
func (c *config) DeviceProduct() string {
|
|
|
|
return *c.productVariables.DeviceProduct
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-07-27 04:32:03 +02:00
|
|
|
func (c *config) PlatformSdkFinal() bool {
|
|
|
|
return Bool(c.productVariables.Platform_sdk_final)
|
|
|
|
}
|
|
|
|
|
2018-04-18 20:06:47 +02:00
|
|
|
func (c *config) PlatformSdkCodename() string {
|
|
|
|
return String(c.productVariables.Platform_sdk_codename)
|
|
|
|
}
|
|
|
|
|
2022-02-16 17:15:10 +01:00
|
|
|
func (c *config) PlatformSdkExtensionVersion() int {
|
|
|
|
return *c.productVariables.Platform_sdk_extension_version
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) PlatformBaseSdkExtensionVersion() int {
|
|
|
|
return *c.productVariables.Platform_base_sdk_extension_version
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2022-04-25 11:23:58 +02:00
|
|
|
func (c *config) PlatformVersionLastStable() string {
|
|
|
|
return String(c.productVariables.Platform_version_last_stable)
|
|
|
|
}
|
|
|
|
|
2022-06-21 03:13:42 +02:00
|
|
|
func (c *config) PlatformVersionKnownCodenames() string {
|
|
|
|
return String(c.productVariables.Platform_version_known_codenames)
|
|
|
|
}
|
|
|
|
|
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 {
|
2022-08-17 22:11:57 +02:00
|
|
|
return uncheckedFinalApiLevel(21)
|
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) 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
|
|
|
|
}
|
|
|
|
|
2021-11-30 13:33:55 +01:00
|
|
|
func (c *config) LatestPreviewApiLevel() ApiLevel {
|
|
|
|
level := NoneApiLevel
|
|
|
|
for _, l := range c.PreviewApiLevels() {
|
|
|
|
if l.GreaterThan(level) {
|
|
|
|
level = l
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return level
|
|
|
|
}
|
|
|
|
|
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) AllSupportedApiLevels() []ApiLevel {
|
|
|
|
var levels []ApiLevel
|
|
|
|
levels = append(levels, c.FinalApiLevels()...)
|
|
|
|
return append(levels, c.PreviewApiLevels()...)
|
2017-08-18 01:19:59 +02:00
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// DefaultAppTargetSdk returns the API level that platform apps are targeting.
|
|
|
|
// This converts a codename to the exact ApiLevel it represents.
|
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()
|
|
|
|
}
|
2020-11-23 05:52:50 +01: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))
|
|
|
|
}
|
2020-11-23 05:52:50 +01:00
|
|
|
return PathForSource(ctx, "build/make/target/product/security")
|
2015-04-13 22:58:27 +02:00
|
|
|
}
|
|
|
|
|
2017-12-14 20:22:55 +01:00
|
|
|
func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) {
|
2018-03-10 06:22:06 +01:00
|
|
|
defaultCert := String(c.productVariables.DefaultAppCertificate)
|
2017-12-02 02:16:02 +01:00
|
|
|
if defaultCert != "" {
|
2017-12-14 20:22:55 +01:00
|
|
|
return PathForSource(ctx, defaultCert+".x509.pem"), PathForSource(ctx, defaultCert+".pk8")
|
2017-12-02 02:16:02 +01:00
|
|
|
}
|
2020-11-23 05:52:50 +01:00
|
|
|
defaultDir := c.DefaultAppCertificateDir(ctx)
|
|
|
|
return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8")
|
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
|
|
|
}
|
2020-11-23 05:52:50 +01:00
|
|
|
// If not, APEX keys are under the specified directory
|
|
|
|
return PathForSource(ctx, filepath.Dir(defaultCert))
|
2018-12-24 03:31:58 +01:00
|
|
|
}
|
|
|
|
|
2022-08-12 14:36:25 +02:00
|
|
|
// Certificate for the NetworkStack sepolicy context
|
|
|
|
func (c *config) MainlineSepolicyDevCertificatesDir(ctx ModuleContext) SourcePath {
|
|
|
|
cert := String(c.productVariables.MainlineSepolicyDevCertificates)
|
|
|
|
if cert != "" {
|
|
|
|
return PathForSource(ctx, cert)
|
|
|
|
}
|
|
|
|
return c.DefaultAppCertificateDir(ctx)
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// AllowMissingDependencies configures Blueprint/Soong to not fail when modules
|
|
|
|
// are configured to depend on non-existent modules. Note that this does not
|
|
|
|
// affect missing input dependencies at the Ninja level.
|
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 {
|
2021-11-24 04:02:08 +01:00
|
|
|
return len(c.productVariables.Unbundled_build_apps) > 0
|
2020-06-17 02:13:15 +02:00
|
|
|
}
|
|
|
|
|
2021-06-08 04:35:00 +02:00
|
|
|
// Returns true if building image that aren't bundled with the platform.
|
|
|
|
// UnbundledBuild() is always true when this is true.
|
|
|
|
func (c *config) UnbundledBuildImage() bool {
|
|
|
|
return Bool(c.productVariables.Unbundled_build_image)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2021-12-09 00:42:22 +01:00
|
|
|
// DevicePrimaryArchType returns the ArchType for the first configured device architecture, or
|
|
|
|
// Common if there are no device architectures.
|
2018-07-07 11:02:07 +02:00
|
|
|
func (c *config) DevicePrimaryArchType() ArchType {
|
2021-12-09 00:42:22 +01:00
|
|
|
if androidTargets := c.Targets[Android]; len(androidTargets) > 0 {
|
|
|
|
return androidTargets[0].Arch.ArchType
|
|
|
|
}
|
|
|
|
return Common
|
2018-07-07 11:02:07 +02: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
|
|
|
|
}
|
2020-11-23 05:52:50 +01:00
|
|
|
return *c.productVariables.EnableCFI
|
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")
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// XrefCorpusName returns the Kythe cross-reference corpus name.
|
2018-11-06 01:49:08 +01:00
|
|
|
func (c *config) XrefCorpusName() string {
|
|
|
|
return c.Getenv("XREF_CORPUS")
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// XrefCuEncoding returns the compilation unit encoding to use for Kythe code
|
|
|
|
// xrefs. Can be 'json' (default), 'proto' or 'all'.
|
2020-01-10 02:34:23 +01:00
|
|
|
func (c *config) XrefCuEncoding() string {
|
|
|
|
if enc := c.Getenv("KYTHE_KZIP_ENCODING"); enc != "" {
|
|
|
|
return enc
|
|
|
|
}
|
|
|
|
return "json"
|
|
|
|
}
|
|
|
|
|
2021-02-16 19:39:40 +01:00
|
|
|
// XrefCuJavaSourceMax returns the maximum number of the Java source files
|
|
|
|
// in a single compilation unit
|
|
|
|
const xrefJavaSourceFileMaxDefault = "1000"
|
|
|
|
|
|
|
|
func (c Config) XrefCuJavaSourceMax() string {
|
|
|
|
v := c.Getenv("KYTHE_JAVA_SOURCE_BATCH_SIZE")
|
|
|
|
if v == "" {
|
|
|
|
return xrefJavaSourceFileMaxDefault
|
|
|
|
}
|
|
|
|
if _, err := strconv.ParseUint(v, 0, 0); err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr,
|
|
|
|
"bad KYTHE_JAVA_SOURCE_BATCH_SIZE value: %s, will use %s",
|
|
|
|
err, xrefJavaSourceFileMaxDefault)
|
|
|
|
return xrefJavaSourceFileMaxDefault
|
|
|
|
}
|
|
|
|
return v
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// Enforce Runtime Resource Overlays for a module. RROs supersede static RROs,
|
|
|
|
// but some modules still depend on it.
|
|
|
|
//
|
|
|
|
// More info: https://source.android.com/devices/architecture/rros
|
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
|
2021-02-19 04:11:51 +01:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
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-11-23 05:52:50 +01:00
|
|
|
// DexpreoptGlobalConfigPath returns the path to the dexpreopt.config file in
|
|
|
|
// the output directory, if it was created during the product configuration
|
|
|
|
// phase by Kati.
|
2020-11-02 06:24:57 +01:00
|
|
|
func (c *config) DexpreoptGlobalConfigPath(ctx PathContext) OptionalPath {
|
2020-01-11 02:11:46 +01:00
|
|
|
if c.productVariables.DexpreoptGlobalConfig == nil {
|
2020-11-02 06:24:57 +01:00
|
|
|
return OptionalPathForPath(nil)
|
|
|
|
}
|
|
|
|
return OptionalPathForPath(
|
|
|
|
pathForBuildToolDep(ctx, *c.productVariables.DexpreoptGlobalConfig))
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// DexpreoptGlobalConfig returns the raw byte contents of the dexpreopt global
|
|
|
|
// configuration. Since the configuration file was created by Kati during
|
|
|
|
// product configuration (externally of soong_build), it's not tracked, so we
|
|
|
|
// also manually add a Ninja file dependency on the configuration file to the
|
|
|
|
// rule that creates the main build.ninja file. This ensures that build.ninja is
|
|
|
|
// regenerated correctly if dexpreopt.config changes.
|
2020-11-02 06:24:57 +01:00
|
|
|
func (c *config) DexpreoptGlobalConfig(ctx PathContext) ([]byte, error) {
|
|
|
|
path := c.DexpreoptGlobalConfigPath(ctx)
|
|
|
|
if !path.Valid() {
|
2020-01-11 02:11:46 +01:00
|
|
|
return nil, nil
|
|
|
|
}
|
2020-11-02 06:24:57 +01:00
|
|
|
ctx.AddNinjaFileDeps(path.String())
|
|
|
|
return ioutil.ReadFile(absolutePath(path.String()))
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
|
|
|
|
2021-03-23 12:52:24 +01:00
|
|
|
func (c *deviceConfig) WithDexpreopt() bool {
|
|
|
|
return c.config.productVariables.WithDexpreopt
|
|
|
|
}
|
|
|
|
|
2019-01-23 22:04:05 +01:00
|
|
|
func (c *config) FrameworksBaseDirExists(ctx PathContext) bool {
|
2021-03-17 00:34:46 +01:00
|
|
|
return ExistentPathForSource(ctx, "frameworks", "base", "Android.bp").Valid()
|
2019-01-23 22:04:05 +01:00
|
|
|
}
|
|
|
|
|
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]
|
|
|
|
}
|
|
|
|
|
2021-01-08 18:34:44 +01:00
|
|
|
func (c *config) PrebuiltHiddenApiDir(ctx PathContext) string {
|
|
|
|
return String(c.productVariables.PrebuiltHiddenApiDir)
|
|
|
|
}
|
|
|
|
|
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-12-11 22:36:29 +01:00
|
|
|
func (c *deviceConfig) RecoverySnapshotVersion() string {
|
|
|
|
return String(c.config.productVariables.RecoverySnapshotVersion)
|
|
|
|
}
|
|
|
|
|
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-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
|
|
|
|
2022-01-27 07:14:32 +01:00
|
|
|
func (c *deviceConfig) ClangCoverageContinuousMode() bool {
|
|
|
|
return Bool(c.config.productVariables.ClangCoverageContinuousMode)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-12-09 11:06:29 +01:00
|
|
|
func (c *deviceConfig) AfdoAdditionalProfileDirs() []string {
|
|
|
|
return c.config.productVariables.AfdoAdditionalProfileDirs
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-03-21 21:11:16 +01:00
|
|
|
func (c *deviceConfig) ApexGlobalMinSdkVersionOverride() string {
|
|
|
|
return String(c.config.productVariables.ApexGlobalMinSdkVersionOverride)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
2021-04-09 23:33:10 +02:00
|
|
|
return HasAnyPrefix(path, c.productVariables.CFIIncludePaths) && !c.CFIDisabledForPath(path)
|
2017-10-31 10:26:14 +01:00
|
|
|
}
|
2017-12-04 20:24:31 +01:00
|
|
|
|
2021-01-06 01:41:26 +01:00
|
|
|
func (c *config) MemtagHeapDisabledForPath(path string) bool {
|
|
|
|
if len(c.productVariables.MemtagHeapExcludePaths) == 0 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return HasAnyPrefix(path, c.productVariables.MemtagHeapExcludePaths)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) MemtagHeapAsyncEnabledForPath(path string) bool {
|
|
|
|
if len(c.productVariables.MemtagHeapAsyncIncludePaths) == 0 {
|
|
|
|
return false
|
|
|
|
}
|
2021-04-09 23:33:10 +02:00
|
|
|
return HasAnyPrefix(path, c.productVariables.MemtagHeapAsyncIncludePaths) && !c.MemtagHeapDisabledForPath(path)
|
2021-01-06 01:41:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) MemtagHeapSyncEnabledForPath(path string) bool {
|
|
|
|
if len(c.productVariables.MemtagHeapSyncIncludePaths) == 0 {
|
|
|
|
return false
|
|
|
|
}
|
2021-04-09 23:33:10 +02:00
|
|
|
return HasAnyPrefix(path, c.productVariables.MemtagHeapSyncIncludePaths) && !c.MemtagHeapDisabledForPath(path)
|
2021-01-06 01:41:26 +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-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
|
|
|
}
|
|
|
|
|
2021-01-05 13:01:11 +01:00
|
|
|
func (c *config) ForceApexSymlinkOptimization() bool {
|
|
|
|
return Bool(c.productVariables.ForceApexSymlinkOptimization)
|
|
|
|
}
|
|
|
|
|
2022-07-27 23:51:45 +02:00
|
|
|
func (c *config) ApexCompressionEnabled() bool {
|
|
|
|
return Bool(c.productVariables.CompressedApex) && !c.UnbundledBuildApps()
|
2020-11-26 14:32:26 +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)
|
|
|
|
}
|
|
|
|
|
2020-10-19 10:25:58 +02:00
|
|
|
func (c *config) EnforceInterPartitionJavaSdkLibrary() bool {
|
|
|
|
return Bool(c.productVariables.EnforceInterPartitionJavaSdkLibrary)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) InterPartitionJavaLibraryAllowList() []string {
|
|
|
|
return c.productVariables.InterPartitionJavaLibraryAllowList
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-05-16 21:28:22 +02:00
|
|
|
func (c *config) MissingUsesLibraries() []string {
|
|
|
|
return c.productVariables.MissingUsesLibraries
|
|
|
|
}
|
|
|
|
|
2022-04-27 03:30:34 +02:00
|
|
|
func (c *config) TargetMultitreeUpdateMeta() bool {
|
|
|
|
return c.productVariables.MultitreeUpdateMeta
|
|
|
|
}
|
|
|
|
|
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-12-09 15:08:17 +01:00
|
|
|
func (c *deviceConfig) PlatformSepolicyVersion() string {
|
|
|
|
return String(c.config.productVariables.PlatformSepolicyVersion)
|
|
|
|
}
|
|
|
|
|
2021-09-15 05:04:53 +02:00
|
|
|
func (c *deviceConfig) TotSepolicyVersion() string {
|
|
|
|
return String(c.config.productVariables.TotSepolicyVersion)
|
|
|
|
}
|
|
|
|
|
2022-01-07 01:11:23 +01:00
|
|
|
func (c *deviceConfig) PlatformSepolicyCompatVersions() []string {
|
|
|
|
return c.config.productVariables.PlatformSepolicyCompatVersions
|
|
|
|
}
|
|
|
|
|
2020-12-09 15:08:17 +01:00
|
|
|
func (c *deviceConfig) BoardSepolicyVers() string {
|
2021-03-22 14:33:40 +01:00
|
|
|
if ver := String(c.config.productVariables.BoardSepolicyVers); ver != "" {
|
|
|
|
return ver
|
|
|
|
}
|
|
|
|
return c.PlatformSepolicyVersion()
|
2020-12-09 15:08:17 +01:00
|
|
|
}
|
|
|
|
|
2021-12-08 14:53:31 +01:00
|
|
|
func (c *deviceConfig) BoardPlatVendorPolicy() []string {
|
|
|
|
return c.config.productVariables.BoardPlatVendorPolicy
|
|
|
|
}
|
|
|
|
|
2020-12-09 15:08:17 +01:00
|
|
|
func (c *deviceConfig) BoardReqdMaskPolicy() []string {
|
|
|
|
return c.config.productVariables.BoardReqdMaskPolicy
|
|
|
|
}
|
|
|
|
|
2021-12-15 14:48:14 +01:00
|
|
|
func (c *deviceConfig) BoardSystemExtPublicPrebuiltDirs() []string {
|
|
|
|
return c.config.productVariables.BoardSystemExtPublicPrebuiltDirs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) BoardSystemExtPrivatePrebuiltDirs() []string {
|
|
|
|
return c.config.productVariables.BoardSystemExtPrivatePrebuiltDirs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) BoardProductPublicPrebuiltDirs() []string {
|
|
|
|
return c.config.productVariables.BoardProductPublicPrebuiltDirs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) BoardProductPrivatePrebuiltDirs() []string {
|
|
|
|
return c.config.productVariables.BoardProductPrivatePrebuiltDirs
|
|
|
|
}
|
|
|
|
|
2022-02-14 15:10:51 +01:00
|
|
|
func (c *deviceConfig) SystemExtSepolicyPrebuiltApiDir() string {
|
|
|
|
return String(c.config.productVariables.SystemExtSepolicyPrebuiltApiDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) ProductSepolicyPrebuiltApiDir() string {
|
|
|
|
return String(c.config.productVariables.ProductSepolicyPrebuiltApiDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) IsPartnerTrebleSepolicyTestEnabled() bool {
|
|
|
|
return c.SystemExtSepolicyPrebuiltApiDir() != "" || c.ProductSepolicyPrebuiltApiDir() != ""
|
|
|
|
}
|
|
|
|
|
2021-01-06 15:06:52 +01:00
|
|
|
func (c *deviceConfig) DirectedVendorSnapshot() bool {
|
|
|
|
return c.config.productVariables.DirectedVendorSnapshot
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) VendorSnapshotModules() map[string]bool {
|
|
|
|
return c.config.productVariables.VendorSnapshotModules
|
|
|
|
}
|
|
|
|
|
2021-02-09 16:44:30 +01:00
|
|
|
func (c *deviceConfig) DirectedRecoverySnapshot() bool {
|
|
|
|
return c.config.productVariables.DirectedRecoverySnapshot
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) RecoverySnapshotModules() map[string]bool {
|
|
|
|
return c.config.productVariables.RecoverySnapshotModules
|
|
|
|
}
|
|
|
|
|
2021-02-24 19:49:43 +01:00
|
|
|
func createDirsMap(previous map[string]bool, dirs []string) (map[string]bool, error) {
|
|
|
|
var ret = make(map[string]bool)
|
|
|
|
for _, dir := range dirs {
|
|
|
|
clean := filepath.Clean(dir)
|
|
|
|
if previous[clean] || ret[clean] {
|
|
|
|
return nil, fmt.Errorf("Duplicate entry %s", dir)
|
|
|
|
}
|
|
|
|
ret[clean] = true
|
|
|
|
}
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) createDirsMapOnce(onceKey OnceKey, previous map[string]bool, dirs []string) map[string]bool {
|
|
|
|
dirMap := c.Once(onceKey, func() interface{} {
|
|
|
|
ret, err := createDirsMap(previous, dirs)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Errorf("%s: %w", onceKey.key, err))
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
})
|
|
|
|
if dirMap == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return dirMap.(map[string]bool)
|
|
|
|
}
|
|
|
|
|
|
|
|
var vendorSnapshotDirsExcludedKey = NewOnceKey("VendorSnapshotDirsExcludedMap")
|
|
|
|
|
|
|
|
func (c *deviceConfig) VendorSnapshotDirsExcludedMap() map[string]bool {
|
|
|
|
return c.createDirsMapOnce(vendorSnapshotDirsExcludedKey, nil,
|
|
|
|
c.config.productVariables.VendorSnapshotDirsExcluded)
|
|
|
|
}
|
|
|
|
|
|
|
|
var vendorSnapshotDirsIncludedKey = NewOnceKey("VendorSnapshotDirsIncludedMap")
|
|
|
|
|
|
|
|
func (c *deviceConfig) VendorSnapshotDirsIncludedMap() map[string]bool {
|
|
|
|
excludedMap := c.VendorSnapshotDirsExcludedMap()
|
|
|
|
return c.createDirsMapOnce(vendorSnapshotDirsIncludedKey, excludedMap,
|
|
|
|
c.config.productVariables.VendorSnapshotDirsIncluded)
|
|
|
|
}
|
|
|
|
|
|
|
|
var recoverySnapshotDirsExcludedKey = NewOnceKey("RecoverySnapshotDirsExcludedMap")
|
|
|
|
|
|
|
|
func (c *deviceConfig) RecoverySnapshotDirsExcludedMap() map[string]bool {
|
|
|
|
return c.createDirsMapOnce(recoverySnapshotDirsExcludedKey, nil,
|
|
|
|
c.config.productVariables.RecoverySnapshotDirsExcluded)
|
|
|
|
}
|
|
|
|
|
|
|
|
var recoverySnapshotDirsIncludedKey = NewOnceKey("RecoverySnapshotDirsIncludedMap")
|
|
|
|
|
|
|
|
func (c *deviceConfig) RecoverySnapshotDirsIncludedMap() map[string]bool {
|
|
|
|
excludedMap := c.RecoverySnapshotDirsExcludedMap()
|
|
|
|
return c.createDirsMapOnce(recoverySnapshotDirsIncludedKey, excludedMap,
|
|
|
|
c.config.productVariables.RecoverySnapshotDirsIncluded)
|
|
|
|
}
|
|
|
|
|
2021-08-10 22:42:03 +02:00
|
|
|
func (c *deviceConfig) HostFakeSnapshotEnabled() bool {
|
|
|
|
return c.config.productVariables.HostFakeSnapshotEnabled
|
|
|
|
}
|
|
|
|
|
2020-12-21 14:53:05 +01:00
|
|
|
func (c *deviceConfig) ShippingApiLevel() ApiLevel {
|
|
|
|
if c.config.productVariables.ShippingApiLevel == nil {
|
|
|
|
return NoneApiLevel
|
|
|
|
}
|
|
|
|
apiLevel, _ := strconv.Atoi(*c.config.productVariables.ShippingApiLevel)
|
|
|
|
return uncheckedFinalApiLevel(apiLevel)
|
|
|
|
}
|
|
|
|
|
2022-09-14 21:10:51 +02:00
|
|
|
func (c *deviceConfig) BuildBrokenClangAsFlags() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenClangAsFlags
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) BuildBrokenClangCFlags() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenClangCFlags
|
|
|
|
}
|
|
|
|
|
2022-04-21 01:00:58 +02:00
|
|
|
func (c *deviceConfig) BuildBrokenClangProperty() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenClangProperty
|
|
|
|
}
|
|
|
|
|
2021-03-17 10:05:33 +01:00
|
|
|
func (c *deviceConfig) BuildBrokenEnforceSyspropOwner() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenEnforceSyspropOwner
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) BuildBrokenTrebleSyspropNeverallow() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenTrebleSyspropNeverallow
|
|
|
|
}
|
|
|
|
|
2021-04-03 01:45:24 +02:00
|
|
|
func (c *deviceConfig) BuildDebugfsRestrictionsEnabled() bool {
|
|
|
|
return c.config.productVariables.BuildDebugfsRestrictionsEnabled
|
|
|
|
}
|
|
|
|
|
2021-02-03 10:16:46 +01:00
|
|
|
func (c *deviceConfig) BuildBrokenVendorPropertyNamespace() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenVendorPropertyNamespace
|
|
|
|
}
|
|
|
|
|
2022-01-28 21:13:39 +01:00
|
|
|
func (c *deviceConfig) BuildBrokenInputDir(name string) bool {
|
|
|
|
return InList(name, c.config.productVariables.BuildBrokenInputDirModules)
|
|
|
|
}
|
|
|
|
|
2022-06-10 20:23:27 +02:00
|
|
|
func (c *deviceConfig) BuildBrokenDepfile() bool {
|
|
|
|
return Bool(c.config.productVariables.BuildBrokenDepfile)
|
|
|
|
}
|
|
|
|
|
2021-03-17 10:05:33 +01:00
|
|
|
func (c *deviceConfig) RequiresInsecureExecmemForSwiftshader() bool {
|
|
|
|
return c.config.productVariables.RequiresInsecureExecmemForSwiftshader
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) SelinuxIgnoreNeverallows() bool {
|
|
|
|
return c.productVariables.SelinuxIgnoreNeverallows
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) SepolicySplit() bool {
|
|
|
|
return c.config.productVariables.SepolicySplit
|
|
|
|
}
|
|
|
|
|
2021-09-15 05:04:53 +02:00
|
|
|
func (c *deviceConfig) SepolicyFreezeTestExtraDirs() []string {
|
|
|
|
return c.config.productVariables.SepolicyFreezeTestExtraDirs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *deviceConfig) SepolicyFreezeTestExtraPrebuiltDirs() []string {
|
|
|
|
return c.config.productVariables.SepolicyFreezeTestExtraPrebuiltDirs
|
|
|
|
}
|
|
|
|
|
2021-10-12 09:47:43 +02:00
|
|
|
func (c *deviceConfig) GenerateAidlNdkPlatformBackend() bool {
|
|
|
|
return c.config.productVariables.GenerateAidlNdkPlatformBackend
|
|
|
|
}
|
|
|
|
|
2022-07-14 08:16:52 +02:00
|
|
|
func (c *config) IgnorePrefer32OnDevice() bool {
|
|
|
|
return c.productVariables.IgnorePrefer32OnDevice
|
|
|
|
}
|
|
|
|
|
2020-07-01 15:31:13 +02:00
|
|
|
func (c *config) BootJars() []string {
|
|
|
|
return c.Once(earlyBootJarsKey, func() interface{} {
|
2020-10-23 22:14:20 +02:00
|
|
|
list := c.productVariables.BootJars.CopyOfJars()
|
2021-07-21 15:23:52 +02:00
|
|
|
return append(list, c.productVariables.ApexBootJars.CopyOfJars()...)
|
2020-07-01 15:31:13 +02:00
|
|
|
}).([]string)
|
|
|
|
}
|
2020-10-28 20:20:06 +01:00
|
|
|
|
2021-07-21 15:23:52 +02:00
|
|
|
func (c *config) NonApexBootJars() ConfiguredJarList {
|
2020-10-28 20:20:06 +01:00
|
|
|
return c.productVariables.BootJars
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:23:52 +02:00
|
|
|
func (c *config) ApexBootJars() ConfiguredJarList {
|
|
|
|
return c.productVariables.ApexBootJars
|
2020-10-28 20:20:06 +01:00
|
|
|
}
|
2021-03-12 20:28:25 +01:00
|
|
|
|
|
|
|
func (c *config) RBEWrapper() string {
|
|
|
|
return c.GetenvWithDefault("RBE_WRAPPER", remoteexec.DefaultWrapperPath)
|
|
|
|
}
|
2021-12-22 18:55:32 +01:00
|
|
|
|
|
|
|
// UseHostMusl returns true if the host target has been configured to build against musl libc.
|
|
|
|
func (c *config) UseHostMusl() bool {
|
|
|
|
return Bool(c.productVariables.HostMusl)
|
|
|
|
}
|
2022-04-21 20:33:17 +02:00
|
|
|
|
2022-05-10 19:50:12 +02:00
|
|
|
func (c *config) LogMixedBuild(ctx BaseModuleContext, useBazel bool) {
|
2022-04-21 20:33:17 +02:00
|
|
|
moduleName := ctx.Module().Name()
|
|
|
|
c.mixedBuildsLock.Lock()
|
|
|
|
defer c.mixedBuildsLock.Unlock()
|
|
|
|
if useBazel {
|
|
|
|
c.mixedBuildEnabledModules[moduleName] = struct{}{}
|
|
|
|
} else {
|
|
|
|
c.mixedBuildDisabledModules[moduleName] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|