Merge changes I08ec0b44,I79b5a1fc,I469d6558 am: 6abfb33784
am: 3bcefabfeb
am: dc2accaba0
am: a0b46c1d06
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1907862 Change-Id: I0ffda740f28a4f1309fae0be43f40904ef4f2168
This commit is contained in:
@@ -1643,8 +1643,7 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
|
||||
}
|
||||
|
||||
// Implements android.ApexModule
|
||||
func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
||||
sdkVersion android.ApiLevel) error {
|
||||
func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
||||
sdkSpec := j.MinSdkVersion(ctx)
|
||||
if !sdkSpec.Specified() {
|
||||
return fmt.Errorf("min_sdk_version is not specified")
|
||||
|
@@ -1129,6 +1129,22 @@ func (module *SdkLibrary) getGeneratedApiScopes(ctx android.EarlyModuleContext)
|
||||
return generatedScopes
|
||||
}
|
||||
|
||||
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) {
|
||||
ctx.WalkDeps(func(child android.Module, parent android.Module) bool {
|
||||
isExternal := !module.depIsInSameApex(ctx, child)
|
||||
if am, ok := child.(android.ApexModule); ok {
|
||||
if !do(ctx, parent, am, isExternal) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return !isExternal
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
type sdkLibraryComponentTag struct {
|
||||
blueprint.BaseDependencyTag
|
||||
name string
|
||||
@@ -1214,6 +1230,10 @@ func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
||||
}
|
||||
|
||||
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
if proptools.String(module.deviceProperties.Min_sdk_version) != "" {
|
||||
module.CheckMinSdkVersion(ctx)
|
||||
}
|
||||
|
||||
module.generateCommonBuildActions(ctx)
|
||||
|
||||
// Only build an implementation library if required.
|
||||
@@ -2605,12 +2625,12 @@ func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleConte
|
||||
|
||||
func (module *sdkLibraryXml) AndroidMkEntries() []android.AndroidMkEntries {
|
||||
if module.hideApexVariantFromMake {
|
||||
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
||||
return []android.AndroidMkEntries{{
|
||||
Disabled: true,
|
||||
}}
|
||||
}
|
||||
|
||||
return []android.AndroidMkEntries{android.AndroidMkEntries{
|
||||
return []android.AndroidMkEntries{{
|
||||
Class: "ETC",
|
||||
OutputFile: android.OptionalPathForPath(module.outputFilePath),
|
||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||
|
@@ -1140,3 +1140,87 @@ func TestJavaSdkLibraryDist(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSdkLibrary_CheckMinSdkVersion(t *testing.T) {
|
||||
preparer := android.GroupFixturePreparers(
|
||||
PrepareForTestWithJavaBuildComponents,
|
||||
PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithJavaSdkLibraryFiles,
|
||||
)
|
||||
|
||||
preparer.RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "sdklib",
|
||||
srcs: ["a.java"],
|
||||
static_libs: ["util"],
|
||||
min_sdk_version: "30",
|
||||
unsafe_ignore_missing_latest_api: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "util",
|
||||
srcs: ["a.java"],
|
||||
min_sdk_version: "30",
|
||||
}
|
||||
`)
|
||||
|
||||
preparer.
|
||||
RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "sdklib",
|
||||
srcs: ["a.java"],
|
||||
libs: ["util"],
|
||||
impl_only_libs: ["util"],
|
||||
stub_only_libs: ["util"],
|
||||
stub_only_static_libs: ["util"],
|
||||
min_sdk_version: "30",
|
||||
unsafe_ignore_missing_latest_api: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "util",
|
||||
srcs: ["a.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "util".*should support min_sdk_version\(30\)`)).
|
||||
RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "sdklib",
|
||||
srcs: ["a.java"],
|
||||
static_libs: ["util"],
|
||||
min_sdk_version: "30",
|
||||
unsafe_ignore_missing_latest_api: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "util",
|
||||
srcs: ["a.java"],
|
||||
min_sdk_version: "31",
|
||||
}
|
||||
`)
|
||||
|
||||
preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "another_util".*should support min_sdk_version\(30\)`)).
|
||||
RunTestWithBp(t, `
|
||||
java_sdk_library {
|
||||
name: "sdklib",
|
||||
srcs: ["a.java"],
|
||||
static_libs: ["util"],
|
||||
min_sdk_version: "30",
|
||||
unsafe_ignore_missing_latest_api: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "util",
|
||||
srcs: ["a.java"],
|
||||
static_libs: ["another_util"],
|
||||
min_sdk_version: "30",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "another_util",
|
||||
srcs: ["a.java"],
|
||||
min_sdk_version: "31",
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
Reference in New Issue
Block a user