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 (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2015-04-02 23:37:16 +02:00
|
|
|
"path/filepath"
|
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"
|
2024-02-07 02:02:04 +01:00
|
|
|
"unicode"
|
2015-12-18 01:39:19 +01:00
|
|
|
|
2024-03-05 01:36:31 +01:00
|
|
|
"android/soong/shared"
|
|
|
|
|
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-03-12 20:28:25 +01:00
|
|
|
"android/soong/remoteexec"
|
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
|
|
|
|
|
2023-03-03 00:36:39 +01:00
|
|
|
// PrivateApiLevel represents the api level of SdkSpecPrivate (sdk_version: "")
|
|
|
|
// This api_level exists to differentiate user-provided "" from "current" sdk_version
|
|
|
|
// The differentiation is necessary to enable different validation rules for these two possible values.
|
|
|
|
var PrivateApiLevel = ApiLevel{
|
|
|
|
value: "current", // The value is current since aidl expects `current` as the default (TestAidlFlagsWithMinSdkVersion)
|
|
|
|
number: FutureApiLevelInt + 1, // This is used to differentiate it from FutureApiLevel
|
|
|
|
isPreview: true,
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2022-12-13 06:23:34 +01:00
|
|
|
type CmdArgs struct {
|
|
|
|
bootstrap.Args
|
2023-04-19 06:13:45 +02:00
|
|
|
RunGoTests bool
|
|
|
|
OutDir string
|
|
|
|
SoongOutDir string
|
|
|
|
SoongVariables string
|
2022-12-13 06:23:34 +01:00
|
|
|
|
2023-12-08 01:54:51 +01:00
|
|
|
BazelQueryViewDir string
|
|
|
|
ModuleGraphFile string
|
|
|
|
ModuleActionsFile string
|
|
|
|
DocFile string
|
2022-12-13 06:23:34 +01:00
|
|
|
|
2023-06-08 21:02:07 +02:00
|
|
|
BuildFromSourceStub bool
|
2023-04-19 18:47:36 +02:00
|
|
|
|
|
|
|
EnsureAllowlistIntegrity bool
|
2022-12-13 06:23:34 +01:00
|
|
|
}
|
|
|
|
|
2022-08-20 20:48:32 +02:00
|
|
|
// Build modes that soong_build can run as.
|
|
|
|
const (
|
|
|
|
// Don't use bazel at all during module analysis.
|
|
|
|
AnalysisNoBazel SoongBuildMode = iota
|
|
|
|
|
|
|
|
// Generate BUILD files which faithfully represent the dependency graph of
|
|
|
|
// blueprint modules. Individual BUILD targets will not, however, faitfhully
|
|
|
|
// express build semantics.
|
|
|
|
GenerateQueryView
|
|
|
|
|
|
|
|
// Create a JSON representation of the module graph and exit.
|
|
|
|
GenerateModuleGraph
|
|
|
|
|
|
|
|
// Generate a documentation file for module type definitions and exit.
|
|
|
|
GenerateDocFile
|
|
|
|
)
|
|
|
|
|
2024-03-19 08:48:59 +01:00
|
|
|
const testKeyDir = "build/make/target/product/security"
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-11-03 00:57:08 +01:00
|
|
|
// tempDir returns the path to out/soong/.temp, which is cleared at the beginning of every build.
|
|
|
|
func (c Config) tempDir() string {
|
|
|
|
return shared.TempDirForOutDir(c.soongOutDir)
|
|
|
|
}
|
|
|
|
|
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{}
|
|
|
|
}
|
|
|
|
|
2022-10-06 12:01:59 +02:00
|
|
|
// RunningInsideUnitTest returns true if this code is being run as part of a Soong unit test.
|
|
|
|
func (c Config) RunningInsideUnitTest() bool {
|
|
|
|
return c.config.TestProductVariables != nil
|
|
|
|
}
|
|
|
|
|
2023-07-20 13:19:04 +02:00
|
|
|
// DisableHiddenApiChecks returns true if hiddenapi checks have been disabled.
|
2023-11-01 14:58:39 +01:00
|
|
|
// For 'eng' target variant hiddenapi checks are disabled by default for performance optimisation,
|
2023-07-20 13:19:04 +02:00
|
|
|
// but can be enabled by setting environment variable ENABLE_HIDDENAPI_FLAGS=true.
|
|
|
|
// For other target variants hiddenapi check are enabled by default but can be disabled by
|
|
|
|
// setting environment variable UNSAFE_DISABLE_HIDDENAPI_FLAGS=true.
|
|
|
|
// If both ENABLE_HIDDENAPI_FLAGS=true and UNSAFE_DISABLE_HIDDENAPI_FLAGS=true, then
|
|
|
|
// ENABLE_HIDDENAPI_FLAGS=true will be triggered and hiddenapi checks will be considered enabled.
|
|
|
|
func (c Config) DisableHiddenApiChecks() bool {
|
|
|
|
return !c.IsEnvTrue("ENABLE_HIDDENAPI_FLAGS") &&
|
|
|
|
(c.IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") ||
|
2023-11-01 14:58:39 +01:00
|
|
|
Bool(c.productVariables.Eng))
|
|
|
|
}
|
|
|
|
|
|
|
|
// DisableVerifyOverlaps returns true if verify_overlaps is skipped.
|
|
|
|
// Mismatch in version of apexes and module SDK is required for mainline prebuilts to work in
|
|
|
|
// trunk stable.
|
|
|
|
// Thus, verify_overlaps is disabled when RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE is set to false.
|
|
|
|
// TODO(b/308174018): Re-enable verify_overlaps for both builr from source/mainline prebuilts.
|
|
|
|
func (c Config) DisableVerifyOverlaps() bool {
|
2024-03-19 00:25:30 +01:00
|
|
|
if c.IsEnvFalse("DISABLE_VERIFY_OVERLAPS") && c.ReleaseDisableVerifyOverlaps() {
|
|
|
|
panic("The current release configuration does not support verify_overlaps. DISABLE_VERIFY_OVERLAPS cannot be set to false")
|
|
|
|
}
|
|
|
|
return c.IsEnvTrue("DISABLE_VERIFY_OVERLAPS") || c.ReleaseDisableVerifyOverlaps() || !c.ReleaseDefaultModuleBuildFromSource()
|
2023-07-20 13:19:04 +02:00
|
|
|
}
|
|
|
|
|
2023-04-07 19:35:35 +02:00
|
|
|
// MaxPageSizeSupported returns the max page size supported by the device. This
|
|
|
|
// value will define the ELF segment alignment for binaries (executables and
|
|
|
|
// shared libraries).
|
|
|
|
func (c Config) MaxPageSizeSupported() string {
|
|
|
|
return String(c.config.productVariables.DeviceMaxPageSizeSupported)
|
|
|
|
}
|
|
|
|
|
2023-12-04 23:51:20 +01:00
|
|
|
// NoBionicPageSizeMacro returns true when AOSP is page size agnostic.
|
|
|
|
// This means that the bionic's macro PAGE_SIZE won't be defined.
|
|
|
|
// Returns false when AOSP is NOT page size agnostic.
|
|
|
|
// This means that bionic's macro PAGE_SIZE is defined.
|
|
|
|
func (c Config) NoBionicPageSizeMacro() bool {
|
|
|
|
return Bool(c.config.productVariables.DeviceNoBionicPageSizeMacro)
|
2023-08-09 17:34:37 +02:00
|
|
|
}
|
|
|
|
|
2023-05-09 17:14:14 +02:00
|
|
|
// The release version passed to aconfig, derived from RELEASE_VERSION
|
|
|
|
func (c Config) ReleaseVersion() string {
|
|
|
|
return c.config.productVariables.ReleaseVersion
|
|
|
|
}
|
|
|
|
|
2023-09-06 02:19:45 +02:00
|
|
|
// The aconfig value set passed to aconfig, derived from RELEASE_VERSION
|
2023-10-13 05:31:27 +02:00
|
|
|
func (c Config) ReleaseAconfigValueSets() []string {
|
2023-12-08 01:38:45 +01:00
|
|
|
return c.config.productVariables.ReleaseAconfigValueSets
|
2023-05-09 17:14:14 +02:00
|
|
|
}
|
|
|
|
|
2023-08-10 23:47:40 +02:00
|
|
|
// The flag default permission value passed to aconfig
|
|
|
|
// derived from RELEASE_ACONFIG_FLAG_DEFAULT_PERMISSION
|
|
|
|
func (c Config) ReleaseAconfigFlagDefaultPermission() string {
|
|
|
|
return c.config.productVariables.ReleaseAconfigFlagDefaultPermission
|
|
|
|
}
|
|
|
|
|
2023-10-06 09:01:22 +02:00
|
|
|
// The flag indicating behavior for the tree wrt building modules or using prebuilts
|
|
|
|
// derived from RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE
|
|
|
|
func (c Config) ReleaseDefaultModuleBuildFromSource() bool {
|
|
|
|
return c.config.productVariables.ReleaseDefaultModuleBuildFromSource == nil ||
|
|
|
|
Bool(c.config.productVariables.ReleaseDefaultModuleBuildFromSource)
|
|
|
|
}
|
|
|
|
|
2024-03-19 00:25:30 +01:00
|
|
|
func (c Config) ReleaseDisableVerifyOverlaps() bool {
|
|
|
|
return c.config.productVariables.GetBuildFlagBool("RELEASE_DISABLE_VERIFY_OVERLAPS_CHECK")
|
|
|
|
}
|
|
|
|
|
Enable exportable stubs to include READ_WRITE aconfig flagged apis
Currently in SDK build, "exportable" stubs are used to generate the
android.jar and the corresponding build artifacts, as well as the
hiddenapi flags. "exportable" stubs only include the flagged apis that
are "enabled" and "read only", and exclude all other flagged apis. This
will be replaced with "runtime" stubs in the long run, which include
"read_write" flagged apis on top of the "enabled" and "read only" flags.
Prior to Trunk Stable, the SDK build did not distinguish the target
audience of the SDK. That is, the identical build target was used to
generate the SDK targeted toward the Google3 developers (i.e. Google3
SDK drop) and the SDK targeted toward the public (i.e. Developer
Preview). However, given that we now have "experimental" apis with Trunk
Stable, there are demands to differentiate the SDK based on the target
audience, so that the "experimental" APIs are included in the SDK
targeted toward Google3 while they are excluded in the public facing
SDK.
The long term solution to achieve this is to generate the hiddenapi
flags and (conditionally) the SDKs using the runtime stubs. However, as
this is high priority, this change resolves the problem by modifying the
filter condition of the "exportable" stubs to include the "read_write"
flagged apis on top of the "enabled" and "read only" flagged apis when
the value of the default-false build flag "RELEASE_EXPORT_RUNTIME_APIS"
is set to true.
Note that this is a temporary solution; However, we might need to keep
the "RELEASE_EXPORT_RUNTIME_APIS" build flag even in the long run to
determine what set of apis are included in the generated SDK, based on
the target audience of the SDK.
Test: m nothing --no-skip-soong-tests
Bug: 323188988
Change-Id: If0d5fa74b3ba6f4a57c86aade8d340f149a657a2
2024-02-06 23:43:18 +01:00
|
|
|
// Enables flagged apis annotated with READ_WRITE aconfig flags to be included in the stubs
|
|
|
|
// and hiddenapi flags so that they are accessible at runtime
|
|
|
|
func (c Config) ReleaseExportRuntimeApis() bool {
|
2024-02-22 20:52:46 +01:00
|
|
|
return Bool(c.config.productVariables.ExportRuntimeApis)
|
Enable exportable stubs to include READ_WRITE aconfig flagged apis
Currently in SDK build, "exportable" stubs are used to generate the
android.jar and the corresponding build artifacts, as well as the
hiddenapi flags. "exportable" stubs only include the flagged apis that
are "enabled" and "read only", and exclude all other flagged apis. This
will be replaced with "runtime" stubs in the long run, which include
"read_write" flagged apis on top of the "enabled" and "read only" flags.
Prior to Trunk Stable, the SDK build did not distinguish the target
audience of the SDK. That is, the identical build target was used to
generate the SDK targeted toward the Google3 developers (i.e. Google3
SDK drop) and the SDK targeted toward the public (i.e. Developer
Preview). However, given that we now have "experimental" apis with Trunk
Stable, there are demands to differentiate the SDK based on the target
audience, so that the "experimental" APIs are included in the SDK
targeted toward Google3 while they are excluded in the public facing
SDK.
The long term solution to achieve this is to generate the hiddenapi
flags and (conditionally) the SDKs using the runtime stubs. However, as
this is high priority, this change resolves the problem by modifying the
filter condition of the "exportable" stubs to include the "read_write"
flagged apis on top of the "enabled" and "read only" flagged apis when
the value of the default-false build flag "RELEASE_EXPORT_RUNTIME_APIS"
is set to true.
Note that this is a temporary solution; However, we might need to keep
the "RELEASE_EXPORT_RUNTIME_APIS" build flag even in the long run to
determine what set of apis are included in the generated SDK, based on
the target audience of the SDK.
Test: m nothing --no-skip-soong-tests
Bug: 323188988
Change-Id: If0d5fa74b3ba6f4a57c86aade8d340f149a657a2
2024-02-06 23:43:18 +01:00
|
|
|
}
|
|
|
|
|
2023-11-24 20:54:26 +01:00
|
|
|
// Enables ABI monitoring of NDK libraries
|
|
|
|
func (c Config) ReleaseNdkAbiMonitored() bool {
|
|
|
|
return c.config.productVariables.GetBuildFlagBool("RELEASE_NDK_ABI_MONITORED")
|
|
|
|
}
|
|
|
|
|
2024-04-29 21:30:23 +02:00
|
|
|
// Enable read flag from new storage, for C/C++
|
|
|
|
func (c Config) ReleaseReadFromNewStorageCc() bool {
|
|
|
|
return c.config.productVariables.GetBuildFlagBool("RELEASE_READ_FROM_NEW_STORAGE_CC")
|
|
|
|
}
|
|
|
|
|
2023-12-26 20:08:01 +01:00
|
|
|
func (c Config) ReleaseHiddenApiExportableStubs() bool {
|
2024-02-22 20:35:26 +01:00
|
|
|
return c.config.productVariables.GetBuildFlagBool("RELEASE_HIDDEN_API_EXPORTABLE_STUBS") ||
|
|
|
|
Bool(c.config.productVariables.HiddenapiExportableStubs)
|
2023-12-26 20:08:01 +01:00
|
|
|
}
|
|
|
|
|
2024-04-03 21:26:36 +02:00
|
|
|
// Enable read flag from new storage
|
|
|
|
func (c Config) ReleaseReadFromNewStorage() bool {
|
|
|
|
return c.config.productVariables.GetBuildFlagBool("RELEASE_READ_FROM_NEW_STORAGE")
|
|
|
|
}
|
|
|
|
|
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
|
2023-04-22 02:37:11 +02: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
|
2023-04-22 02:37:11 +02:00
|
|
|
TestProductVariables *ProductVariables
|
2018-03-13 02:06:05 +01:00
|
|
|
|
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
|
|
|
|
|
2023-12-08 01:54:51 +01:00
|
|
|
BuildMode SoongBuildMode
|
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
|
|
|
|
2023-06-08 21:02:07 +02:00
|
|
|
// If buildFromSourceStub is true then the Java API stubs are
|
|
|
|
// built from the source Java files, not the signature text files.
|
|
|
|
buildFromSourceStub bool
|
2023-04-19 18:47:36 +02:00
|
|
|
|
|
|
|
// If ensureAllowlistIntegrity is true, then the presence of any allowlisted
|
|
|
|
// modules that aren't mixed-built for at least one variant will cause a build
|
|
|
|
// failure
|
|
|
|
ensureAllowlistIntegrity bool
|
2023-03-23 18:44:51 +01:00
|
|
|
|
|
|
|
// List of Api libraries that contribute to Api surfaces.
|
|
|
|
apiLibraries 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
|
|
|
|
2024-02-07 02:02:04 +01:00
|
|
|
// Checks if the string is a valid go identifier. This is equivalent to blueprint's definition
|
|
|
|
// of an identifier, so it will match the same identifiers as those that can be used in bp files.
|
|
|
|
func isGoIdentifier(ident string) bool {
|
|
|
|
for i, r := range ident {
|
|
|
|
valid := r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r) && i > 0
|
|
|
|
if !valid {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return len(ident) > 0
|
|
|
|
}
|
|
|
|
|
2020-11-23 05:52:50 +01:00
|
|
|
// loadFromConfigFile loads and decodes configuration options from a JSON file
|
|
|
|
// in the current working directory.
|
2023-04-22 02:37:11 +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)
|
2024-06-04 20:10:11 +02:00
|
|
|
jsonDecoder.DisallowUnknownFields()
|
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))
|
|
|
|
|
2024-02-07 02:02:04 +01:00
|
|
|
// The go scanner's definition of identifiers is c-style identifiers, but allowing unicode's
|
|
|
|
// definition of letters and digits. This is the same scanner that blueprint uses, so it
|
|
|
|
// will allow the same identifiers as are valid in bp files.
|
|
|
|
for namespace := range configurable.VendorVars {
|
|
|
|
if !isGoIdentifier(namespace) {
|
|
|
|
return fmt.Errorf("soong config namespaces must be valid identifiers: %q", namespace)
|
|
|
|
}
|
|
|
|
for variable := range configurable.VendorVars[namespace] {
|
|
|
|
if !isGoIdentifier(variable) {
|
|
|
|
return fmt.Errorf("soong config variables must be valid identifiers: %q", variable)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
|
2024-06-14 23:13:54 +02:00
|
|
|
return nil
|
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)
|
2023-04-22 02:37:11 +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())
|
|
|
|
}
|
|
|
|
|
2022-12-13 06:23:34 +01:00
|
|
|
f, err := os.CreateTemp(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
|
|
|
|
}
|
|
|
|
|
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-12-13 06:23:34 +01:00
|
|
|
func NewConfig(cmdArgs CmdArgs, 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{
|
2023-04-19 06:13:45 +02:00
|
|
|
ProductVariablesFileName: cmdArgs.SoongVariables,
|
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
|
|
|
|
2022-12-13 06:23:34 +01:00
|
|
|
outDir: cmdArgs.OutDir,
|
|
|
|
soongOutDir: cmdArgs.SoongOutDir,
|
|
|
|
runGoTests: cmdArgs.RunGoTests,
|
2021-09-08 15:31:14 +02:00
|
|
|
multilibConflicts: make(map[ArchType]bool),
|
2019-12-14 05:41:13 +01:00
|
|
|
|
2023-12-08 01:54:51 +01:00
|
|
|
moduleListFile: cmdArgs.ModuleListFile,
|
|
|
|
fs: pathtools.NewOsFs(absSrcDir),
|
2023-02-23 23:28:06 +01:00
|
|
|
|
2023-06-08 21:02:07 +02:00
|
|
|
buildFromSourceStub: cmdArgs.BuildFromSourceStub,
|
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.
|
2022-12-13 06:23:34 +01:00
|
|
|
absBuildDir, err := filepath.Abs(cmdArgs.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
|
|
|
}
|
|
|
|
|
2022-12-13 06:23:34 +01:00
|
|
|
KatiEnabledMarkerFile := filepath.Join(cmdArgs.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-12-21 17:44:26 +01:00
|
|
|
setBuildMode := func(arg string, mode SoongBuildMode) {
|
|
|
|
if arg != "" {
|
|
|
|
if config.BuildMode != AnalysisNoBazel {
|
|
|
|
fmt.Fprintf(os.Stderr, "buildMode is already set, illegal argument: %s", arg)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
config.BuildMode = mode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setBuildMode(cmdArgs.BazelQueryViewDir, GenerateQueryView)
|
|
|
|
setBuildMode(cmdArgs.ModuleGraphFile, GenerateModuleGraph)
|
|
|
|
setBuildMode(cmdArgs.DocFile, GenerateDocFile)
|
2022-11-29 01:47:59 +01:00
|
|
|
|
2023-03-23 18:44:51 +01:00
|
|
|
// TODO(b/276958307): Replace the hardcoded list to a sdk_library local prop.
|
|
|
|
config.apiLibraries = map[string]struct{}{
|
|
|
|
"android.net.ipsec.ike": {},
|
|
|
|
"art.module.public.api": {},
|
|
|
|
"conscrypt.module.public.api": {},
|
|
|
|
"framework-adservices": {},
|
|
|
|
"framework-appsearch": {},
|
|
|
|
"framework-bluetooth": {},
|
2023-05-19 08:02:08 +02:00
|
|
|
"framework-configinfrastructure": {},
|
2023-03-23 18:44:51 +01:00
|
|
|
"framework-connectivity": {},
|
|
|
|
"framework-connectivity-t": {},
|
2023-05-19 08:02:08 +02:00
|
|
|
"framework-devicelock": {},
|
2023-03-23 18:44:51 +01:00
|
|
|
"framework-graphics": {},
|
2023-05-19 08:02:08 +02:00
|
|
|
"framework-healthfitness": {},
|
2023-08-06 02:20:47 +02:00
|
|
|
"framework-location": {},
|
2023-03-23 18:44:51 +01:00
|
|
|
"framework-media": {},
|
|
|
|
"framework-mediaprovider": {},
|
2023-11-14 02:16:35 +01:00
|
|
|
"framework-nfc": {},
|
2023-03-23 18:44:51 +01:00
|
|
|
"framework-ondevicepersonalization": {},
|
2023-11-08 17:03:53 +01:00
|
|
|
"framework-pdf": {},
|
2024-02-10 10:02:15 +01:00
|
|
|
"framework-pdf-v": {},
|
2023-03-23 18:44:51 +01:00
|
|
|
"framework-permission": {},
|
|
|
|
"framework-permission-s": {},
|
|
|
|
"framework-scheduling": {},
|
|
|
|
"framework-sdkextensions": {},
|
|
|
|
"framework-statsd": {},
|
|
|
|
"framework-sdksandbox": {},
|
|
|
|
"framework-tethering": {},
|
|
|
|
"framework-uwb": {},
|
|
|
|
"framework-virtualization": {},
|
|
|
|
"framework-wifi": {},
|
|
|
|
"i18n.module.public.api": {},
|
|
|
|
}
|
|
|
|
|
2023-11-16 20:07:04 +01:00
|
|
|
config.productVariables.Build_from_text_stub = boolPtr(config.BuildFromTextStub())
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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 {
|
2023-10-16 22:30:51 +02:00
|
|
|
path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin", tool)
|
2021-10-26 04:15:55 +02:00
|
|
|
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"
|
|
|
|
}
|
2023-10-16 22:30:51 +02:00
|
|
|
path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "lib64", lib+ext)
|
2021-10-26 04:15:55 +02:00
|
|
|
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 {
|
2023-10-16 22:30:51 +02:00
|
|
|
path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "framework", tool)
|
2021-11-04 18:22:51 +01:00
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
2023-05-16 22:03:20 +02:00
|
|
|
func (c *config) HostCcSharedLibPath(ctx PathContext, lib string) Path {
|
|
|
|
libDir := "lib"
|
|
|
|
if ctx.Config().BuildArch.Multilib == "lib64" {
|
|
|
|
libDir = "lib64"
|
|
|
|
}
|
2023-10-16 22:30:51 +02:00
|
|
|
return pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, libDir, lib+".so")
|
2023-05-16 22:03:20 +02:00
|
|
|
}
|
|
|
|
|
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 {
|
2024-05-01 22:51:25 +02:00
|
|
|
value := strings.ToLower(c.Getenv(key))
|
2016-11-24 01:52:04 +01:00
|
|
|
return value == "1" || value == "y" || value == "yes" || value == "on" || value == "true"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) IsEnvFalse(key string) bool {
|
2024-05-01 22:51:25 +02:00
|
|
|
value := strings.ToLower(c.Getenv(key))
|
2016-11-24 01:52:04 +01:00
|
|
|
return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
|
|
|
|
}
|
|
|
|
|
2024-05-23 11:28:24 +02:00
|
|
|
func (c *config) TargetsJava21() bool {
|
|
|
|
return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_21")
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-10-13 20:32:14 +02:00
|
|
|
func (c *config) ProductVariables() ProductVariables {
|
|
|
|
return c.productVariables
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-03-19 08:48:59 +01:00
|
|
|
func (c *config) DisplayBuildNumber() bool {
|
|
|
|
return Bool(c.productVariables.DisplayBuildNumber)
|
|
|
|
}
|
|
|
|
|
2024-06-18 04:09:12 +02:00
|
|
|
// BuildFingerprintFile returns the path to a text file containing metadata
|
|
|
|
// representing the current build's fingerprint.
|
|
|
|
//
|
|
|
|
// Rules that want to reference the build fingerprint 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 fingerprint. This ensures they
|
|
|
|
// don't rebuild on every incremental build when the build number changes.
|
|
|
|
func (c *config) BuildFingerprintFile(ctx PathContext) Path {
|
|
|
|
return PathForArbitraryOutput(ctx, "target", "product", c.DeviceName(), String(c.productVariables.BuildFingerprintFile))
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-03-19 08:48:59 +01:00
|
|
|
// BuildHostnameFile returns the path to a text file containing metadata
|
|
|
|
// representing the current build's host name.
|
|
|
|
func (c *config) BuildHostnameFile(ctx PathContext) Path {
|
|
|
|
return PathForOutput(ctx, String(c.productVariables.BuildHostnameFile))
|
|
|
|
}
|
|
|
|
|
|
|
|
// BuildThumbprintFile returns the path to a text file containing metadata
|
|
|
|
// representing the current build's thumbprint.
|
|
|
|
//
|
|
|
|
// Rules that want to reference the build thumbprint 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 thumbprint. This ensures they
|
|
|
|
// don't rebuild on every incremental build when the build thumbprint changes.
|
|
|
|
func (c *config) BuildThumbprintFile(ctx PathContext) Path {
|
|
|
|
return PathForArbitraryOutput(ctx, "target", "product", c.DeviceName(), String(c.productVariables.BuildThumbprintFile))
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-11-09 03:14:01 +01:00
|
|
|
// HasDeviceProduct returns if the build has a product. A build will not
|
|
|
|
// necessarily have a product when --skip-config is passed to soong, like it is
|
|
|
|
// in prebuilts/build-tools/build-prebuilts.sh
|
|
|
|
func (c *config) HasDeviceProduct() bool {
|
|
|
|
return c.productVariables.DeviceProduct != nil
|
|
|
|
}
|
|
|
|
|
2024-03-19 08:48:59 +01:00
|
|
|
func (c *config) DeviceAbi() []string {
|
|
|
|
return c.productVariables.DeviceAbi
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-03-19 08:48:59 +01:00
|
|
|
func (c *config) PlatformDisplayVersionName() string {
|
|
|
|
return String(c.productVariables.Platform_display_version_name)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-04-12 19:27:45 +02:00
|
|
|
func (c *config) RawPlatformSdkVersion() *int {
|
|
|
|
return c.productVariables.Platform_sdk_version
|
|
|
|
}
|
|
|
|
|
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 {
|
2024-04-12 13:06:22 +02:00
|
|
|
var val, ok = c.productVariables.BuildFlags["RELEASE_PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION"]
|
|
|
|
if !ok {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
return val
|
2019-04-03 07:56:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2023-10-05 22:40:46 +02:00
|
|
|
i := 0
|
|
|
|
for _, codename := range c.PlatformVersionActiveCodenames() {
|
|
|
|
if codename == "REL" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
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, ApiLevel{
|
|
|
|
value: codename,
|
|
|
|
number: i,
|
|
|
|
isPreview: true,
|
|
|
|
})
|
2023-10-05 22:40:46 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
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()
|
2023-03-27 10:39:48 +02:00
|
|
|
hostOnlyBuild := c.productVariables.DeviceArch == nil
|
2020-11-23 05:52:50 +01:00
|
|
|
if codename == "" {
|
2023-03-27 10:39:48 +02:00
|
|
|
// There are some host-only builds (those are invoked by build-prebuilts.sh) which
|
|
|
|
// don't set platform sdk codename. Platform sdk codename makes sense only when we
|
|
|
|
// are building the platform. So we don't enforce the below panic for the host-only
|
|
|
|
// builds.
|
|
|
|
if hostOnlyBuild {
|
|
|
|
return NoneApiLevel
|
|
|
|
}
|
|
|
|
panic("Platform_sdk_codename must be set")
|
2020-11-23 05:52:50 +01:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-03-27 22:34:01 +02:00
|
|
|
// All unreleased codenames.
|
|
|
|
func (c *config) PlatformVersionAllPreviewCodenames() []string {
|
|
|
|
return c.productVariables.Platform_version_all_preview_codenames
|
|
|
|
}
|
|
|
|
|
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))
|
|
|
|
}
|
2024-03-19 08:48:59 +01:00
|
|
|
return PathForSource(ctx, testKeyDir)
|
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
|
|
|
|
2024-03-19 08:48:59 +01:00
|
|
|
func (c *config) BuildKeys() string {
|
|
|
|
defaultCert := String(c.productVariables.DefaultAppCertificate)
|
|
|
|
if defaultCert == "" || defaultCert == filepath.Join(testKeyDir, "testkey") {
|
|
|
|
return "test-keys"
|
|
|
|
}
|
|
|
|
return "dev-keys"
|
|
|
|
}
|
|
|
|
|
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)
|
2024-03-19 08:48:59 +01:00
|
|
|
if defaultCert == "" || filepath.Dir(defaultCert) == testKeyDir {
|
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)
|
|
|
|
}
|
|
|
|
|
2024-03-19 08:48:59 +01:00
|
|
|
func (c *config) BuildType() string {
|
|
|
|
return String(c.productVariables.BuildType)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-02-21 17:50:29 +01:00
|
|
|
func (c *config) SourceRootDirs() []string {
|
|
|
|
return c.productVariables.SourceRootDirs
|
|
|
|
}
|
|
|
|
|
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())
|
2022-12-13 06:23:34 +01:00
|
|
|
return os.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
|
|
|
|
}
|
|
|
|
|
2022-11-04 04:38:01 +01:00
|
|
|
func (c *config) FrameworksBaseDirExists(ctx PathGlobContext) 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]
|
|
|
|
}
|
|
|
|
|
2022-12-13 06:23:34 +01:00
|
|
|
func (c *config) PrebuiltHiddenApiDir(_ PathContext) string {
|
2021-01-08 18:34:44 +01:00
|
|
|
return String(c.productVariables.PrebuiltHiddenApiDir)
|
|
|
|
}
|
|
|
|
|
2023-11-29 09:58:16 +01:00
|
|
|
func (c *config) VendorApiLevel() string {
|
|
|
|
return String(c.productVariables.VendorApiLevel)
|
|
|
|
}
|
|
|
|
|
2024-02-05 10:37:27 +01:00
|
|
|
func (c *config) PrevVendorApiLevel() string {
|
|
|
|
vendorApiLevel, err := strconv.Atoi(c.VendorApiLevel())
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Errorf("Cannot parse vendor API level %s to an integer: %s",
|
|
|
|
c.VendorApiLevel(), err))
|
|
|
|
}
|
|
|
|
// The version before trunk stable is 34.
|
|
|
|
if vendorApiLevel == 202404 {
|
|
|
|
return "34"
|
|
|
|
}
|
2024-03-05 08:56:44 +01:00
|
|
|
if vendorApiLevel >= 1 && vendorApiLevel <= 34 {
|
|
|
|
return strconv.Itoa(vendorApiLevel - 1)
|
|
|
|
}
|
|
|
|
if vendorApiLevel < 202404 || vendorApiLevel%100 != 4 {
|
|
|
|
panic("Unknown vendor API level " + c.VendorApiLevel())
|
|
|
|
}
|
2024-02-05 10:37:27 +01:00
|
|
|
return strconv.Itoa(vendorApiLevel - 100)
|
|
|
|
}
|
|
|
|
|
2024-03-29 12:12:35 +01:00
|
|
|
func IsTrunkStableVendorApiLevel(level string) bool {
|
|
|
|
levelInt, err := strconv.Atoi(level)
|
|
|
|
return err == nil && levelInt >= 202404
|
|
|
|
}
|
|
|
|
|
2024-01-19 08:02:29 +01:00
|
|
|
func (c *config) VendorApiLevelFrozen() bool {
|
|
|
|
return c.productVariables.GetBuildFlagBool("RELEASE_BOARD_API_LEVEL_FROZEN")
|
|
|
|
}
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
Install VNDK snapshot libraries for system build
When BOARD_VNDK_VERSION := <VNDK version>, or
PRODUCT_EXTRA_VNDK_VERSIONS includes the needed <VNDK version> list,
the prebuilt VNDK libs in prebuilts/vndk/ directory will be
installed.
Each prebuilt VNDK module uses "vndk_prebuilt_shared" for shared
VNDK/VNDK-SP libs.
Following is the sample configuration of a vndk snapshot module:
vndk_prebuilt_shared {
name: "libfoo",
version: "27",
vendor_available: true,
vndk: {
enabled: true,
},
arch: {
arm64: {
srcs: ["arm/lib64/libfoo.so"],
},
arm: {
srcs: ["arm/lib/libfoo.so"],
},
},
}
The Android.bp for the snapshot modules will be auto-generated by a
script.
Bug: 38304393
Bug: 65377115
Bug: 68123344
Test: set BOARD_VNDK_VERSION := 27
copy a snapshot for v27
build with make command
Change-Id: Ib93107530dbabb4a24583f4d6e4f0c513c9adfec
2017-11-17 04:10:28 +01:00
|
|
|
func (c *deviceConfig) ExtraVndkVersions() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return c.config.productVariables.ExtraVndkVersions
|
2016-11-18 23:54:24 +01:00
|
|
|
}
|
2016-12-09 00:45:07 +01:00
|
|
|
|
2018-01-15 07:05:10 +01:00
|
|
|
func (c *deviceConfig) SystemSdkVersions() []string {
|
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-09-10 15:21:40 +02:00
|
|
|
func (c *deviceConfig) TargetSpecificHeaderPath() string {
|
|
|
|
return String(c.config.productVariables.TargetSpecificHeaderPath)
|
|
|
|
}
|
|
|
|
|
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 {
|
2023-02-16 09:42:27 +01:00
|
|
|
// Workaround coverage boot failure.
|
|
|
|
// http://b/269981180
|
|
|
|
if strings.HasPrefix(path, "external/protobuf") {
|
|
|
|
coverage = false
|
|
|
|
}
|
2020-06-09 13:44:06 +02:00
|
|
|
if HasAnyPrefix(path, c.config.productVariables.NativeCoverageExcludePaths) {
|
2017-07-13 23:46:05 +02:00
|
|
|
coverage = false
|
2017-02-27 18:01:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return coverage
|
2017-02-10 01:16:31 +01:00
|
|
|
}
|
2017-07-13 23:46:05 +02:00
|
|
|
|
2018-01-30 08:11:42 +01:00
|
|
|
func (c *deviceConfig) PgoAdditionalProfileDirs() []string {
|
2018-03-10 06:22:06 +01:00
|
|
|
return c.config.productVariables.PgoAdditionalProfileDirs
|
2018-01-30 08:11:42 +01:00
|
|
|
}
|
|
|
|
|
2023-03-10 04:07:19 +01:00
|
|
|
// AfdoProfile returns fully qualified path associated to the given module name
|
2024-01-24 01:38:06 +01:00
|
|
|
func (c *deviceConfig) AfdoProfile(name string) (string, error) {
|
2023-03-10 04:07:19 +01:00
|
|
|
for _, afdoProfile := range c.config.productVariables.AfdoProfiles {
|
|
|
|
split := strings.Split(afdoProfile, ":")
|
|
|
|
if len(split) != 3 {
|
2024-01-24 01:38:06 +01:00
|
|
|
return "", fmt.Errorf("AFDO_PROFILES has invalid value: %s. "+
|
2023-03-10 04:07:19 +01:00
|
|
|
"The expected format is <module>:<fully-qualified-path-to-fdo_profile>", afdoProfile)
|
|
|
|
}
|
|
|
|
if split[0] == name {
|
2024-01-24 01:38:06 +01:00
|
|
|
return strings.Join([]string{split[1], split[2]}, ":"), nil
|
2023-03-10 04:07:19 +01:00
|
|
|
}
|
|
|
|
}
|
2024-01-24 01:38:06 +01:00
|
|
|
return "", nil
|
2023-03-10 04:07:19 +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
|
|
|
}
|
|
|
|
|
2023-08-22 19:51:44 +02:00
|
|
|
func (c *config) HWASanDisabledForPath(path string) bool {
|
|
|
|
if len(c.productVariables.HWASanExcludePaths) == 0 {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return HasAnyPrefix(path, c.productVariables.HWASanExcludePaths)
|
|
|
|
}
|
|
|
|
|
2023-03-17 06:17:22 +01:00
|
|
|
func (c *config) HWASanEnabledForPath(path string) bool {
|
|
|
|
if len(c.productVariables.HWASanIncludePaths) == 0 {
|
|
|
|
return false
|
|
|
|
}
|
2023-08-22 19:51:44 +02:00
|
|
|
return HasAnyPrefix(path, c.productVariables.HWASanIncludePaths) && !c.HWASanDisabledForPath(path)
|
2023-03-17 06:17:22 +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)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-01-11 15:15:43 +01:00
|
|
|
func (c *config) ApexTrimEnabled() bool {
|
|
|
|
return Bool(c.productVariables.TrimmedApex)
|
|
|
|
}
|
|
|
|
|
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-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
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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 {
|
2024-06-04 00:29:38 +02:00
|
|
|
if c.config.productVariables.Shipping_api_level == nil {
|
2020-12-21 14:53:05 +01:00
|
|
|
return NoneApiLevel
|
|
|
|
}
|
2024-06-04 00:29:38 +02:00
|
|
|
apiLevel, _ := strconv.Atoi(*c.config.productVariables.Shipping_api_level)
|
2020-12-21 14:53:05 +01:00
|
|
|
return uncheckedFinalApiLevel(apiLevel)
|
|
|
|
}
|
|
|
|
|
2023-05-18 20:20:28 +02:00
|
|
|
func (c *deviceConfig) BuildBrokenPluginValidation() []string {
|
|
|
|
return c.config.productVariables.BuildBrokenPluginValidation
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-09-10 04:39:25 +02:00
|
|
|
func (c *deviceConfig) BuildBrokenUsesSoongPython2Modules() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenUsesSoongPython2Modules
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2024-01-05 00:21:26 +01:00
|
|
|
func (c *deviceConfig) BuildBrokenDontCheckSystemSdk() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenDontCheckSystemSdk
|
|
|
|
}
|
|
|
|
|
2024-06-18 04:09:12 +02:00
|
|
|
func (c *deviceConfig) BuildBrokenDupSysprop() bool {
|
|
|
|
return c.config.productVariables.BuildBrokenDupSysprop
|
|
|
|
}
|
|
|
|
|
2023-06-03 00:42:21 +02:00
|
|
|
func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string {
|
|
|
|
return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist
|
|
|
|
}
|
|
|
|
|
2023-05-10 02:12:22 +02:00
|
|
|
func (c *deviceConfig) GenruleSandboxing() bool {
|
|
|
|
return Bool(c.config.productVariables.GenruleSandboxing)
|
2022-06-10 20:23:27 +02:00
|
|
|
}
|
|
|
|
|
2021-03-17 10:05:33 +01:00
|
|
|
func (c *deviceConfig) RequiresInsecureExecmemForSwiftshader() bool {
|
|
|
|
return c.config.productVariables.RequiresInsecureExecmemForSwiftshader
|
|
|
|
}
|
|
|
|
|
2023-07-07 00:03:58 +02:00
|
|
|
func (c *deviceConfig) Release_aidl_use_unfrozen() bool {
|
|
|
|
return Bool(c.config.productVariables.Release_aidl_use_unfrozen)
|
|
|
|
}
|
|
|
|
|
2021-03-17 10:05:33 +01:00
|
|
|
func (c *config) SelinuxIgnoreNeverallows() bool {
|
|
|
|
return c.productVariables.SelinuxIgnoreNeverallows
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-03-05 01:36:31 +01:00
|
|
|
func (c *deviceConfig) AconfigContainerValidation() string {
|
|
|
|
return c.config.productVariables.AconfigContainerValidation
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2023-03-08 06:47:29 +01:00
|
|
|
// ApiSurfaces directory returns the source path inside the api_surfaces repo
|
|
|
|
// (relative to workspace root).
|
|
|
|
func (c *config) ApiSurfacesDir(s ApiSurface, version string) string {
|
|
|
|
return filepath.Join(
|
|
|
|
"build",
|
|
|
|
"bazel",
|
|
|
|
"api_surfaces",
|
|
|
|
s.String(),
|
|
|
|
version)
|
|
|
|
}
|
2023-01-17 21:40:22 +01:00
|
|
|
|
2023-10-17 01:24:11 +02:00
|
|
|
func (c *config) JavaCoverageEnabled() bool {
|
|
|
|
return c.IsEnvTrue("EMMA_INSTRUMENT") || c.IsEnvTrue("EMMA_INSTRUMENT_STATIC") || c.IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK")
|
|
|
|
}
|
|
|
|
|
2023-11-16 20:07:04 +01:00
|
|
|
func (c *deviceConfig) BuildFromSourceStub() bool {
|
|
|
|
return Bool(c.config.productVariables.BuildFromSourceStub)
|
|
|
|
}
|
|
|
|
|
2023-01-17 21:40:22 +01:00
|
|
|
func (c *config) BuildFromTextStub() bool {
|
2023-10-17 01:24:11 +02:00
|
|
|
// TODO: b/302320354 - Remove the coverage build specific logic once the
|
|
|
|
// robust solution for handling native properties in from-text stub build
|
|
|
|
// is implemented.
|
2023-11-16 20:07:04 +01:00
|
|
|
return !c.buildFromSourceStub &&
|
|
|
|
!c.JavaCoverageEnabled() &&
|
|
|
|
!c.deviceConfig.BuildFromSourceStub()
|
2023-01-17 21:40:22 +01:00
|
|
|
}
|
2023-03-30 19:06:32 +02:00
|
|
|
|
|
|
|
func (c *config) SetBuildFromTextStub(b bool) {
|
2023-06-08 21:02:07 +02:00
|
|
|
c.buildFromSourceStub = !b
|
2023-06-02 00:31:52 +02:00
|
|
|
c.productVariables.Build_from_text_stub = boolPtr(b)
|
2023-03-30 19:06:32 +02:00
|
|
|
}
|
2023-03-23 18:44:51 +01:00
|
|
|
|
|
|
|
func (c *config) SetApiLibraries(libs []string) {
|
|
|
|
c.apiLibraries = make(map[string]struct{})
|
|
|
|
for _, lib := range libs {
|
|
|
|
c.apiLibraries[lib] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) GetApiLibraries() map[string]struct{} {
|
|
|
|
return c.apiLibraries
|
|
|
|
}
|
2023-08-25 14:29:46 +02:00
|
|
|
|
|
|
|
func (c *deviceConfig) CheckVendorSeappViolations() bool {
|
|
|
|
return Bool(c.config.productVariables.CheckVendorSeappViolations)
|
|
|
|
}
|
2023-09-20 03:02:18 +02:00
|
|
|
|
2023-10-25 16:53:58 +02:00
|
|
|
func (c *config) GetBuildFlag(name string) (string, bool) {
|
|
|
|
val, ok := c.productVariables.BuildFlags[name]
|
|
|
|
return val, ok
|
|
|
|
}
|
2023-10-26 22:48:02 +02:00
|
|
|
|
2024-01-25 22:39:06 +01:00
|
|
|
func (c *config) UseResourceProcessorByDefault() bool {
|
|
|
|
return c.productVariables.GetBuildFlagBool("RELEASE_USE_RESOURCE_PROCESSOR_BY_DEFAULT")
|
|
|
|
}
|
|
|
|
|
2023-10-26 22:48:02 +02:00
|
|
|
var (
|
2024-08-01 02:51:20 +02:00
|
|
|
mainlineApexContributionBuildFlagsToApexNames = map[string]string{
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_ADBD": "com.android.adbd",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "com.android.adservices",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_APPSEARCH": "com.android.appsearch",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_ART": "com.android.art",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_BLUETOOTH": "com.android.btservices",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_CAPTIVEPORTALLOGIN": "",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_CELLBROADCAST": "com.android.cellbroadcast",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_CONFIGINFRASTRUCTURE": "com.android.configinfrastructure",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_CONNECTIVITY": "com.android.tethering",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_CONSCRYPT": "com.android.conscrypt",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_CRASHRECOVERY": "",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_DEVICELOCK": "com.android.devicelock",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_DOCUMENTSUIGOOGLE": "",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_EXTSERVICES": "com.android.extservices",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_HEALTHFITNESS": "com.android.healthfitness",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_IPSEC": "com.android.ipsec",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_MEDIA": "com.android.media",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_MEDIAPROVIDER": "com.android.mediaprovider",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_MODULE_METADATA": "",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_NETWORKSTACKGOOGLE": "",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_NEURALNETWORKS": "com.android.neuralnetworks",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_ONDEVICEPERSONALIZATION": "com.android.ondevicepersonalization",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_PERMISSION": "com.android.permission",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_PRIMARY_LIBS": "",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_REMOTEKEYPROVISIONING": "com.android.rkpd",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_RESOLV": "com.android.resolv",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_SCHEDULING": "com.android.scheduling",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_SDKEXTENSIONS": "com.android.sdkext",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_SWCODEC": "com.android.media.swcodec",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_STATSD": "com.android.os.statsd",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_TELEMETRY_TVP": "",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_TZDATA": "com.android.tzdata",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_UWB": "com.android.uwb",
|
|
|
|
"RELEASE_APEX_CONTRIBUTIONS_WIFI": "com.android.wifi",
|
2023-10-26 22:48:02 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// Returns the list of _selected_ apex_contributions
|
|
|
|
// Each mainline module will have one entry in the list
|
|
|
|
func (c *config) AllApexContributions() []string {
|
|
|
|
ret := []string{}
|
2024-08-01 02:51:20 +02:00
|
|
|
for _, f := range SortedKeys(mainlineApexContributionBuildFlagsToApexNames) {
|
2023-10-26 22:48:02 +02:00
|
|
|
if val, exists := c.GetBuildFlag(f); exists && val != "" {
|
|
|
|
ret = append(ret, val)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
2024-02-17 04:31:45 +01:00
|
|
|
|
2024-08-01 02:51:20 +02:00
|
|
|
func (c *config) AllMainlineApexNames() []string {
|
|
|
|
return SortedStringValues(mainlineApexContributionBuildFlagsToApexNames)
|
|
|
|
}
|
|
|
|
|
2024-03-08 05:20:15 +01:00
|
|
|
func (c *config) BuildIgnoreApexContributionContents() *bool {
|
2024-02-17 04:31:45 +01:00
|
|
|
return c.productVariables.BuildIgnoreApexContributionContents
|
|
|
|
}
|
2024-03-19 08:48:59 +01:00
|
|
|
|
|
|
|
func (c *config) ProductLocales() []string {
|
|
|
|
return c.productVariables.ProductLocales
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) ProductDefaultWifiChannels() []string {
|
|
|
|
return c.productVariables.ProductDefaultWifiChannels
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) BoardUseVbmetaDigestInFingerprint() bool {
|
|
|
|
return Bool(c.productVariables.BoardUseVbmetaDigestInFingerprint)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *config) OemProperties() []string {
|
|
|
|
return c.productVariables.OemProperties
|
|
|
|
}
|
2024-07-08 04:02:23 +02:00
|
|
|
|
|
|
|
func (c *config) UseDebugArt() bool {
|
|
|
|
if c.productVariables.ArtTargetIncludeDebugBuild != nil {
|
|
|
|
return Bool(c.productVariables.ArtTargetIncludeDebugBuild)
|
|
|
|
}
|
|
|
|
|
|
|
|
return Bool(c.productVariables.Eng)
|
|
|
|
}
|
2024-07-31 04:00:41 +02:00
|
|
|
|
|
|
|
func (c *config) SystemPropFiles(ctx PathContext) Paths {
|
|
|
|
return PathsForSource(ctx, c.productVariables.SystemPropFiles)
|
|
|
|
}
|
2024-07-31 04:01:03 +02:00
|
|
|
|
2024-08-05 05:51:05 +02:00
|
|
|
func (c *config) SystemExtPropFiles(ctx PathContext) Paths {
|
|
|
|
return PathsForSource(ctx, c.productVariables.SystemExtPropFiles)
|
|
|
|
}
|
|
|
|
|
2024-08-08 10:47:14 +02:00
|
|
|
func (c *config) ProductPropFiles(ctx PathContext) Paths {
|
|
|
|
return PathsForSource(ctx, c.productVariables.ProductPropFiles)
|
|
|
|
}
|
|
|
|
|
2024-08-26 08:58:09 +02:00
|
|
|
func (c *config) OdmPropFiles(ctx PathContext) Paths {
|
|
|
|
return PathsForSource(ctx, c.productVariables.OdmPropFiles)
|
|
|
|
}
|
|
|
|
|
2024-07-31 04:01:03 +02:00
|
|
|
func (c *config) EnableUffdGc() string {
|
|
|
|
return String(c.productVariables.EnableUffdGc)
|
|
|
|
}
|