aboutsummaryrefslogtreecommitdiff
path: root/android/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/config.go')
-rw-r--r--android/config.go260
1 files changed, 169 insertions, 91 deletions
diff --git a/android/config.go b/android/config.go
index 3d95ab59a..fc4e2900b 100644
--- a/android/config.go
+++ b/android/config.go
@@ -29,8 +29,6 @@ import (
"sync"
"unicode"
- "android/soong/shared"
-
"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/pathtools"
@@ -38,6 +36,7 @@ import (
"android/soong/android/soongconfig"
"android/soong/remoteexec"
+ "android/soong/shared"
)
// Bool re-exports proptools.Bool for the android package.
@@ -86,9 +85,7 @@ type CmdArgs struct {
SoongVariables string
KatiSuffix string
- ModuleGraphFile string
- ModuleActionsFile string
- DocFile string
+ DocFile string
BuildFromSourceStub bool
@@ -100,9 +97,6 @@ const (
// Don't use bazel at all during module analysis.
AnalysisNoBazel SoongBuildMode = iota
- // Create a JSON representation of the module graph and exit.
- GenerateModuleGraph
-
// Generate a documentation file for module type definitions and exit.
GenerateDocFile
)
@@ -110,7 +104,7 @@ const (
const testKeyDir = "build/make/target/product/security"
func (c Config) genericConfig() Config {
- return Config{c.config.genericConfig}
+ return Config{c.config.genericConfigField}
}
// SoongOutDir returns the build output directory for the configuration.
@@ -143,6 +137,8 @@ func (c Config) PrimaryBuilderInvocations() []bootstrap.PrimaryBuilderInvocation
return []bootstrap.PrimaryBuilderInvocation{}
}
+func (c Config) IsBootstrap() bool { return false }
+
// 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
@@ -272,21 +268,12 @@ func (c Config) ReleaseNdkAbiMonitored() bool {
return c.config.productVariables.GetBuildFlagBool("RELEASE_NDK_ABI_MONITORED")
}
-// 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")
-}
-
func (c Config) ReleaseHiddenApiExportableStubs() bool {
return c.config.productVariables.GetBuildFlagBool("RELEASE_HIDDEN_API_EXPORTABLE_STUBS") ||
Bool(c.config.productVariables.HiddenapiExportableStubs)
}
// Enable read flag from new storage
-func (c Config) ReleaseReadFromNewStorage() bool {
- return c.config.productVariables.GetBuildFlagBool("RELEASE_READ_FROM_NEW_STORAGE")
-}
-
func (c Config) ReleaseCreateAconfigStorageFile() bool {
return c.config.productVariables.GetBuildFlagBool("RELEASE_CREATE_ACONFIG_STORAGE_FILE")
}
@@ -295,12 +282,42 @@ func (c Config) ReleaseUseSystemFeatureBuildFlags() bool {
return c.config.productVariables.GetBuildFlagBool("RELEASE_USE_SYSTEM_FEATURE_BUILD_FLAGS")
}
-func (c Config) ReleaseFingerprintAconfigPackages() bool {
- return c.config.productVariables.GetBuildFlagBool("RELEASE_FINGERPRINT_ACONFIG_PACKAGES")
+func (c Config) ReleaseUseSystemFeatureXmlForUnavailableFeatures() bool {
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_USE_SYSTEM_FEATURE_XML_FOR_UNAVAILABLE_FEATURES")
+}
+
+func (c Config) ReleaseRustUseArmTargetArchVariant() bool {
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_RUST_USE_ARM_TARGET_ARCH_VARIANT")
}
-func (c Config) ReleaseAconfigCheckApiLevel() bool {
- return c.config.productVariables.GetBuildFlagBool("RELEASE_ACONFIG_CHECK_API_LEVEL")
+func (c Config) ReleaseUseSparseEncoding() bool {
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_SOONG_SPARSE_ENCODING")
+}
+
+func (c Config) ReleaseUseUncompressedFonts() bool {
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_SOONG_UNCOMPRESSED_FONTS")
+}
+
+func (c Config) ReleaseAconfigStorageVersion() string {
+ if val, exists := c.GetBuildFlag("RELEASE_ACONFIG_STORAGE_VERSION"); exists {
+ return val
+ } else {
+ // Default value is 2.
+ return "2"
+ }
+}
+
+// TODO: b/414412266 Remove this flag after feature released.
+func (c Config) ReleaseJarjarFlagsInFramework() bool {
+ return c.config.productVariables.GetBuildFlagBool("RELEASE_JARJAR_FLAGS_IN_FRAMEWORK")
+}
+
+func (c Config) ReleaseMainlineBetaNamespaceConfig() string {
+ if val, exists := c.GetBuildFlag("RELEASE_MAINLINE_BETA_NAMESPACE_CONFIG"); exists {
+ return val
+ } else {
+ return ""
+ }
}
// A DeviceConfig object represents the configuration for a particular device
@@ -397,20 +414,31 @@ type config struct {
// Copy of this config struct but some product-specific variables are
// replaced with the generic configuration values.
- genericConfig *config
+ genericConfigField *config
+
+ // modulesForTests stores the list of modules that exist during Soong tests. It is nil
+ // when not running Soong tests.
+ modulesForTests *modulesForTests
}
type partialCompileFlags struct {
// Whether to use d8 instead of r8
Use_d8 bool
- // Whether to disable stub validation. This is slightly more surgical
- // than DISABLE_STUB_VALIDATION, in that it only applies to partial
- // compile builds.
+ // Whether to disable stub validation for partial compile builds.
+ // This is similar to setting `DISABLE_STUB_VALIDATION=true`: the
+ // validation checks are still created, but are not run by default.
+ // To run the validation checks, use `m {MODULE_NAME}-stub-validation`.
Disable_stub_validation bool
- // Whether to disable api lint.
- Disable_api_lint bool
+ // Whether to enable incremental java compilation.
+ Enable_inc_javac bool
+
+ // Whether to use the kotlin-incremental-client when compiling .kt files.
+ Enable_inc_kotlin bool
+
+ // Whether to enable incremental d8
+ Enable_inc_d8 bool
// Add others as needed.
}
@@ -421,8 +449,19 @@ var defaultPartialCompileFlags = partialCompileFlags{}
// These are the flags when `SOONG_PARTIAL_COMPILE=true`.
var enabledPartialCompileFlags = partialCompileFlags{
Use_d8: true,
- Disable_stub_validation: false,
- Disable_api_lint: false,
+ Disable_stub_validation: true,
+ Enable_inc_kotlin: false,
+ Enable_inc_javac: true,
+ Enable_inc_d8: true,
+}
+
+// These are the flags when `SOONG_PARTIAL_COMPILE=all`.
+var allPartialCompileFlags = partialCompileFlags{
+ Use_d8: true,
+ Disable_stub_validation: true,
+ Enable_inc_javac: true,
+ Enable_inc_kotlin: false,
+ Enable_inc_d8: true,
}
type deviceConfig struct {
@@ -497,23 +536,29 @@ func (c *config) parsePartialCompileFlags(isEngBuild bool) (partialCompileFlags,
state = "+"
}
switch tok {
- case "all":
- // Turn on **all** of the flags.
- ret = partialCompileFlags{
- Use_d8: true,
- Disable_stub_validation: true,
- Disable_api_lint: true,
- }
- case "true":
- ret = enabledPartialCompileFlags
+ // Big toggle switches.
case "false":
- // Set everything to false.
ret = partialCompileFlags{}
+ case "true":
+ ret = enabledPartialCompileFlags
+ case "all":
+ ret = allPartialCompileFlags
+
+ // Individual flags.
+ case "inc_d8", "enable_inc_d8":
+ ret.Enable_inc_d8 = makeVal(state, !defaultPartialCompileFlags.Enable_inc_d8)
+ case "disable_inc_d8":
+ ret.Enable_inc_d8 = !makeVal(state, defaultPartialCompileFlags.Enable_inc_d8)
+
+ case "inc_javac", "enable_inc_javac":
+ ret.Enable_inc_javac = makeVal(state, !defaultPartialCompileFlags.Enable_inc_javac)
+ case "disable_inc_javac":
+ ret.Enable_inc_javac = !makeVal(state, defaultPartialCompileFlags.Enable_inc_javac)
- case "api_lint", "enable_api_lint":
- ret.Disable_api_lint = !makeVal(state, !defaultPartialCompileFlags.Disable_api_lint)
- case "disable_api_lint":
- ret.Disable_api_lint = makeVal(state, defaultPartialCompileFlags.Disable_api_lint)
+ case "inc_kotlin", "enable_inc_kotlin":
+ ret.Enable_inc_kotlin = makeVal(state, defaultPartialCompileFlags.Enable_inc_kotlin)
+ case "disable_inc_kotlin":
+ ret.Enable_inc_kotlin = !makeVal(state, defaultPartialCompileFlags.Enable_inc_kotlin)
case "stub_validation", "enable_stub_validation":
ret.Disable_stub_validation = !makeVal(state, !defaultPartialCompileFlags.Disable_stub_validation)
@@ -522,6 +567,7 @@ func (c *config) parsePartialCompileFlags(isEngBuild bool) (partialCompileFlags,
case "use_d8":
ret.Use_d8 = makeVal(state, defaultPartialCompileFlags.Use_d8)
+
default:
return partialCompileFlags{}, fmt.Errorf("Unknown SOONG_PARTIAL_COMPILE value: %v", tok)
}
@@ -771,7 +817,6 @@ func initConfig(cmdArgs CmdArgs, availableEnv map[string]string) (*config, error
newConfig.BuildMode = mode
}
}
- setBuildMode(cmdArgs.ModuleGraphFile, GenerateModuleGraph)
setBuildMode(cmdArgs.DocFile, GenerateDocFile)
newConfig.productVariables.Build_from_text_stub = boolPtr(newConfig.BuildFromTextStub())
@@ -785,9 +830,9 @@ func initConfig(cmdArgs CmdArgs, availableEnv map[string]string) (*config, error
// A generic tag may have a string or an int value for the generic configuration.
// If the value is "unset", generic configuration will unset the variable.
func overrideGenericConfig(config *config) {
- config.genericConfig.isGeneric = true
- type_pv := reflect.TypeOf(config.genericConfig.productVariables)
- value_pv := reflect.ValueOf(&config.genericConfig.productVariables)
+ config.genericConfigField.isGeneric = true
+ type_pv := reflect.TypeOf(config.genericConfigField.productVariables)
+ value_pv := reflect.ValueOf(&config.genericConfigField.productVariables)
for i := range type_pv.NumField() {
type_pv_field := type_pv.Field(i)
generic_value := type_pv_field.Tag.Get("generic")
@@ -833,9 +878,9 @@ func overrideGenericConfig(config *config) {
}
// OncePer must be a singleton.
- config.genericConfig.OncePer = config.OncePer
+ config.genericConfigField.OncePer = config.OncePer
// keep the device name to get the install path.
- config.genericConfig.deviceNameToInstall = config.deviceNameToInstall
+ config.genericConfigField.deviceNameToInstall = config.deviceNameToInstall
}
// NewConfig creates a new Config object. It also loads the config file, if
@@ -848,7 +893,7 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error)
}
// Initialize generic configuration.
- config.genericConfig, err = initConfig(cmdArgs, availableEnv)
+ config.genericConfigField, err = initConfig(cmdArgs, availableEnv)
// Update product specific variables with the generic configuration.
overrideGenericConfig(config)
@@ -1069,9 +1114,23 @@ func (c *config) BuildThumbprintFile(ctx PathContext) Path {
return PathForArbitraryOutput(ctx, "target", "product", *c.deviceNameToInstall, String(c.productVariables.BuildThumbprintFile))
}
+func (c *config) BuildDateFile(ctx PathContext) Path {
+ buildDateFile := c.Getenv("BUILD_DATETIME_FILE")
+ relPath, err := filepath.Rel(ctx.Config().OutDir(), buildDateFile)
+ if err != nil {
+ panic("build_date.txt is outside of OUT_DIR")
+ }
+ return PathForArbitraryOutput(ctx, relPath)
+}
+
// DeviceName returns the name of the current device target.
// TODO: take an AndroidModuleContext to select the device name for multi-device builds
func (c *config) DeviceName() string {
+ if c.isGeneric {
+ // The config is called from a context of a module which returns true
+ // from UseGenericConfig(). This is not allowed.
+ panic("The DeviceName() function cannot be called when using the generic configuration. To call DeviceName(), ensure the module's UseGenericConfig() function returns \"false\".")
+ }
return *c.productVariables.DeviceName
}
@@ -1080,6 +1139,11 @@ func (c *config) DeviceName() string {
//
// NOTE: Do not base conditional logic on this value. It may break product inheritance.
func (c *config) DeviceProduct() string {
+ if c.isGeneric {
+ // The config is called from a context of a module which returns true
+ // from UseGenericConfig(). This is not allowed.
+ panic("The DeviceProduct() function cannot be called when using the generic configuration. To call DeviceProduct(), ensure the module's UseGenericConfig() function returns \"false\".")
+ }
return *c.productVariables.DeviceProduct
}
@@ -1111,7 +1175,7 @@ func (c *config) PlatformVersionName() string {
}
func (c *config) PlatformSdkVersion() ApiLevel {
- return uncheckedFinalApiLevel(*c.productVariables.Platform_sdk_version)
+ return UncheckedFinalApiLevel(*c.productVariables.Platform_sdk_version)
}
func (c *config) PlatformSdkVersionFull() string {
@@ -1167,13 +1231,13 @@ func (c *config) PlatformVersionKnownCodenames() string {
}
func (c *config) MinSupportedSdkVersion() ApiLevel {
- return uncheckedFinalApiLevel(21)
+ return UncheckedFinalApiLevel(21)
}
func (c *config) FinalApiLevels() []ApiLevel {
var levels []ApiLevel
for i := 1; i <= c.PlatformSdkVersion().FinalOrFutureInt(); i++ {
- levels = append(levels, uncheckedFinalApiLevel(i))
+ levels = append(levels, UncheckedFinalApiLevel(i))
}
return levels
}
@@ -1353,7 +1417,13 @@ func (c *config) UnbundledBuild() bool {
// 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 {
+func (c *config) UnbundledBuildApps() []string {
+ return c.productVariables.Unbundled_build_apps
+}
+
+// Returns true if building apps that aren't bundled with the platform.
+// UnbundledBuild() is always true when this is true.
+func (c *config) HasUnbundledBuildApps() bool {
return len(c.productVariables.Unbundled_build_apps) > 0
}
@@ -1430,10 +1500,6 @@ func (c *config) Android64() bool {
return false
}
-func (c *config) UseGoma() bool {
- return Bool(c.productVariables.UseGoma)
-}
-
func (c *config) UseABFS() bool {
return Bool(c.productVariables.UseABFS)
}
@@ -1455,7 +1521,7 @@ func (c *config) UseRBED8() bool {
}
func (c *config) UseRemoteBuild() bool {
- return c.UseGoma() || c.UseRBE()
+ return c.UseRBE()
}
func (c *config) RunErrorProne() bool {
@@ -1658,6 +1724,10 @@ func (c *config) katiPackageMkDir() string {
return filepath.Join(c.soongOutDir, "kati_packaging"+c.katiSuffix)
}
+func (c *config) DisableNoticeXmlGeneration() bool {
+ return c.IsEnvTrue("DISABLE_NOTICE_XML_GENERATION")
+}
+
func (c *deviceConfig) Arches() []Arch {
var arches []Arch
for _, target := range c.config.Targets[Android] {
@@ -2001,7 +2071,7 @@ func (c *config) ForceApexSymlinkOptimization() bool {
}
func (c *config) ApexCompressionEnabled() bool {
- return Bool(c.productVariables.CompressedApex) && !c.UnbundledBuildApps()
+ return Bool(c.productVariables.CompressedApex) && !c.HasUnbundledBuildApps()
}
func (c *config) DefaultApexPayloadType() string {
@@ -2106,16 +2176,16 @@ func (c *deviceConfig) BoardSepolicyVers() string {
return c.PlatformSepolicyVersion()
}
-func (c *deviceConfig) SystemExtSepolicyPrebuiltApiDir() string {
- return String(c.config.productVariables.SystemExtSepolicyPrebuiltApiDir)
+func (c *deviceConfig) SystemExtSepolicyPrebuiltApiDirs() []string {
+ return c.config.productVariables.SystemExtSepolicyPrebuiltApiDirs
}
-func (c *deviceConfig) ProductSepolicyPrebuiltApiDir() string {
- return String(c.config.productVariables.ProductSepolicyPrebuiltApiDir)
+func (c *deviceConfig) ProductSepolicyPrebuiltApiDirs() []string {
+ return c.config.productVariables.ProductSepolicyPrebuiltApiDirs
}
func (c *deviceConfig) IsPartnerTrebleSepolicyTestEnabled() bool {
- return c.SystemExtSepolicyPrebuiltApiDir() != "" || c.ProductSepolicyPrebuiltApiDir() != ""
+ return len(c.SystemExtSepolicyPrebuiltApiDirs()) > 0 || len(c.ProductSepolicyPrebuiltApiDirs()) > 0
}
func createDirsMap(previous map[string]bool, dirs []string) (map[string]bool, error) {
@@ -2149,7 +2219,7 @@ func (c *deviceConfig) ShippingApiLevel() ApiLevel {
return NoneApiLevel
}
apiLevel, _ := strconv.Atoi(*c.config.productVariables.Shipping_api_level)
- return uncheckedFinalApiLevel(apiLevel)
+ return UncheckedFinalApiLevel(apiLevel)
}
func (c *deviceConfig) BuildBrokenPluginValidation() []string {
@@ -2196,14 +2266,6 @@ func (c *deviceConfig) BuildBrokenDupSysprop() bool {
return c.config.productVariables.BuildBrokenDupSysprop
}
-func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string {
- return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist
-}
-
-func (c *deviceConfig) GenruleSandboxing() bool {
- return Bool(c.config.productVariables.GenruleSandboxing)
-}
-
func (c *deviceConfig) RequiresInsecureExecmemForSwiftshader() bool {
return c.config.productVariables.RequiresInsecureExecmemForSwiftshader
}
@@ -2260,17 +2322,6 @@ func (c *config) UseHostMusl() bool {
return Bool(c.productVariables.HostMusl)
}
-// 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)
-}
-
func (c *config) JavaCoverageEnabled() bool {
return c.IsEnvTrue("EMMA_INSTRUMENT") || c.IsEnvTrue("EMMA_INSTRUMENT_STATIC") || c.IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK")
}
@@ -2302,6 +2353,10 @@ func (c *config) GetBuildFlag(name string) (string, bool) {
return val, ok
}
+func (c *config) GetBuildFlagBool(name string) bool {
+ return c.productVariables.GetBuildFlagBool(name)
+}
+
func (c *config) UseOptimizedResourceShrinkingByDefault() bool {
return c.productVariables.GetBuildFlagBool("RELEASE_USE_OPTIMIZED_RESOURCE_SHRINKING_BY_DEFAULT")
}
@@ -2404,17 +2459,19 @@ func (c *config) OemProperties() []string {
}
func (c *config) UseDebugArt() bool {
- // If the ArtTargetIncludeDebugBuild product variable is set then return its value.
- if c.productVariables.ArtTargetIncludeDebugBuild != nil {
- return Bool(c.productVariables.ArtTargetIncludeDebugBuild)
- }
-
// If the RELEASE_APEX_CONTRIBUTIONS_ART build flag is set to use a prebuilt ART apex
// then don't use the debug apex.
if val, ok := c.GetBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART"); ok && val != "" {
return false
}
+ // If the ArtTargetIncludeDebugBuild product variable is set then return its value.
+ // The prebuilt APEX check overrides this to be tolerant wrt build logic
+ // that sets PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD regardless of module source.
+ if c.productVariables.ArtTargetIncludeDebugBuild != nil {
+ return Bool(c.productVariables.ArtTargetIncludeDebugBuild)
+ }
+
// Default to the debug apex for eng builds.
return Bool(c.productVariables.Eng)
}
@@ -2486,6 +2543,27 @@ func (c *config) DeviceManifestFiles() []string {
return c.productVariables.DeviceManifestFiles
}
+func (c *config) DeviceManifestSkus() []string {
+ return c.productVariables.DeviceManifestSkus
+}
+
func (c *config) OdmManifestFiles() []string {
return c.productVariables.OdmManifestFiles
}
+
+func (c *config) OdmManifestSkus() []string {
+ return c.productVariables.OdmManifestSkus
+}
+
+func (c *config) EnforceSELinuxTrebleLabeling() bool {
+ return Bool(c.productVariables.EnforceSELinuxTrebleLabeling)
+}
+
+func (c *config) SELinuxTrebleLabelingTrackingListFile(ctx PathContext) Path {
+ path := String(c.productVariables.SELinuxTrebleLabelingTrackingListFile)
+ if path == "" {
+ return nil
+ }
+
+ return PathForSource(ctx, path)
+}