Merge "Add srcjar output for platform_bootclasspath" into main am: c38757d0c0 am: 10d91d7107

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2757569

Change-Id: I6ebb3f0be38af38f2f862593a3f185579d231d7d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Anton Hansson 2023-09-28 18:28:50 +00:00 committed by Automerger Merge Worker
commit f7931b390a
2 changed files with 41 additions and 0 deletions

View file

@ -173,6 +173,18 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
allModules = append(allModules, apexModules...) allModules = append(allModules, apexModules...)
b.configuredModules = allModules b.configuredModules = allModules
var transitiveSrcFiles android.Paths
for _, module := range allModules {
depInfo := ctx.OtherModuleProvider(module, JavaInfoProvider).(JavaInfo)
if depInfo.TransitiveSrcFiles != nil {
transitiveSrcFiles = append(transitiveSrcFiles, depInfo.TransitiveSrcFiles.ToList()...)
}
}
jarArgs := resourcePathsToJarArgs(transitiveSrcFiles)
jarArgs = append(jarArgs, "-srcjar") // Move srcfiles to the right package
transitiveSrcJar := android.PathForModuleOut(ctx, ctx.ModuleName()+"-transitive.srcjar")
TransformResourcesToJar(ctx, transitiveSrcJar, jarArgs, transitiveSrcFiles)
// Gather all the fragments dependencies. // Gather all the fragments dependencies.
b.fragments = gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag) b.fragments = gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag)

View file

@ -81,6 +81,15 @@ func TestPlatformBootclasspath(t *testing.T) {
RunTest(t) RunTest(t)
}) })
fooSourceSrc := "source/a.java"
barSrc := "a.java"
checkSrcJarInputs := func(t *testing.T, result *android.TestResult, name string, expected []string) {
t.Helper()
srcjar := result.ModuleForTests(name, "android_common").Output(name + "-transitive.srcjar")
android.AssertStringDoesContain(t, "srcjar arg", srcjar.Args["jarArgs"], "-srcjar")
android.AssertArrayString(t, "srcjar inputs", expected, srcjar.Implicits.Strings())
}
t.Run("source", func(t *testing.T) { t.Run("source", func(t *testing.T) {
result := android.GroupFixturePreparers( result := android.GroupFixturePreparers(
preparer, preparer,
@ -91,6 +100,10 @@ func TestPlatformBootclasspath(t *testing.T) {
"platform:foo", "platform:foo",
"platform:bar", "platform:bar",
}) })
checkSrcJarInputs(t, result, "platform-bootclasspath", []string{
fooSourceSrc,
barSrc,
})
}) })
t.Run("prebuilt", func(t *testing.T) { t.Run("prebuilt", func(t *testing.T) {
@ -103,6 +116,10 @@ func TestPlatformBootclasspath(t *testing.T) {
"platform:prebuilt_foo", "platform:prebuilt_foo",
"platform:bar", "platform:bar",
}) })
checkSrcJarInputs(t, result, "platform-bootclasspath", []string{
// TODO(b/151360309): This should also have the srcs for prebuilt_foo
barSrc,
})
}) })
t.Run("source+prebuilt - source preferred", func(t *testing.T) { t.Run("source+prebuilt - source preferred", func(t *testing.T) {
@ -116,6 +133,10 @@ func TestPlatformBootclasspath(t *testing.T) {
"platform:foo", "platform:foo",
"platform:bar", "platform:bar",
}) })
checkSrcJarInputs(t, result, "platform-bootclasspath", []string{
fooSourceSrc,
barSrc,
})
}) })
t.Run("source+prebuilt - prebuilt preferred", func(t *testing.T) { t.Run("source+prebuilt - prebuilt preferred", func(t *testing.T) {
@ -129,6 +150,10 @@ func TestPlatformBootclasspath(t *testing.T) {
"platform:prebuilt_foo", "platform:prebuilt_foo",
"platform:bar", "platform:bar",
}) })
checkSrcJarInputs(t, result, "platform-bootclasspath", []string{
// TODO(b/151360309): This should also have the srcs for prebuilt_foo
barSrc,
})
}) })
t.Run("dex import", func(t *testing.T) { t.Run("dex import", func(t *testing.T) {
@ -146,6 +171,10 @@ func TestPlatformBootclasspath(t *testing.T) {
"platform:prebuilt_foo", "platform:prebuilt_foo",
"platform:bar", "platform:bar",
}) })
checkSrcJarInputs(t, result, "platform-bootclasspath", []string{
// TODO(b/151360309): This should also have the srcs for prebuilt_foo
barSrc,
})
}) })
} }