Merge "Do not allow duplicate deapexer dependencies."
This commit is contained in:
@@ -143,12 +143,16 @@ type RequiresFilesFromPrebuiltApexTag interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FindDeapexerProviderForModule searches through the direct dependencies of the current context
|
// FindDeapexerProviderForModule searches through the direct dependencies of the current context
|
||||||
// module for a DeapexerTag dependency and returns its DeapexerInfo. If there is an error then it is
|
// module for a DeapexerTag dependency and returns its DeapexerInfo. If a single nonambiguous
|
||||||
// reported with ctx.ModuleErrorf and nil is returned.
|
// deapexer module isn't found then errors are reported with ctx.ModuleErrorf and nil is returned.
|
||||||
func FindDeapexerProviderForModule(ctx ModuleContext) *DeapexerInfo {
|
func FindDeapexerProviderForModule(ctx ModuleContext) *DeapexerInfo {
|
||||||
var di *DeapexerInfo
|
var di *DeapexerInfo
|
||||||
ctx.VisitDirectDepsWithTag(DeapexerTag, func(m Module) {
|
ctx.VisitDirectDepsWithTag(DeapexerTag, func(m Module) {
|
||||||
p := ctx.OtherModuleProvider(m, DeapexerProvider).(DeapexerInfo)
|
p := ctx.OtherModuleProvider(m, DeapexerProvider).(DeapexerInfo)
|
||||||
|
if di != nil {
|
||||||
|
ctx.ModuleErrorf("Multiple installable prebuilt APEXes provide ambiguous deapexers: %s and %s",
|
||||||
|
di.ApexModuleName(), p.ApexModuleName())
|
||||||
|
}
|
||||||
di = &p
|
di = &p
|
||||||
})
|
})
|
||||||
if di != nil {
|
if di != nil {
|
||||||
|
@@ -7045,6 +7045,75 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, preparer android.F
|
|||||||
return result.TestContext
|
return result.TestContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDuplicateDeapexeresFromPrebuiltApexes(t *testing.T) {
|
||||||
|
preparers := android.GroupFixturePreparers(
|
||||||
|
java.PrepareForTestWithJavaDefaultModules,
|
||||||
|
PrepareForTestWithApexBuildComponents,
|
||||||
|
).
|
||||||
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
|
"Multiple installable prebuilt APEXes provide ambiguous deapexers: com.android.myapex and com.mycompany.android.myapex"))
|
||||||
|
|
||||||
|
bpBase := `
|
||||||
|
apex_set {
|
||||||
|
name: "com.android.myapex",
|
||||||
|
installable: true,
|
||||||
|
exported_bootclasspath_fragments: ["my-bootclasspath-fragment"],
|
||||||
|
set: "myapex.apks",
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_set {
|
||||||
|
name: "com.mycompany.android.myapex",
|
||||||
|
apex_name: "com.android.myapex",
|
||||||
|
installable: true,
|
||||||
|
exported_bootclasspath_fragments: ["my-bootclasspath-fragment"],
|
||||||
|
set: "company-myapex.apks",
|
||||||
|
}
|
||||||
|
|
||||||
|
prebuilt_bootclasspath_fragment {
|
||||||
|
name: "my-bootclasspath-fragment",
|
||||||
|
apex_available: ["com.android.myapex"],
|
||||||
|
%s
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
t.Run("java_import", func(t *testing.T) {
|
||||||
|
_ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
|
||||||
|
java_import {
|
||||||
|
name: "libfoo",
|
||||||
|
jars: ["libfoo.jar"],
|
||||||
|
apex_available: ["com.android.myapex"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("java_sdk_library_import", func(t *testing.T) {
|
||||||
|
_ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
|
||||||
|
java_sdk_library_import {
|
||||||
|
name: "libfoo",
|
||||||
|
public: {
|
||||||
|
jars: ["libbar.jar"],
|
||||||
|
},
|
||||||
|
apex_available: ["com.android.myapex"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("prebuilt_bootclasspath_fragment", func(t *testing.T) {
|
||||||
|
_ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `
|
||||||
|
image_name: "art",
|
||||||
|
contents: ["libfoo"],
|
||||||
|
`)+`
|
||||||
|
java_sdk_library_import {
|
||||||
|
name: "libfoo",
|
||||||
|
public: {
|
||||||
|
jars: ["libbar.jar"],
|
||||||
|
},
|
||||||
|
apex_available: ["com.android.myapex"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpdatable_should_set_min_sdk_version(t *testing.T) {
|
func TestUpdatable_should_set_min_sdk_version(t *testing.T) {
|
||||||
testApexError(t, `"myapex" .*: updatable: updatable APEXes should set min_sdk_version`, `
|
testApexError(t, `"myapex" .*: updatable: updatable APEXes should set min_sdk_version`, `
|
||||||
apex {
|
apex {
|
||||||
|
@@ -548,7 +548,7 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
|
func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
preparers := android.GroupFixturePreparers(
|
||||||
prepareForTestWithBootclasspathFragment,
|
prepareForTestWithBootclasspathFragment,
|
||||||
prepareForTestWithArtApex,
|
prepareForTestWithArtApex,
|
||||||
|
|
||||||
@@ -559,7 +559,9 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
|
|||||||
|
|
||||||
// Configure some libraries in the art bootclasspath_fragment.
|
// Configure some libraries in the art bootclasspath_fragment.
|
||||||
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
|
java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"),
|
||||||
).RunTestWithBp(t, `
|
)
|
||||||
|
|
||||||
|
bp := `
|
||||||
prebuilt_apex {
|
prebuilt_apex {
|
||||||
name: "com.android.art",
|
name: "com.android.art",
|
||||||
arch: {
|
arch: {
|
||||||
@@ -605,22 +607,45 @@ func TestBootclasspathFragmentInPrebuiltArtApex(t *testing.T) {
|
|||||||
all_flags: "mybootclasspathfragment/all-flags.csv",
|
all_flags: "mybootclasspathfragment/all-flags.csv",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`)
|
|
||||||
|
|
||||||
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
|
// A prebuilt apex with the same apex_name that shouldn't interfere when it isn't enabled.
|
||||||
`com.android.art.apex.selector`,
|
prebuilt_apex {
|
||||||
`prebuilt_mybootclasspathfragment`,
|
name: "com.mycompany.android.art",
|
||||||
|
apex_name: "com.android.art",
|
||||||
|
%s
|
||||||
|
src: "com.mycompany.android.art.apex",
|
||||||
|
exported_bootclasspath_fragments: ["mybootclasspathfragment"],
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
t.Run("disabled alternative APEX", func(t *testing.T) {
|
||||||
|
result := preparers.RunTestWithBp(t, fmt.Sprintf(bp, "enabled: false,"))
|
||||||
|
|
||||||
|
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
|
||||||
|
`com.android.art.apex.selector`,
|
||||||
|
`prebuilt_mybootclasspathfragment`,
|
||||||
|
})
|
||||||
|
|
||||||
|
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_com.android.art", []string{
|
||||||
|
`com.android.art.deapexer`,
|
||||||
|
`dex2oatd`,
|
||||||
|
`prebuilt_bar`,
|
||||||
|
`prebuilt_foo`,
|
||||||
|
})
|
||||||
|
|
||||||
|
module := result.ModuleForTests("mybootclasspathfragment", "android_common_com.android.art")
|
||||||
|
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
|
||||||
|
|
||||||
|
// Check that the right deapexer module was chosen for a boot image.
|
||||||
|
param := module.Output("out/soong/test_device/dex_artjars/android/apex/art_boot_images/javalib/arm64/boot.art")
|
||||||
|
android.AssertStringDoesContain(t, "didn't find the expected deapexer in the input path", param.Input.String(), "/com.android.art.deapexer")
|
||||||
})
|
})
|
||||||
|
|
||||||
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_com.android.art", []string{
|
t.Run("enabled alternative APEX", func(t *testing.T) {
|
||||||
`com.android.art.deapexer`,
|
preparers.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||||
`dex2oatd`,
|
"Multiple installable prebuilt APEXes provide ambiguous deapexers: com.android.art and com.mycompany.android.art")).
|
||||||
`prebuilt_bar`,
|
RunTestWithBp(t, fmt.Sprintf(bp, ""))
|
||||||
`prebuilt_foo`,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
module := result.ModuleForTests("mybootclasspathfragment", "android_common_com.android.art")
|
|
||||||
checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkCopiesToPredefinedLocationForArt checks that the supplied modules are copied to the
|
// checkCopiesToPredefinedLocationForArt checks that the supplied modules are copied to the
|
||||||
|
Reference in New Issue
Block a user