Remove deapex support from java_*_import
prebuilt_apex/apex_set currently supports its deapexed contents to be returned via a sibling java_import/java_sdk_import module. This is necesssary for 1. dexpreopt/hiddenapi processing 2. usage as shared library (1) is no longer necessary. this information is provided by the top-level prebuilt apexes now (2) is no longer possible since `exported_java_libs` has been removed in https://r.android.com/3272110 This CL uses a hack for java_sdk_library_improt. Even though (1) is provided by the top-level apex, there are still some places where dexpreopt/hiddenapi processing visits the import modules. This CL uses a bogus path to make analysis work. If this bogus path gets used, there will be an error during ninja execution Test: go test ./apex Test: in internal lunch cf_x86_64_phone-next-userdebug (uses mainline prebuilts) Test: verified that file_list.txt is same Bug: 368337090 Change-Id: I0ea2327f648f0fc60e337b232f7265e140772ffd
This commit is contained in:
@@ -4907,23 +4907,6 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
}),
|
||||
)
|
||||
|
||||
checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) {
|
||||
t.Helper()
|
||||
s := ctx.ModuleForTests("dex_bootjars", "android_common")
|
||||
foundLibfooJar := false
|
||||
base := stem + ".jar"
|
||||
for _, output := range s.AllOutputs() {
|
||||
if filepath.Base(output) == base {
|
||||
foundLibfooJar = true
|
||||
buildRule := s.Output(output)
|
||||
android.AssertStringEquals(t, "boot dex jar path", bootDexJarPath, buildRule.Input.String())
|
||||
}
|
||||
}
|
||||
if !foundLibfooJar {
|
||||
t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs %q", android.StringPathsRelativeToTop(ctx.Config().SoongOutDir(), s.AllOutputs()))
|
||||
}
|
||||
}
|
||||
|
||||
checkHiddenAPIIndexFromClassesInputs := func(t *testing.T, ctx *android.TestContext, expectedIntermediateInputs string) {
|
||||
t.Helper()
|
||||
platformBootclasspath := ctx.ModuleForTests("platform-bootclasspath", "android_common")
|
||||
@@ -4996,8 +4979,6 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
`
|
||||
|
||||
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
|
||||
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
|
||||
|
||||
// Verify the correct module jars contribute to the hiddenapi index file.
|
||||
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
|
||||
@@ -5066,8 +5047,6 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
`
|
||||
|
||||
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
|
||||
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
|
||||
|
||||
// Verify the correct module jars contribute to the hiddenapi index file.
|
||||
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
|
||||
@@ -5259,8 +5238,6 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
`
|
||||
|
||||
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
|
||||
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
|
||||
|
||||
// Verify the correct module jars contribute to the hiddenapi index file.
|
||||
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
|
||||
@@ -5359,8 +5336,6 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
`
|
||||
|
||||
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
|
||||
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/hiddenapi-modular/encoded/libfoo.jar")
|
||||
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/hiddenapi-modular/encoded/libbar.jar")
|
||||
|
||||
// Verify the correct module jars contribute to the hiddenapi index file.
|
||||
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
|
||||
@@ -5472,8 +5447,6 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||
)
|
||||
|
||||
ctx := testDexpreoptWithApexes(t, bp, "", preparer2, fragment)
|
||||
checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
|
||||
|
||||
// Verify the correct module jars contribute to the hiddenapi index file.
|
||||
checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
|
||||
@@ -7973,189 +7946,6 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, preparer android.F
|
||||
return result.TestContext
|
||||
}
|
||||
|
||||
func TestDuplicateDeapexersFromPrebuiltApexes(t *testing.T) {
|
||||
preparers := android.GroupFixturePreparers(
|
||||
java.PrepareForTestWithJavaDefaultModules,
|
||||
prepareForTestWithBootclasspathFragment,
|
||||
dexpreopt.FixtureSetTestOnlyArtBootImageJars("com.android.art:libfoo"),
|
||||
PrepareForTestWithApexBuildComponents,
|
||||
).
|
||||
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
|
||||
"Multiple installable prebuilt APEXes provide ambiguous deapexers: prebuilt_com.android.art and prebuilt_com.mycompany.android.art"))
|
||||
|
||||
bpBase := `
|
||||
apex_set {
|
||||
name: "com.android.art",
|
||||
installable: true,
|
||||
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
|
||||
set: "myapex.apks",
|
||||
}
|
||||
|
||||
apex_set {
|
||||
name: "com.mycompany.android.art",
|
||||
apex_name: "com.android.art",
|
||||
installable: true,
|
||||
exported_bootclasspath_fragments: ["art-bootclasspath-fragment"],
|
||||
set: "company-myapex.apks",
|
||||
}
|
||||
|
||||
prebuilt_bootclasspath_fragment {
|
||||
name: "art-bootclasspath-fragment",
|
||||
apex_available: ["com.android.art"],
|
||||
hidden_api: {
|
||||
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
|
||||
metadata: "my-bootclasspath-fragment/metadata.csv",
|
||||
index: "my-bootclasspath-fragment/index.csv",
|
||||
stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
|
||||
all_flags: "my-bootclasspath-fragment/all-flags.csv",
|
||||
},
|
||||
%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.art"],
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
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"],
|
||||
},
|
||||
shared_library: false,
|
||||
apex_available: ["com.android.art"],
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
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"],
|
||||
},
|
||||
shared_library: false,
|
||||
apex_available: ["com.android.art"],
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
func TestDuplicateButEquivalentDeapexersFromPrebuiltApexes(t *testing.T) {
|
||||
preparers := android.GroupFixturePreparers(
|
||||
java.PrepareForTestWithJavaDefaultModules,
|
||||
PrepareForTestWithApexBuildComponents,
|
||||
)
|
||||
|
||||
errCtx := moduleErrorfTestCtx{}
|
||||
|
||||
bpBase := `
|
||||
apex_set {
|
||||
name: "com.android.myapex",
|
||||
installable: true,
|
||||
exported_bootclasspath_fragments: ["my-bootclasspath-fragment"],
|
||||
set: "myapex.apks",
|
||||
}
|
||||
|
||||
apex_set {
|
||||
name: "com.android.myapex_compressed",
|
||||
apex_name: "com.android.myapex",
|
||||
installable: true,
|
||||
exported_bootclasspath_fragments: ["my-bootclasspath-fragment"],
|
||||
set: "myapex_compressed.apks",
|
||||
}
|
||||
|
||||
prebuilt_bootclasspath_fragment {
|
||||
name: "my-bootclasspath-fragment",
|
||||
apex_available: [
|
||||
"com.android.myapex",
|
||||
"com.android.myapex_compressed",
|
||||
],
|
||||
hidden_api: {
|
||||
annotation_flags: "annotation-flags.csv",
|
||||
metadata: "metadata.csv",
|
||||
index: "index.csv",
|
||||
signature_patterns: "signature_patterns.csv",
|
||||
},
|
||||
%s
|
||||
}
|
||||
`
|
||||
|
||||
t.Run("java_import", func(t *testing.T) {
|
||||
result := preparers.RunTestWithBp(t,
|
||||
fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
|
||||
java_import {
|
||||
name: "libfoo",
|
||||
jars: ["libfoo.jar"],
|
||||
apex_available: [
|
||||
"com.android.myapex",
|
||||
"com.android.myapex_compressed",
|
||||
],
|
||||
}
|
||||
`)
|
||||
|
||||
module := result.Module("libfoo", "android_common_com.android.myapex")
|
||||
usesLibraryDep := module.(java.UsesLibraryDependency)
|
||||
android.AssertPathRelativeToTopEquals(t, "dex jar path",
|
||||
"out/soong/.intermediates/prebuilt_com.android.myapex.deapexer/android_common/deapexer/javalib/libfoo.jar",
|
||||
usesLibraryDep.DexJarBuildPath(errCtx).Path())
|
||||
})
|
||||
|
||||
t.Run("java_sdk_library_import", func(t *testing.T) {
|
||||
result := preparers.RunTestWithBp(t,
|
||||
fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
|
||||
java_sdk_library_import {
|
||||
name: "libfoo",
|
||||
public: {
|
||||
jars: ["libbar.jar"],
|
||||
},
|
||||
apex_available: [
|
||||
"com.android.myapex",
|
||||
"com.android.myapex_compressed",
|
||||
],
|
||||
compile_dex: true,
|
||||
}
|
||||
`)
|
||||
|
||||
module := result.Module("libfoo", "android_common_com.android.myapex")
|
||||
usesLibraryDep := module.(java.UsesLibraryDependency)
|
||||
android.AssertPathRelativeToTopEquals(t, "dex jar path",
|
||||
"out/soong/.intermediates/prebuilt_com.android.myapex.deapexer/android_common/deapexer/javalib/libfoo.jar",
|
||||
usesLibraryDep.DexJarBuildPath(errCtx).Path())
|
||||
})
|
||||
|
||||
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",
|
||||
"com.android.myapex_compressed",
|
||||
],
|
||||
compile_dex: true,
|
||||
}
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
func TestUpdatable_should_set_min_sdk_version(t *testing.T) {
|
||||
testApexError(t, `"myapex" .*: updatable: updatable APEXes should set min_sdk_version`, `
|
||||
apex {
|
||||
|
39
java/java.go
39
java/java.go
@@ -2818,41 +2818,14 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
if ctx.Device() {
|
||||
// If this is a variant created for a prebuilt_apex then use the dex implementation jar
|
||||
// obtained from the associated deapexer module.
|
||||
// Shared libraries deapexed from prebuilt apexes are no longer supported.
|
||||
// Set the dexJarBuildPath to a fake path.
|
||||
// This allows soong analysis pass, but will be an error during ninja execution if there are
|
||||
// any rdeps.
|
||||
ai, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
||||
if ai.ForPrebuiltApex {
|
||||
// Get the path of the dex implementation jar from the `deapexer` module.
|
||||
di, err := android.FindDeapexerProviderForModule(ctx)
|
||||
if err != nil {
|
||||
// An error was found, possibly due to multiple apexes in the tree that export this library
|
||||
// Defer the error till a client tries to call DexJarBuildPath
|
||||
j.dexJarFileErr = err
|
||||
j.initHiddenAPIError(err)
|
||||
return
|
||||
}
|
||||
dexJarFileApexRootRelative := ApexRootRelativePathToJavaLib(j.BaseModuleName())
|
||||
if dexOutputPath := di.PrebuiltExportPath(dexJarFileApexRootRelative); dexOutputPath != nil {
|
||||
dexJarFile := makeDexJarPathFromPath(dexOutputPath)
|
||||
j.dexJarFile = dexJarFile
|
||||
installPath := android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, ApexRootRelativePathToJavaLib(j.BaseModuleName()))
|
||||
j.dexJarInstallFile = installPath
|
||||
|
||||
j.dexpreopter.installPath = j.dexpreopter.getInstallPath(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), installPath)
|
||||
setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
|
||||
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
||||
|
||||
if profilePath := di.PrebuiltExportPath(dexJarFileApexRootRelative + ".prof"); profilePath != nil {
|
||||
j.dexpreopter.inputProfilePathOnHost = profilePath
|
||||
}
|
||||
|
||||
// Initialize the hiddenapi structure.
|
||||
j.initHiddenAPI(ctx, dexJarFile, outputFile, j.dexProperties.Uncompress_dex)
|
||||
} else {
|
||||
// This should never happen as a variant for a prebuilt_apex is only created if the
|
||||
// prebuilt_apex has been configured to export the java library dex file.
|
||||
ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt APEX %s", di.ApexModuleName())
|
||||
}
|
||||
j.dexJarFile = makeDexJarPathFromPath(android.PathForModuleInstall(ctx, "intentionally_no_longer_supported"))
|
||||
j.initHiddenAPI(ctx, j.dexJarFile, outputFile, j.dexProperties.Uncompress_dex)
|
||||
} else if Bool(j.dexProperties.Compile_dex) {
|
||||
sdkDep := decodeSdkDep(ctx, android.SdkContext(j))
|
||||
if sdkDep.invalidVersion {
|
||||
|
@@ -2823,40 +2823,14 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo
|
||||
}
|
||||
|
||||
if ctx.Device() {
|
||||
// If this is a variant created for a prebuilt_apex then use the dex implementation jar
|
||||
// obtained from the associated deapexer module.
|
||||
// Shared libraries deapexed from prebuilt apexes are no longer supported.
|
||||
// Set the dexJarBuildPath to a fake path.
|
||||
// This allows soong analysis pass, but will be an error during ninja execution if there are
|
||||
// any rdeps.
|
||||
ai, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
|
||||
if ai.ForPrebuiltApex {
|
||||
// Get the path of the dex implementation jar from the `deapexer` module.
|
||||
di, err := android.FindDeapexerProviderForModule(ctx)
|
||||
if err != nil {
|
||||
// An error was found, possibly due to multiple apexes in the tree that export this library
|
||||
// Defer the error till a client tries to call DexJarBuildPath
|
||||
module.dexJarFileErr = err
|
||||
module.initHiddenAPIError(err)
|
||||
return
|
||||
}
|
||||
dexJarFileApexRootRelative := ApexRootRelativePathToJavaLib(module.BaseModuleName())
|
||||
if dexOutputPath := di.PrebuiltExportPath(dexJarFileApexRootRelative); dexOutputPath != nil {
|
||||
dexJarFile := makeDexJarPathFromPath(dexOutputPath)
|
||||
module.dexJarFile = dexJarFile
|
||||
installPath := android.PathForModuleInPartitionInstall(
|
||||
ctx, "apex", ai.ApexVariationName, dexJarFileApexRootRelative)
|
||||
module.installFile = installPath
|
||||
module.initHiddenAPI(ctx, dexJarFile, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
|
||||
|
||||
module.dexpreopter.installPath = module.dexpreopter.getInstallPath(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), installPath)
|
||||
module.dexpreopter.isSDKLibrary = true
|
||||
module.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), &module.dexpreopter)
|
||||
|
||||
if profilePath := di.PrebuiltExportPath(dexJarFileApexRootRelative + ".prof"); profilePath != nil {
|
||||
module.dexpreopter.inputProfilePathOnHost = profilePath
|
||||
}
|
||||
} else {
|
||||
// This should never happen as a variant for a prebuilt_apex is only created if the
|
||||
// prebuilt_apex has been configured to export the java library dex file.
|
||||
ctx.ModuleErrorf("internal error: no dex implementation jar available from prebuilt APEX %s", di.ApexModuleName())
|
||||
}
|
||||
module.dexJarFile = makeDexJarPathFromPath(android.PathForModuleInstall(ctx, "intentionally_no_longer_supported"))
|
||||
module.initHiddenAPI(ctx, module.dexJarFile, module.findScopePaths(apiScopePublic).stubsImplPath[0], nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -204,7 +204,19 @@ java_import {
|
||||
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar
|
||||
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar
|
||||
`),
|
||||
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
|
||||
snapshotTestPreparer(checkSnapshotWithoutSource, android.GroupFixturePreparers(
|
||||
preparerForSnapshot,
|
||||
// Flag ART prebuilts
|
||||
android.FixtureMergeMockFs(android.MockFS{
|
||||
"apex_contributions/Android.bp": []byte(`
|
||||
apex_contributions {
|
||||
name: "prebuilt_art_contributions",
|
||||
contents: ["prebuilt_com.android.art"],
|
||||
api_domain: "com.android.art",
|
||||
}
|
||||
`)}),
|
||||
android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "prebuilt_art_contributions"),
|
||||
)),
|
||||
|
||||
// Check the behavior of the snapshot without the source.
|
||||
snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
|
||||
|
Reference in New Issue
Block a user