Merge "Vendor apexes can be "updatable: true""
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 938c41e..2917931 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -710,6 +710,10 @@
// for building com.android.neuralnetworks
"libimapper_stablec",
"libimapper_providerutils",
+
+ // min_sdk_version in android_app
+ "CtsShimUpgrade",
+ "fake-framework",
}
Bp2buildModuleTypeAlwaysConvertList = []string{
@@ -869,6 +873,9 @@
"android.hardware.health-translate-java",
// cc_test related.
+ // b/274164834 "Could not open Configuration file test.cfg"
+ "svcenc", "svcdec",
+
// Failing host cc_tests
"memunreachable_unit_test",
"libprocinfo_test",
@@ -1435,8 +1442,10 @@
// Bazel prod-mode allowlist. Modules in this list are built by Bazel
// in either prod mode or staging mode.
ProdMixedBuildsEnabledList = []string{
+ // M5: tzdata launch
"com.android.tzdata",
"test1_com.android.tzdata",
+ // M7: adbd launch
"com.android.adbd",
"test_com.android.adbd",
"adbd_test",
@@ -1444,6 +1453,8 @@
"adb_pairing_auth_test",
"adb_pairing_connection_test",
"adb_tls_connection_test",
+ // M9: mixed builds for mainline trains launch
+ "api_fingerprint",
}
// Staging-mode allowlist. Modules in this list are only built
@@ -1451,21 +1462,19 @@
// which will soon be added to the prod allowlist.
// It is implicit that all modules in ProdMixedBuildsEnabledList will
// also be built - do not add them to this list.
- StagingMixedBuildsEnabledList = []string{
- "api_fingerprint",
- }
+ StagingMixedBuildsEnabledList = []string{}
// These should be the libs that are included by the apexes in the ProdMixedBuildsEnabledList
- ProdDclaMixedBuildsEnabledList = []string{}
-
- // These should be the libs that are included by the apexes in the StagingMixedBuildsEnabledList
- StagingDclaMixedBuildsEnabledList = []string{
+ ProdDclaMixedBuildsEnabledList = []string{
"libbase",
"libc++",
"libcrypto",
"libcutils",
}
+ // These should be the libs that are included by the apexes in the StagingMixedBuildsEnabledList
+ StagingDclaMixedBuildsEnabledList = []string{}
+
// TODO(b/269342245): Enable the rest of the DCLA libs
// "libssl",
// "libstagefright_flacdec",
diff --git a/android/androidmk.go b/android/androidmk.go
index a7b69f6..aa411d1 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -560,8 +560,6 @@
a.SetPaths("LOCAL_SOONG_INSTALL_SYMLINKS", base.katiSymlinks.InstallPaths().Paths())
}
- a.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", base.commonProperties.SkipInstall)
-
if am, ok := mod.(ApexModule); ok {
a.SetBoolIfTrue("LOCAL_NOT_AVAILABLE_FOR_PLATFORM", am.NotAvailableForPlatform())
}
diff --git a/android/apex.go b/android/apex.go
index a0ac5b8..87bff74 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -603,7 +603,7 @@
// Do not install the module for platform, but still allow it to output
// uninstallable AndroidMk entries in certain cases when they have side
// effects. TODO(jiyong): move this routine to somewhere else
- mod.SkipInstall()
+ mod.MakeUninstallable()
}
if !platformVariation {
mctx.SetVariationProvider(mod, ApexInfoProvider, apexInfos[i-1])
@@ -845,7 +845,7 @@
// ModuleWithMinSdkVersionCheck represents a module that implements min_sdk_version checks
type ModuleWithMinSdkVersionCheck interface {
Module
- MinSdkVersion(ctx EarlyModuleContext) SdkSpec
+ MinSdkVersion(ctx EarlyModuleContext) ApiLevel
CheckMinSdkVersion(ctx ModuleContext)
}
diff --git a/android/api_levels.go b/android/api_levels.go
index 9440ee9..0c0b2b4 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -55,6 +55,9 @@
}
func (this ApiLevel) FinalInt() int {
+ if this.IsInvalid() {
+ panic(fmt.Errorf("%v is not a recognized api_level\n", this))
+ }
if this.IsPreview() {
panic("Requested a final int from a non-final ApiLevel")
} else {
@@ -63,6 +66,9 @@
}
func (this ApiLevel) FinalOrFutureInt() int {
+ if this.IsInvalid() {
+ panic(fmt.Errorf("%v is not a recognized api_level\n", this))
+ }
if this.IsPreview() {
return FutureApiLevelInt
} else {
@@ -76,6 +82,9 @@
// - preview codenames -> preview base (9000) + index
// - otherwise -> cast to int
func (this ApiLevel) FinalOrPreviewInt() int {
+ if this.IsInvalid() {
+ panic(fmt.Errorf("%v is not a recognized api_level\n", this))
+ }
if this.IsCurrent() {
return this.number
}
@@ -97,6 +106,11 @@
return this.isPreview
}
+// Returns true if the raw api level string is invalid
+func (this ApiLevel) IsInvalid() bool {
+ return this.EqualTo(InvalidApiLevel)
+}
+
// Returns true if this is the unfinalized "current" API level. This means
// different things across Java and native. Java APIs do not use explicit
// codenames, so all non-final codenames are grouped into "current". For native
@@ -113,6 +127,72 @@
return this.number == -1
}
+// Returns true if an app is compiling against private apis.
+// e.g. if sdk_version = "" in Android.bp, then the ApiLevel of that "sdk" is at PrivateApiLevel.
+func (this ApiLevel) IsPrivate() bool {
+ return this.number == PrivateApiLevel.number
+}
+
+// EffectiveVersion converts an ApiLevel into the concrete ApiLevel that the module should use. For
+// modules targeting an unreleased SDK (meaning it does not yet have a number) it returns
+// FutureApiLevel(10000).
+func (l ApiLevel) EffectiveVersion(ctx EarlyModuleContext) (ApiLevel, error) {
+ if l.EqualTo(InvalidApiLevel) {
+ return l, fmt.Errorf("invalid version in sdk_version %q", l.value)
+ }
+ if !l.IsPreview() {
+ return l, nil
+ }
+ ret := ctx.Config().DefaultAppTargetSdk(ctx)
+ if ret.IsPreview() {
+ return FutureApiLevel, nil
+ }
+ return ret, nil
+}
+
+// EffectiveVersionString converts an SdkSpec into the concrete version string that the module
+// should use. For modules targeting an unreleased SDK (meaning it does not yet have a number)
+// it returns the codename (P, Q, R, etc.)
+func (l ApiLevel) EffectiveVersionString(ctx EarlyModuleContext) (string, error) {
+ if l.EqualTo(InvalidApiLevel) {
+ return l.value, fmt.Errorf("invalid version in sdk_version %q", l.value)
+ }
+ if !l.IsPreview() {
+ return l.String(), nil
+ }
+ // Determine the default sdk
+ ret := ctx.Config().DefaultAppTargetSdk(ctx)
+ if !ret.IsPreview() {
+ // If the default sdk has been finalized, return that
+ return ret.String(), nil
+ }
+ // There can be more than one active in-development sdks
+ // If an app is targeting an active sdk, but not the default one, return the requested active sdk.
+ // e.g.
+ // SETUP
+ // In-development: UpsideDownCake, VanillaIceCream
+ // Default: VanillaIceCream
+ // Android.bp
+ // min_sdk_version: `UpsideDownCake`
+ // RETURN
+ // UpsideDownCake and not VanillaIceCream
+ for _, preview := range ctx.Config().PreviewApiLevels() {
+ if l.String() == preview.String() {
+ return preview.String(), nil
+ }
+ }
+ // Otherwise return the default one
+ return ret.String(), nil
+}
+
+// Specified returns true if the module is targeting a recognzized api_level.
+// It returns false if either
+// 1. min_sdk_version is not an int or a recognized codename
+// 2. both min_sdk_version and sdk_version are empty. In this case, MinSdkVersion() defaults to SdkSpecPrivate.ApiLevel
+func (this ApiLevel) Specified() bool {
+ return !this.IsInvalid() && !this.IsPrivate()
+}
+
// Returns -1 if the current API level is less than the argument, 0 if they
// are equal, and 1 if it is greater than the argument.
func (this ApiLevel) CompareTo(other ApiLevel) int {
@@ -166,6 +246,19 @@
isPreview: true,
}
+// Sentinel ApiLevel to validate that an apiLevel is either an int or a recognized codename.
+var InvalidApiLevel = NewInvalidApiLevel("invalid")
+
+// Returns an apiLevel object at the same level as InvalidApiLevel.
+// The object contains the raw string provied in bp file, and can be used for error handling.
+func NewInvalidApiLevel(raw string) ApiLevel {
+ return ApiLevel{
+ value: raw,
+ number: -2, // One less than NoneApiLevel
+ isPreview: true,
+ }
+}
+
// The first version that introduced 64-bit ABIs.
var FirstLp64Version = uncheckedFinalApiLevel(21)
@@ -204,6 +297,16 @@
return strconv.Itoa(num)
}
+// ApiLevelFrom converts the given string `raw` to an ApiLevel.
+// If `raw` is invalid (empty string, unrecognized codename etc.) it returns an invalid ApiLevel
+func ApiLevelFrom(ctx PathContext, raw string) ApiLevel {
+ ret, err := ApiLevelFromUser(ctx, raw)
+ if err != nil {
+ return NewInvalidApiLevel(raw)
+ }
+ return ret
+}
+
// ApiLevelFromUser converts the given string `raw` to an ApiLevel, possibly returning an error.
//
// `raw` must be non-empty. Passing an empty string results in a panic.
diff --git a/android/arch.go b/android/arch.go
index 6acf9cf..4b4691b 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -1694,6 +1694,7 @@
return []archConfig{
{"arm64", "armv8-a-branchprot", "", []string{"arm64-v8a"}},
{"arm", "armv7-a-neon", "", []string{"armeabi-v7a"}},
+ {"riscv64", "", "", []string{"riscv64"}},
{"x86_64", "", "", []string{"x86_64"}},
{"x86", "", "", []string{"x86"}},
}
diff --git a/android/config.go b/android/config.go
index 292fcf2..593812c 100644
--- a/android/config.go
+++ b/android/config.go
@@ -52,6 +52,15 @@
// FutureApiLevelInt is a placeholder constant for unreleased API levels.
const FutureApiLevelInt = 10000
+// 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,
+}
+
// FutureApiLevel represents unreleased API levels.
var FutureApiLevel = ApiLevel{
value: "current",
diff --git a/android/module.go b/android/module.go
index b45ed95..76fe8dc 100644
--- a/android/module.go
+++ b/android/module.go
@@ -37,26 +37,64 @@
DeviceStaticLibrary = "static_library"
)
+// BuildParameters describes the set of potential parameters to build a Ninja rule.
+// In general, these correspond to a Ninja concept.
type BuildParams struct {
- Rule blueprint.Rule
- Deps blueprint.Deps
- Depfile WritablePath
- Description string
- Output WritablePath
- Outputs WritablePaths
- SymlinkOutput WritablePath
- SymlinkOutputs WritablePaths
- ImplicitOutput WritablePath
+ // A Ninja Rule that will be written to the Ninja file. This allows factoring out common code
+ // among multiple modules to reduce repetition in the Ninja file of action requirements. A rule
+ // can contain variables that should be provided in Args.
+ Rule blueprint.Rule
+ // Deps represents the depfile format. When using RuleBuilder, this defaults to GCC when depfiles
+ // are used.
+ Deps blueprint.Deps
+ // Depfile is a writeable path that allows correct incremental builds when the inputs have not
+ // been fully specified by the Ninja rule. Ninja supports a subset of the Makefile depfile syntax.
+ Depfile WritablePath
+ // A description of the build action.
+ Description string
+ // Output is an output file of the action. When using this field, references to $out in the Ninja
+ // command will refer to this file.
+ Output WritablePath
+ // Outputs is a slice of output file of the action. When using this field, references to $out in
+ // the Ninja command will refer to these files.
+ Outputs WritablePaths
+ // SymlinkOutput is an output file specifically that is a symlink.
+ SymlinkOutput WritablePath
+ // SymlinkOutputs is a slice of output files specifically that is a symlink.
+ SymlinkOutputs WritablePaths
+ // ImplicitOutput is an output file generated by the action. Note: references to `$out` in the
+ // Ninja command will NOT include references to this file.
+ ImplicitOutput WritablePath
+ // ImplicitOutputs is a slice of output files generated by the action. Note: references to `$out`
+ // in the Ninja command will NOT include references to these files.
ImplicitOutputs WritablePaths
- Input Path
- Inputs Paths
- Implicit Path
- Implicits Paths
- OrderOnly Paths
- Validation Path
- Validations Paths
- Default bool
- Args map[string]string
+ // Input is an input file to the Ninja action. When using this field, references to $in in the
+ // Ninja command will refer to this file.
+ Input Path
+ // Inputs is a slice of input files to the Ninja action. When using this field, references to $in
+ // in the Ninja command will refer to these files.
+ Inputs Paths
+ // Implicit is an input file to the Ninja action. Note: references to `$in` in the Ninja command
+ // will NOT include references to this file.
+ Implicit Path
+ // Implicits is a slice of input files to the Ninja action. Note: references to `$in` in the Ninja
+ // command will NOT include references to these files.
+ Implicits Paths
+ // OrderOnly are Ninja order-only inputs to the action. When these are out of date, the output is
+ // not rebuilt until they are built, but changes in order-only dependencies alone do not cause the
+ // output to be rebuilt.
+ OrderOnly Paths
+ // Validation is an output path for a validation action. Validation outputs imply lower
+ // non-blocking priority to building non-validation outputs.
+ Validation Path
+ // Validations is a slice of output path for a validation action. Validation outputs imply lower
+ // non-blocking priority to building non-validation outputs.
+ Validations Paths
+ // Whether to skip outputting a default target statement which will be built by Ninja when no
+ // targets are specified on Ninja's command line.
+ Default bool
+ // Args is a key value mapping for replacements of variables within the Rule
+ Args map[string]string
}
type ModuleBuildParams BuildParams
@@ -505,8 +543,8 @@
PartitionTag(DeviceConfig) string
HideFromMake()
IsHideFromMake() bool
- SkipInstall()
IsSkipInstall() bool
+ MakeUninstallable()
ReplacedByPrebuilt()
IsReplacedByPrebuilt() bool
ExportedToMake() bool
@@ -1964,6 +2002,15 @@
return m.commonProperties.SkipInstall
}
+// Similar to HideFromMake, but if the AndroidMk entry would set
+// LOCAL_UNINSTALLABLE_MODULE then this variant may still output that entry
+// rather than leaving it out altogether. That happens in cases where it would
+// have other side effects, in particular when it adds a NOTICE file target,
+// which other install targets might depend on.
+func (m *ModuleBase) MakeUninstallable() {
+ m.HideFromMake()
+}
+
func (m *ModuleBase) ReplacedByPrebuilt() {
m.commonProperties.ReplacedByPrebuilt = true
m.HideFromMake()
diff --git a/android/packaging_test.go b/android/packaging_test.go
index f32d1c3..91ac1f3 100644
--- a/android/packaging_test.go
+++ b/android/packaging_test.go
@@ -15,7 +15,6 @@
package android
import (
- "strings"
"testing"
"github.com/google/blueprint"
@@ -29,8 +28,6 @@
Deps []string
Skip_install *bool
}
-
- builtFile Path
}
// dep tag used in this test. All dependencies are considered as installable.
@@ -51,21 +48,13 @@
}
func (m *componentTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
- m.builtFile = PathForModuleOut(ctx, m.Name())
+ builtFile := PathForModuleOut(ctx, m.Name())
dir := ctx.Target().Arch.ArchType.Multilib
installDir := PathForModuleInstall(ctx, dir)
if proptools.Bool(m.props.Skip_install) {
m.SkipInstall()
}
- ctx.InstallFile(installDir, m.Name(), m.builtFile)
-}
-
-func (m *componentTestModule) AndroidMkEntries() []AndroidMkEntries {
- return []AndroidMkEntries{
- {
- OutputFile: OptionalPathForPath(m.builtFile),
- },
- }
+ ctx.InstallFile(installDir, m.Name(), builtFile)
}
// Module that itself is a package
@@ -262,35 +251,6 @@
`, []string{"lib32/foo", "lib64/foo", "lib64/bar"})
}
-func TestSkipInstallProducesLocalUninstallableModule(t *testing.T) {
- result := GroupFixturePreparers(
- PrepareForTestWithArchMutator,
- FixtureRegisterWithContext(func(ctx RegistrationContext) {
- ctx.RegisterModuleType("component", componentTestModuleFactory)
- ctx.RegisterModuleType("package_module", packageTestModuleFactory)
- }),
- FixtureWithRootAndroidBp(`
-component {
- name: "foo",
- skip_install: true,
-}
-
-package_module {
- name: "package",
- deps: ["foo"],
-}
-`),
- ).RunTest(t)
- module := result.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*componentTestModule)
- entries := AndroidMkEntriesForTest(t, result.TestContext, module)
- builder := &strings.Builder{}
- entries[0].write(builder)
- androidMkString := builder.String()
- if !strings.Contains(androidMkString, "LOCAL_UNINSTALLABLE_MODULE := true") {
- t.Errorf("Expected android mk entries to contain \"LOCAL_UNINSTALLABLE_MODULE := true\", got: \n%s", androidMkString)
- }
-}
-
func TestPackagingBaseSingleTarget(t *testing.T) {
multiTarget := false
runPackagingTest(t, multiTarget,
diff --git a/android/sdk.go b/android/sdk.go
index 8b23d63..63e0bbe 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -25,7 +25,7 @@
// minApiLevelForSdkSnapshot provides access to the min_sdk_version for MinApiLevelForSdkSnapshot
type minApiLevelForSdkSnapshot interface {
- MinSdkVersion(ctx EarlyModuleContext) SdkSpec
+ MinSdkVersion(ctx EarlyModuleContext) ApiLevel
}
// MinApiLevelForSdkSnapshot returns the ApiLevel of the min_sdk_version of the supplied module.
@@ -34,7 +34,7 @@
func MinApiLevelForSdkSnapshot(ctx EarlyModuleContext, module Module) ApiLevel {
minApiLevel := NoneApiLevel
if m, ok := module.(minApiLevelForSdkSnapshot); ok {
- minApiLevel = m.MinSdkVersion(ctx).ApiLevel
+ minApiLevel = m.MinSdkVersion(ctx)
}
if minApiLevel == NoneApiLevel {
// The default min API level is 1.
diff --git a/android/sdk_version.go b/android/sdk_version.go
index a7e03dc..18b819a 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -25,9 +25,9 @@
SdkVersion(ctx EarlyModuleContext) SdkSpec
// SystemModules returns the system_modules property of the current module, or an empty string if it is not set.
SystemModules() string
- // MinSdkVersion returns SdkSpec that corresponds to the min_sdk_version property of the current module,
+ // MinSdkVersion returns ApiLevel that corresponds to the min_sdk_version property of the current module,
// or from sdk_version if it is not set.
- MinSdkVersion(ctx EarlyModuleContext) SdkSpec
+ MinSdkVersion(ctx EarlyModuleContext) ApiLevel
// ReplaceMaxSdkVersionPlaceholder returns SdkSpec to replace the maxSdkVersion property of permission and
// uses-permission tags if it is set.
ReplaceMaxSdkVersionPlaceholder(ctx EarlyModuleContext) SdkSpec
@@ -187,14 +187,7 @@
if ctx.DeviceSpecific() || ctx.SocSpecific() {
s = s.ForVendorPartition(ctx)
}
- if !s.ApiLevel.IsPreview() {
- return s.ApiLevel, nil
- }
- ret := ctx.Config().DefaultAppTargetSdk(ctx)
- if ret.IsPreview() {
- return FutureApiLevel, nil
- }
- return ret, nil
+ return s.ApiLevel.EffectiveVersion(ctx)
}
// EffectiveVersionString converts an SdkSpec into the concrete version string that the module
@@ -208,37 +201,12 @@
if ctx.DeviceSpecific() || ctx.SocSpecific() {
s = s.ForVendorPartition(ctx)
}
- if !s.ApiLevel.IsPreview() {
- return s.ApiLevel.String(), nil
- }
- // Determine the default sdk
- ret := ctx.Config().DefaultAppTargetSdk(ctx)
- if !ret.IsPreview() {
- // If the default sdk has been finalized, return that
- return ret.String(), nil
- }
- // There can be more than one active in-development sdks
- // If an app is targeting an active sdk, but not the default one, return the requested active sdk.
- // e.g.
- // SETUP
- // In-development: UpsideDownCake, VanillaIceCream
- // Default: VanillaIceCream
- // Android.bp
- // min_sdk_version: `UpsideDownCake`
- // RETURN
- // UpsideDownCake and not VanillaIceCream
- for _, preview := range ctx.Config().PreviewApiLevels() {
- if s.ApiLevel.String() == preview.String() {
- return preview.String(), nil
- }
- }
- // Otherwise return the default one
- return ret.String(), nil
+ return s.ApiLevel.EffectiveVersionString(ctx)
}
var (
SdkSpecNone = SdkSpec{SdkNone, NoneApiLevel, "(no version)"}
- SdkSpecPrivate = SdkSpec{SdkPrivate, FutureApiLevel, ""}
+ SdkSpecPrivate = SdkSpec{SdkPrivate, PrivateApiLevel, ""}
SdkSpecCorePlatform = SdkSpec{SdkCorePlatform, FutureApiLevel, "core_platform"}
)
@@ -261,7 +229,7 @@
var kindString string
if sep == 0 {
- return SdkSpec{SdkInvalid, NoneApiLevel, str}
+ return SdkSpec{SdkInvalid, NewInvalidApiLevel(str), str}
} else if sep == -1 {
kindString = ""
} else {
@@ -289,7 +257,7 @@
apiLevel, err := ApiLevelFromUserWithConfig(config, versionString)
if err != nil {
- return SdkSpec{SdkInvalid, apiLevel, str}
+ return SdkSpec{SdkInvalid, NewInvalidApiLevel(versionString), str}
}
return SdkSpec{kind, apiLevel, str}
}
diff --git a/android/sdk_version_test.go b/android/sdk_version_test.go
index ec81782..ea99c4d 100644
--- a/android/sdk_version_test.go
+++ b/android/sdk_version_test.go
@@ -37,11 +37,11 @@
},
{
input: "_",
- expected: "invalid_(no version)",
+ expected: "invalid__",
},
{
input: "_31",
- expected: "invalid_(no version)",
+ expected: "invalid__31",
},
{
input: "system_R",
diff --git a/apex/apex.go b/apex/apex.go
index 4424b22..68ad95e 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2946,12 +2946,8 @@
}
// Returns apex's min_sdk_version SdkSpec, honoring overrides
-func (a *apexBundle) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
- return android.SdkSpec{
- Kind: android.SdkNone,
- ApiLevel: a.minSdkVersion(ctx),
- Raw: a.minSdkVersionValue(ctx),
- }
+func (a *apexBundle) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
+ return a.minSdkVersion(ctx)
}
// Returns apex's min_sdk_version ApiLevel, honoring overrides
diff --git a/apex/builder.go b/apex/builder.go
index ee6c473..45c5267 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -1063,10 +1063,10 @@
} else {
toMinSdkVersion := "(no version)"
if m, ok := to.(interface {
- MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
+ MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
}); ok {
- if v := m.MinSdkVersion(ctx); !v.ApiLevel.IsNone() {
- toMinSdkVersion = v.ApiLevel.String()
+ if v := m.MinSdkVersion(ctx); !v.IsNone() {
+ toMinSdkVersion = v.String()
}
} else if m, ok := to.(interface{ MinSdkVersion() string }); ok {
// TODO(b/175678607) eliminate the use of MinSdkVersion returning
@@ -1087,7 +1087,7 @@
return !externalDep
})
- a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, a.MinSdkVersion(ctx).Raw, depInfos)
+ a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, a.MinSdkVersion(ctx).String(), depInfos)
ctx.Build(pctx, android.BuildParams{
Rule: android.Phony,
diff --git a/bp2build/android_app_conversion_test.go b/bp2build/android_app_conversion_test.go
index 03b3d2b..ef3f124 100644
--- a/bp2build/android_app_conversion_test.go
+++ b/bp2build/android_app_conversion_test.go
@@ -344,3 +344,50 @@
}),
}})
}
+
+func TestAndroidAppMinSdkProvided(t *testing.T) {
+ runAndroidAppTestCase(t, Bp2buildTestCase{
+ Description: "Android app with value for min_sdk_version",
+ ModuleTypeUnderTest: "android_app",
+ ModuleTypeUnderTestFactory: java.AndroidAppFactory,
+ Filesystem: map[string]string{},
+ Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
+android_app {
+ name: "foo",
+ sdk_version: "current",
+ min_sdk_version: "24",
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("android_binary", "foo", AttrNameToString{
+ "manifest": `"AndroidManifest.xml"`,
+ "resource_files": `[]`,
+ "manifest_values": `{
+ "minSdkVersion": "24",
+ }`,
+ }),
+ }})
+}
+
+func TestAndroidAppMinSdkDefaultToSdkVersion(t *testing.T) {
+ runAndroidAppTestCase(t, Bp2buildTestCase{
+ Description: "Android app with value for sdk_version",
+ ModuleTypeUnderTest: "android_app",
+ ModuleTypeUnderTestFactory: java.AndroidAppFactory,
+ Filesystem: map[string]string{},
+ Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
+android_app {
+ name: "foo",
+ sdk_version: "30",
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("android_binary", "foo", AttrNameToString{
+ "manifest": `"AndroidManifest.xml"`,
+ "resource_files": `[]`,
+ "manifest_values": `{
+ "minSdkVersion": "30",
+ }`,
+ }),
+ }})
+}
diff --git a/cc/cc.go b/cc/cc.go
index ea6b110..a7884e7 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -609,6 +609,7 @@
inSanitizerDir() bool
hostToolPath() android.OptionalPath
relativeInstallPath() string
+ makeUninstallable(mod *Module)
installInRoot() bool
}
@@ -3524,6 +3525,14 @@
return c.InRecovery()
}
+func (c *Module) MakeUninstallable() {
+ if c.installer == nil {
+ c.ModuleBase.MakeUninstallable()
+ return
+ }
+ c.installer.makeUninstallable(c)
+}
+
func (c *Module) HostToolPath() android.OptionalPath {
if c.installer == nil {
return android.OptionalPath{}
diff --git a/cc/installer.go b/cc/installer.go
index c3618b7..e2c0e7b 100644
--- a/cc/installer.go
+++ b/cc/installer.go
@@ -121,6 +121,10 @@
return String(installer.Properties.Relative_install_path)
}
+func (installer *baseInstaller) makeUninstallable(mod *Module) {
+ mod.ModuleBase.MakeUninstallable()
+}
+
func (installer *baseInstaller) installInRoot() bool {
return Bool(installer.Properties.Install_in_root)
}
diff --git a/cc/library.go b/cc/library.go
index 842a05f..68de233 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2439,6 +2439,17 @@
return nil
}
+func (library *libraryDecorator) makeUninstallable(mod *Module) {
+ if library.static() && library.buildStatic() && !library.buildStubs() {
+ // If we're asked to make a static library uninstallable we don't do
+ // anything since AndroidMkEntries always sets LOCAL_UNINSTALLABLE_MODULE
+ // for these entries. This is done to still get the make targets for NOTICE
+ // files from notice_files.mk, which other libraries might depend on.
+ return
+ }
+ mod.ModuleBase.MakeUninstallable()
+}
+
func (library *libraryDecorator) getPartition() string {
return library.path.Partition()
}
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index c237d75..5b7ba43 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -214,7 +214,7 @@
// without the prefix hack below.
if p.hasStubsVariants() && !p.buildStubs() && !ctx.Host() &&
!strings.HasPrefix(ctx.baseModuleName(), "libclang_rt.") {
- ctx.Module().SkipInstall()
+ ctx.Module().MakeUninstallable()
}
return outputFile
diff --git a/java/aar.go b/java/aar.go
index 4bc5465..4e5ac1f 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -220,12 +220,12 @@
linkDeps = append(linkDeps, assetDeps...)
// Returns the effective version for {min|target}_sdk_version
- effectiveVersionString := func(sdkVersion android.SdkSpec, minSdkVersion android.SdkSpec) string {
+ effectiveVersionString := func(sdkVersion android.SdkSpec, minSdkVersion android.ApiLevel) string {
// If {min|target}_sdk_version is current, use sdk_version to determine the effective level
// This is necessary for vendor modules.
// The effective version does not _only_ depend on {min|target}_sdk_version(level),
// but also on the sdk_version (kind+level)
- if minSdkVersion.ApiLevel.IsCurrent() {
+ if minSdkVersion.IsCurrent() {
ret, err := sdkVersion.EffectiveVersionString(ctx)
if err != nil {
ctx.ModuleErrorf("invalid sdk_version: %s", err)
@@ -689,7 +689,7 @@
jniPackages android.Paths
sdkVersion android.SdkSpec
- minSdkVersion android.SdkSpec
+ minSdkVersion android.ApiLevel
}
var _ android.OutputFileProducer = (*AARImport)(nil)
@@ -714,11 +714,11 @@
return ""
}
-func (a *AARImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+func (a *AARImport) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
if a.properties.Min_sdk_version != nil {
- return android.SdkSpecFrom(ctx, *a.properties.Min_sdk_version)
+ return android.ApiLevelFrom(ctx, *a.properties.Min_sdk_version)
}
- return a.SdkVersion(ctx)
+ return a.SdkVersion(ctx).ApiLevel
}
func (a *AARImport) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
diff --git a/java/androidmk.go b/java/androidmk.go
index d73ff46..a4dac80 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -76,6 +76,9 @@
entriesList = append(entriesList, dexpreoptEntries...)
}
entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
+ } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
+ // Platform variant. If not available for the platform, we don't need Make module.
+ entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
} else {
entriesList = append(entriesList, android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
@@ -91,8 +94,7 @@
entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...)
}
- if library.installFile == nil || !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
- // If the ApexModule is not available for the platform, it shouldn't be installed.
+ if library.installFile == nil {
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
}
if library.dexJarFile.IsSet() {
diff --git a/java/app.go b/java/app.go
index 4cc9e19..52caf6d 100755
--- a/java/app.go
+++ b/java/app.go
@@ -752,7 +752,7 @@
type appDepsInterface interface {
SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
- MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
+ MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
RequiresStableAPIs(ctx android.BaseModuleContext) bool
}
@@ -865,10 +865,10 @@
} else {
toMinSdkVersion := "(no version)"
if m, ok := to.(interface {
- MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
+ MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
}); ok {
- if v := m.MinSdkVersion(ctx); !v.ApiLevel.IsNone() {
- toMinSdkVersion = v.ApiLevel.String()
+ if v := m.MinSdkVersion(ctx); !v.IsNone() {
+ toMinSdkVersion = v.String()
}
} else if m, ok := to.(interface{ MinSdkVersion() string }); ok {
// TODO(b/175678607) eliminate the use of MinSdkVersion returning
@@ -1495,6 +1495,10 @@
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
}
+type manifestValueAttribute struct {
+ MinSdkVersion *string
+}
+
type bazelAndroidAppAttributes struct {
*javaCommonAttributes
*bazelAapt
@@ -1502,6 +1506,7 @@
Custom_package *string
Certificate bazel.LabelAttribute
Certificate_name bazel.StringAttribute
+ Manifest_values *manifestValueAttribute
}
// ConvertWithBp2build is used to convert android_app to Bazel.
@@ -1516,11 +1521,23 @@
certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableAppProperties.Certificate)
+ manifestValues := &manifestValueAttribute{}
+ // TODO(b/274474008 ): Directly convert deviceProperties.Min_sdk_version in bp2build
+ // MinSdkVersion(ctx) calls SdkVersion(ctx) if no value for min_sdk_version is set
+ minSdkVersion := a.MinSdkVersion(ctx)
+ if !minSdkVersion.IsPreview() && !minSdkVersion.IsInvalid() {
+ minSdkStr, err := minSdkVersion.EffectiveVersionString(ctx)
+ if err == nil {
+ manifestValues.MinSdkVersion = &minSdkStr
+ }
+ }
+
appAttrs := &bazelAndroidAppAttributes{
// TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES
Custom_package: a.overridableAppProperties.Package_name,
Certificate: certificate,
Certificate_name: certificateName,
+ Manifest_values: manifestValues,
}
props := bazel.BazelTargetModuleProperties{
diff --git a/java/app_import.go b/java/app_import.go
index e24e780..c1de667 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -426,8 +426,8 @@
return android.SdkSpecPrivate
}
-func (a *AndroidAppImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
- return android.SdkSpecPrivate
+func (a *AndroidAppImport) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
+ return android.SdkSpecPrivate.ApiLevel
}
func (a *AndroidAppImport) LintDepSets() LintDepSets {
diff --git a/java/base.go b/java/base.go
index 85f4a5e..75ec16d 100644
--- a/java/base.go
+++ b/java/base.go
@@ -489,7 +489,7 @@
hideApexVariantFromMake bool
sdkVersion android.SdkSpec
- minSdkVersion android.SdkSpec
+ minSdkVersion android.ApiLevel
maxSdkVersion android.SdkSpec
sourceExtensions []string
@@ -665,11 +665,11 @@
return proptools.String(j.deviceProperties.System_modules)
}
-func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
if j.deviceProperties.Min_sdk_version != nil {
- return android.SdkSpecFrom(ctx, *j.deviceProperties.Min_sdk_version)
+ return android.ApiLevelFrom(ctx, *j.deviceProperties.Min_sdk_version)
}
- return j.SdkVersion(ctx)
+ return j.SdkVersion(ctx).ApiLevel
}
func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
@@ -685,7 +685,7 @@
}
func (j *Module) MinSdkVersionString() string {
- return j.minSdkVersion.Raw
+ return j.minSdkVersion.String()
}
func (j *Module) TargetSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
@@ -881,7 +881,7 @@
j.ignoredAidlPermissionList = android.PathsForModuleSrcExcludes(ctx, exceptions, nil)
}
- aidlMinSdkVersion := j.MinSdkVersion(ctx).ApiLevel.String()
+ aidlMinSdkVersion := j.MinSdkVersion(ctx).String()
flags = append(flags, "--min_sdk_version="+aidlMinSdkVersion)
return strings.Join(flags, " "), deps
@@ -1542,9 +1542,9 @@
}
if ctx.Device() {
- lintSDKVersion := func(sdkSpec android.SdkSpec) int {
- if v := sdkSpec.ApiLevel; !v.IsPreview() {
- return v.FinalInt()
+ lintSDKVersion := func(apiLevel android.ApiLevel) int {
+ if !apiLevel.IsPreview() {
+ return apiLevel.FinalInt()
} else {
// When running metalava, we pass --version-codename. When that value
// is not REL, metalava will add 1 to the --current-version argument.
@@ -1575,8 +1575,8 @@
j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...)
j.linter.classes = j.implementationJarFile
j.linter.minSdkVersion = lintSDKVersion(j.MinSdkVersion(ctx))
- j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx))
- j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx))
+ j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx).ApiLevel)
+ j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx).ApiLevel)
j.linter.compileSdkKind = j.SdkVersion(ctx).Kind
j.linter.javaLanguageLevel = flags.javaVersion.String()
j.linter.kotlinLanguageLevel = "1.3"
@@ -1846,15 +1846,14 @@
// Implements android.ApexModule
func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
sdkVersionSpec := j.SdkVersion(ctx)
- minSdkVersionSpec := j.MinSdkVersion(ctx)
- if !minSdkVersionSpec.Specified() {
+ minSdkVersion := j.MinSdkVersion(ctx)
+ if !minSdkVersion.Specified() {
return fmt.Errorf("min_sdk_version is not specified")
}
// If the module is compiling against core (via sdk_version), skip comparison check.
if sdkVersionSpec.Kind == android.SdkCore {
return nil
}
- minSdkVersion := minSdkVersionSpec.ApiLevel
if minSdkVersion.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", minSdkVersion)
}
diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go
index cf81ddb..45e6175 100644
--- a/java/classpath_fragment.go
+++ b/java/classpath_fragment.go
@@ -130,13 +130,13 @@
if s, ok := m.(*SdkLibrary); ok {
// TODO(208456999): instead of mapping "current" to latest, min_sdk_version should never be set to "current"
if s.minSdkVersion.Specified() {
- if s.minSdkVersion.ApiLevel.IsCurrent() {
+ if s.minSdkVersion.IsCurrent() {
jar.minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
} else {
- jar.minSdkVersion = s.minSdkVersion.ApiLevel.String()
+ jar.minSdkVersion = s.minSdkVersion.String()
}
}
- if s.maxSdkVersion.Specified() {
+ if s.maxSdkVersion.ApiLevel.Specified() {
if s.maxSdkVersion.ApiLevel.IsCurrent() {
jar.maxSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String()
} else {
diff --git a/java/config/config.go b/java/config/config.go
index 838d007..13670ee 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -94,10 +94,12 @@
"-JXX:+TieredCompilation",
"-JXX:TieredStopAtLevel=1",
"-JDcom.android.tools.r8.emitRecordAnnotationsInDex",
+ "-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex",
}, dexerJavaVmFlagsList...))
exportedVars.ExportStringListStaticVariable("R8Flags", append([]string{
"-JXmx2048M",
"-JDcom.android.tools.r8.emitRecordAnnotationsInDex",
+ "-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex",
}, dexerJavaVmFlagsList...))
exportedVars.ExportStringListStaticVariable("CommonJdkFlags", []string{
diff --git a/java/dex.go b/java/dex.go
index 7b6a99a..4d6aa34 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -343,7 +343,7 @@
type compileDexParams struct {
flags javaBuilderFlags
sdkVersion android.SdkSpec
- minSdkVersion android.SdkSpec
+ minSdkVersion android.ApiLevel
classesJar android.Path
jarName string
}
diff --git a/java/droiddoc.go b/java/droiddoc.go
index e98b9ea..3e21008 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -248,8 +248,8 @@
return proptools.String(j.properties.System_modules)
}
-func (j *Javadoc) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
- return j.SdkVersion(ctx)
+func (j *Javadoc) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
+ return j.SdkVersion(ctx).ApiLevel
}
func (j *Javadoc) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
@@ -304,7 +304,7 @@
flags = append(flags, "-I"+src.String())
}
- minSdkVersion := j.MinSdkVersion(ctx).ApiLevel.FinalOrFutureInt()
+ minSdkVersion := j.MinSdkVersion(ctx).FinalOrFutureInt()
flags = append(flags, fmt.Sprintf("--min_sdk_version=%v", minSdkVersion))
return strings.Join(flags, " "), deps
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index c4fc65f..d25096b 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -73,7 +73,7 @@
android.Module
hiddenAPIIntf
- MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec
+ MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel
}
type hiddenAPIIntf interface {
@@ -157,7 +157,7 @@
// Create a copy of the dex jar which has been encoded with hiddenapi flags.
flagsCSV := hiddenAPISingletonPaths(ctx).flags
outputDir := android.PathForModuleOut(ctx, "hiddenapi").OutputPath
- encodedDex := hiddenAPIEncodeDex(ctx, dexJar, flagsCSV, uncompressDex, android.SdkSpecNone, outputDir)
+ encodedDex := hiddenAPIEncodeDex(ctx, dexJar, flagsCSV, uncompressDex, android.NoneApiLevel, outputDir)
// Use the encoded dex jar from here onwards.
return encodedDex
@@ -253,7 +253,7 @@
// The encode dex rule requires unzipping, encoding and rezipping the classes.dex files along with
// all the resources from the input jar. It also ensures that if it was uncompressed in the input
// it stays uncompressed in the output.
-func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Path, uncompressDex bool, minSdkVersion android.SdkSpec, outputDir android.OutputPath) android.OutputPath {
+func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Path, uncompressDex bool, minSdkVersion android.ApiLevel, outputDir android.OutputPath) android.OutputPath {
// The output file has the same name as the input file and is in the output directory.
output := outputDir.Join(ctx, dexInput.Base())
@@ -283,7 +283,7 @@
// If the library is targeted for Q and/or R then make sure that they do not
// have any S+ flags encoded as that will break the runtime.
- minApiLevel := minSdkVersion.ApiLevel
+ minApiLevel := minSdkVersion
if !minApiLevel.IsNone() {
if minApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(ctx, "R")) {
hiddenapiFlags = hiddenapiFlags + " --max-hiddenapi-level=max-target-r"
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index be4a48e..445ca1e 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -1278,7 +1278,7 @@
uncompressDex bool
// The minimum sdk version that the dex jar will be used on.
- minSdkVersion android.SdkSpec
+ minSdkVersion android.ApiLevel
}
// bootDexInfoByModule is a map from module name (as returned by module.Name()) to the boot dex
diff --git a/java/java.go b/java/java.go
index 0841dad..287bdac 100644
--- a/java/java.go
+++ b/java/java.go
@@ -811,7 +811,7 @@
// If the min_sdk_version was set then add the canonical representation of the API level to the
// snapshot.
if j.deviceProperties.Min_sdk_version != nil {
- canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.ApiLevel.String())
+ canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.String())
p.MinSdkVersion = proptools.StringPtr(canonical)
}
@@ -1874,7 +1874,7 @@
hideApexVariantFromMake bool
sdkVersion android.SdkSpec
- minSdkVersion android.SdkSpec
+ minSdkVersion android.ApiLevel
}
var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil)
@@ -1891,11 +1891,11 @@
return "none"
}
-func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
if j.properties.Min_sdk_version != nil {
- return android.SdkSpecFrom(ctx, *j.properties.Min_sdk_version)
+ return android.ApiLevelFrom(ctx, *j.properties.Min_sdk_version)
}
- return j.SdkVersion(ctx)
+ return j.SdkVersion(ctx).ApiLevel
}
func (j *Import) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
@@ -2161,15 +2161,14 @@
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
sdkVersion android.ApiLevel) error {
sdkVersionSpec := j.SdkVersion(ctx)
- minSdkVersionSpec := j.MinSdkVersion(ctx)
- if !minSdkVersionSpec.Specified() {
+ minSdkVersion := j.MinSdkVersion(ctx)
+ if !minSdkVersion.Specified() {
return fmt.Errorf("min_sdk_version is not specified")
}
// If the module is compiling against core (via sdk_version), skip comparison check.
if sdkVersionSpec.Kind == android.SdkCore {
return nil
}
- minSdkVersion := minSdkVersionSpec.ApiLevel
if minSdkVersion.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", minSdkVersion)
}
diff --git a/java/rro.go b/java/rro.go
index 9d0667c..49737b9 100644
--- a/java/rro.go
+++ b/java/rro.go
@@ -175,11 +175,11 @@
return ""
}
-func (r *RuntimeResourceOverlay) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+func (r *RuntimeResourceOverlay) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
if r.properties.Min_sdk_version != nil {
- return android.SdkSpecFrom(ctx, *r.properties.Min_sdk_version)
+ return android.ApiLevelFrom(ctx, *r.properties.Min_sdk_version)
}
- return r.SdkVersion(ctx)
+ return r.SdkVersion(ctx).ApiLevel
}
func (r *RuntimeResourceOverlay) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index d2fbfd9..5477ed6 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1231,7 +1231,7 @@
var _ android.ModuleWithMinSdkVersionCheck = (*SdkLibrary)(nil)
func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) {
- android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx).ApiLevel, func(c android.ModuleContext, do android.PayloadDepsCallback) {
+ android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx), func(c android.ModuleContext, do android.PayloadDepsCallback) {
ctx.WalkDeps(func(child android.Module, parent android.Module) bool {
isExternal := !module.depIsInSameApex(ctx, child)
if am, ok := child.(android.ApexModule); ok {
@@ -1775,7 +1775,7 @@
// Creates the xml file that publicizes the runtime library
func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
- moduleMinApiLevel := module.Library.MinSdkVersion(mctx).ApiLevel
+ moduleMinApiLevel := module.Library.MinSdkVersion(mctx)
var moduleMinApiLevelStr = moduleMinApiLevel.String()
if moduleMinApiLevel == android.NoneApiLevel {
moduleMinApiLevelStr = "current"
@@ -2414,8 +2414,8 @@
}
// MinSdkVersion - Implements hiddenAPIModule
-func (module *SdkLibraryImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
- return android.SdkSpecNone
+func (module *SdkLibraryImport) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
+ return android.NoneApiLevel
}
var _ hiddenAPIModule = (*SdkLibraryImport)(nil)
diff --git a/python/test.go b/python/test.go
index fb8e918..31da17e 100644
--- a/python/test.go
+++ b/python/test.go
@@ -15,6 +15,8 @@
package python
import (
+ "fmt"
+
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -63,7 +65,22 @@
Java_data []string
// Test options.
- Test_options android.CommonTestOptions
+ Test_options TestOptions
+}
+
+type TestOptions struct {
+ android.CommonTestOptions
+
+ // Runner for the test. Supports "tradefed" and "mobly" (for multi-device tests). Default is "tradefed".
+ Runner *string
+
+ // Metadata to describe the test configuration.
+ Metadata []Metadata
+}
+
+type Metadata struct {
+ Name string
+ Value string
}
type PythonTestModule struct {
@@ -94,14 +111,41 @@
p.PythonLibraryModule.GenerateAndroidBuildActions(ctx)
p.buildBinary(ctx)
- p.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
- TestConfigProp: p.testProperties.Test_config,
- TestConfigTemplateProp: p.testProperties.Test_config_template,
- TestSuites: p.binaryProperties.Test_suites,
- AutoGenConfig: p.binaryProperties.Auto_gen_config,
- DeviceTemplate: "${PythonBinaryHostTestConfigTemplate}",
- HostTemplate: "${PythonBinaryHostTestConfigTemplate}",
- })
+ var configs []tradefed.Option
+ for _, metadata := range p.testProperties.Test_options.Metadata {
+ configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: metadata.Name, Value: metadata.Value})
+ }
+
+ runner := proptools.StringDefault(p.testProperties.Test_options.Runner, "tradefed")
+ if runner == "tradefed" {
+ p.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
+ TestConfigProp: p.testProperties.Test_config,
+ TestConfigTemplateProp: p.testProperties.Test_config_template,
+ TestSuites: p.binaryProperties.Test_suites,
+ OptionsForAutogenerated: configs,
+ AutoGenConfig: p.binaryProperties.Auto_gen_config,
+ DeviceTemplate: "${PythonBinaryHostTestConfigTemplate}",
+ HostTemplate: "${PythonBinaryHostTestConfigTemplate}",
+ })
+ } else if runner == "mobly" {
+ if p.testProperties.Test_config != nil || p.testProperties.Test_config_template != nil || p.binaryProperties.Auto_gen_config != nil {
+ panic(fmt.Errorf("cannot set test_config, test_config_template or auto_gen_config for mobly test"))
+ }
+
+ for _, testSuite := range p.binaryProperties.Test_suites {
+ if testSuite == "cts" {
+ configs = append(configs, tradefed.Option{Name: "test-suite-tag", Value: "cts"})
+ break
+ }
+ }
+ p.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
+ OptionsForAutogenerated: configs,
+ DeviceTemplate: "${PythonBinaryHostMoblyTestConfigTemplate}",
+ HostTemplate: "${PythonBinaryHostMoblyTestConfigTemplate}",
+ })
+ } else {
+ panic(fmt.Errorf("unknown python test runner '%s', should be 'tradefed' or 'mobly'", runner))
+ }
p.installedDest = ctx.InstallFile(installDir(ctx, "nativetest", "nativetest64", ctx.ModuleName()), p.installSource.Base(), p.installSource)
diff --git a/scripts/build-ndk-prebuilts.sh b/scripts/build-ndk-prebuilts.sh
index b57963b..964a866 100755
--- a/scripts/build-ndk-prebuilts.sh
+++ b/scripts/build-ndk-prebuilts.sh
@@ -19,7 +19,10 @@
exit 1
fi
-TARGET_PRODUCT=ndk build/soong/soong_ui.bash --make-mode --soong-only ${OUT_DIR}/soong/ndk.timestamp
+# TODO: remove this when all the riscv64 dependencies exist (currently blocked by
+# http://b/273792258).
+ALLOW_MISSING_DEPENDENCIES=true \
+ TARGET_PRODUCT=ndk build/soong/soong_ui.bash --make-mode --soong-only ${OUT_DIR}/soong/ndk.timestamp
if [ -n "${DIST_DIR}" ]; then
mkdir -p ${DIST_DIR} || true
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index efb97be..0d6496d 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -839,6 +839,7 @@
compile_dex: true,
public: {enabled: true},
permitted_packages: ["mysdklibrary"],
+ min_sdk_version: "current",
}
java_sdk_library {
diff --git a/sdk/update.go b/sdk/update.go
index 0820d62..5fb6f2d 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -319,7 +319,7 @@
targetBuildRelease := s.targetBuildRelease(ctx)
targetApiLevel, err := android.ApiLevelFromUser(ctx, targetBuildRelease.name)
if err != nil {
- targetApiLevel = android.FutureApiLevel
+ targetApiLevel = android.InvalidApiLevel
}
// Aggregate all the sdkMemberVariantDep instances from all the sdk variants.
@@ -357,6 +357,12 @@
// If the minApiLevel of the member is greater than the target API level then exclude it from
// this snapshot.
exclude := memberVariantDep.minApiLevel.GreaterThan(targetApiLevel)
+ // Always include host variants (e.g. host tools) in the snapshot.
+ // Host variants should not be guarded by a min_sdk_version check. In fact, host variants
+ // do not have a `min_sdk_version`.
+ if memberVariantDep.Host() {
+ exclude = false
+ }
addMember(name, export, exclude)
@@ -1263,6 +1269,11 @@
minApiLevel android.ApiLevel
}
+// Host returns true if the sdk member is a host variant (e.g. host tool)
+func (s *sdkMemberVariantDep) Host() bool {
+ return s.variant.Target().Os.Class == android.Host
+}
+
var _ android.SdkMember = (*sdkMember)(nil)
// sdkMember groups all the variants of a specific member module together along with the name of the
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index e1aa70c..7fa0dae 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -15,8 +15,8 @@
# mock client.
"$TOP/build/soong/tests/apex_comparison_tests.sh"
"$TOP/build/soong/tests/apex_comparison_tests.sh" "module_arm64only"
-extra_build_params=--bazel-mode-staging "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
-BUILD_BROKEN_DISABLE_BAZEL=true "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
+#extra_build_params=--bazel-mode-staging "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
+#BUILD_BROKEN_DISABLE_BAZEL=true "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh"
"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_arm" "armv7-a"
"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_cf_arm64_phone" "armv8-a" "cortex-a53"
diff --git a/tradefed/config.go b/tradefed/config.go
index 999424c..326a006 100644
--- a/tradefed/config.go
+++ b/tradefed/config.go
@@ -31,6 +31,7 @@
pctx.SourcePathVariable("NativeBenchmarkTestConfigTemplate", "build/make/core/native_benchmark_test_config_template.xml")
pctx.SourcePathVariable("NativeHostTestConfigTemplate", "build/make/core/native_host_test_config_template.xml")
pctx.SourcePathVariable("NativeTestConfigTemplate", "build/make/core/native_test_config_template.xml")
+ pctx.SourcePathVariable("PythonBinaryHostMoblyTestConfigTemplate", "build/make/core/python_binary_host_mobly_test_config_template.xml")
pctx.SourcePathVariable("PythonBinaryHostTestConfigTemplate", "build/make/core/python_binary_host_test_config_template.xml")
pctx.SourcePathVariable("RustDeviceTestConfigTemplate", "build/make/core/rust_device_test_config_template.xml")
pctx.SourcePathVariable("RustHostTestConfigTemplate", "build/make/core/rust_host_test_config_template.xml")
diff --git a/ui/build/soong.go b/ui/build/soong.go
index 655ae35..871e637 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -168,7 +168,7 @@
commonArgs = append(commonArgs, "-t")
}
- if !pb.config.multitreeBuild {
+ if pb.config.multitreeBuild {
commonArgs = append(commonArgs, "--multitree-build")
}