Merge "Put shared library R.jar files in the classpath" into main am: 149f6f6f78 am: a43251d771 am: e88d5b1796 am: 0abb9e863b

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

Change-Id: I127c579d908b08cf5e868c8a8659061208a90bf1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Colin Cross 2023-10-13 20:20:25 +00:00 committed by Automerger Merge Worker
commit f4578a4787
2 changed files with 159 additions and 25 deletions

View file

@ -311,7 +311,7 @@ type aaptBuildActionOptions struct {
func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptions) { func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptions) {
staticResourcesNodesDepSet, staticRRODirsDepSet, staticManifestsDepSet, sharedDeps, libFlags := staticResourcesNodesDepSet, sharedResourcesNodesDepSet, staticRRODirsDepSet, staticManifestsDepSet, sharedExportPackages, libFlags :=
aaptLibs(ctx, opts.sdkContext, opts.classLoaderContexts) aaptLibs(ctx, opts.sdkContext, opts.classLoaderContexts)
// Exclude any libraries from the supplied list. // Exclude any libraries from the supplied list.
@ -335,6 +335,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio
}) })
staticDeps := transitiveAarDeps(staticResourcesNodesDepSet.ToList()) staticDeps := transitiveAarDeps(staticResourcesNodesDepSet.ToList())
sharedDeps := transitiveAarDeps(sharedResourcesNodesDepSet.ToList())
// Add additional manifest files to transitive manifests. // Add additional manifest files to transitive manifests.
additionalManifests := android.PathsForModuleSrc(ctx, a.aaptProperties.Additional_manifests) additionalManifests := android.PathsForModuleSrc(ctx, a.aaptProperties.Additional_manifests)
@ -364,7 +365,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio
compileFlags, linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resZips := a.aapt2Flags(ctx, opts.sdkContext, manifestPath) compileFlags, linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resZips := a.aapt2Flags(ctx, opts.sdkContext, manifestPath)
linkFlags = append(linkFlags, libFlags...) linkFlags = append(linkFlags, libFlags...)
linkDeps = append(linkDeps, sharedDeps...) linkDeps = append(linkDeps, sharedExportPackages...)
linkDeps = append(linkDeps, staticDeps.resPackages()...) linkDeps = append(linkDeps, staticDeps.resPackages()...)
linkFlags = append(linkFlags, opts.extraLinkFlags...) linkFlags = append(linkFlags, opts.extraLinkFlags...)
if a.isLibrary { if a.isLibrary {
@ -422,6 +423,11 @@ func (a *aapt) buildActions(ctx android.ModuleContext, opts aaptBuildActionOptio
transitiveRJars = append(transitiveRJars, staticDep.rJar) transitiveRJars = append(transitiveRJars, staticDep.rJar)
} }
} }
for _, sharedDep := range sharedDeps {
if sharedDep.usedResourceProcessor {
transitiveRJars = append(transitiveRJars, sharedDep.rJar)
}
}
} else { } else {
// When building an app or building a library without ResourceProcessorBusyBox enabled all static // When building an app or building a library without ResourceProcessorBusyBox enabled all static
// dependencies are compiled into this module's package-res.apk as overlays. // dependencies are compiled into this module's package-res.apk as overlays.
@ -630,7 +636,7 @@ func (t transitiveAarDeps) assets() android.Paths {
// aaptLibs collects libraries from dependencies and sdk_version and converts them into paths // aaptLibs collects libraries from dependencies and sdk_version and converts them into paths
func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoaderContexts dexpreopt.ClassLoaderContextMap) ( func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoaderContexts dexpreopt.ClassLoaderContextMap) (
staticResourcesNodes *android.DepSet[*resourcesNode], staticRRODirs *android.DepSet[rroDir], staticResourcesNodes, sharedResourcesNodes *android.DepSet[*resourcesNode], staticRRODirs *android.DepSet[rroDir],
staticManifests *android.DepSet[android.Path], sharedLibs android.Paths, flags []string) { staticManifests *android.DepSet[android.Path], sharedLibs android.Paths, flags []string) {
if classLoaderContexts == nil { if classLoaderContexts == nil {
@ -644,7 +650,8 @@ func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoa
sharedLibs = append(sharedLibs, sdkDep.jars...) sharedLibs = append(sharedLibs, sdkDep.jars...)
} }
var resourcesNodeDepSets []*android.DepSet[*resourcesNode] var staticResourcesNodeDepSets []*android.DepSet[*resourcesNode]
var sharedResourcesNodeDepSets []*android.DepSet[*resourcesNode]
rroDirsDepSetBuilder := android.NewDepSetBuilder[rroDir](android.TOPOLOGICAL) rroDirsDepSetBuilder := android.NewDepSetBuilder[rroDir](android.TOPOLOGICAL)
manifestsDepSetBuilder := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL) manifestsDepSetBuilder := android.NewDepSetBuilder[android.Path](android.TOPOLOGICAL)
@ -662,6 +669,7 @@ func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoa
// Nothing, instrumentationForTag is treated as libTag for javac but not for aapt2. // Nothing, instrumentationForTag is treated as libTag for javac but not for aapt2.
case sdkLibTag, libTag: case sdkLibTag, libTag:
if exportPackage != nil { if exportPackage != nil {
sharedResourcesNodeDepSets = append(sharedResourcesNodeDepSets, aarDep.ResourcesNodeDepSet())
sharedLibs = append(sharedLibs, exportPackage) sharedLibs = append(sharedLibs, exportPackage)
} }
case frameworkResTag: case frameworkResTag:
@ -670,7 +678,7 @@ func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoa
} }
case staticLibTag: case staticLibTag:
if exportPackage != nil { if exportPackage != nil {
resourcesNodeDepSets = append(resourcesNodeDepSets, aarDep.ResourcesNodeDepSet()) staticResourcesNodeDepSets = append(staticResourcesNodeDepSets, aarDep.ResourcesNodeDepSet())
rroDirsDepSetBuilder.Transitive(aarDep.RRODirsDepSet()) rroDirsDepSetBuilder.Transitive(aarDep.RRODirsDepSet())
manifestsDepSetBuilder.Transitive(aarDep.ManifestsDepSet()) manifestsDepSetBuilder.Transitive(aarDep.ManifestsDepSet())
} }
@ -686,7 +694,9 @@ func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoa
// dependencies) the highest priority dependency is listed first, but for resources the highest priority // dependencies) the highest priority dependency is listed first, but for resources the highest priority
// dependency has to be listed last. // dependency has to be listed last.
staticResourcesNodes = android.NewDepSet(android.TOPOLOGICAL, nil, staticResourcesNodes = android.NewDepSet(android.TOPOLOGICAL, nil,
android.ReverseSliceInPlace(resourcesNodeDepSets)) android.ReverseSliceInPlace(staticResourcesNodeDepSets))
sharedResourcesNodes = android.NewDepSet(android.TOPOLOGICAL, nil,
android.ReverseSliceInPlace(sharedResourcesNodeDepSets))
staticRRODirs = rroDirsDepSetBuilder.Build() staticRRODirs = rroDirsDepSetBuilder.Build()
staticManifests = manifestsDepSetBuilder.Build() staticManifests = manifestsDepSetBuilder.Build()
@ -699,7 +709,7 @@ func aaptLibs(ctx android.ModuleContext, sdkContext android.SdkContext, classLoa
flags = append(flags, "-I "+sharedLib.String()) flags = append(flags, "-I "+sharedLib.String())
} }
return staticResourcesNodes, staticRRODirs, staticManifests, sharedLibs, flags return staticResourcesNodes, sharedResourcesNodes, staticRRODirs, staticManifests, sharedLibs, flags
} }
type AndroidLibrary struct { type AndroidLibrary struct {
@ -1095,10 +1105,12 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
linkFlags = append(linkFlags, "--manifest "+a.manifest.String()) linkFlags = append(linkFlags, "--manifest "+a.manifest.String())
linkDeps = append(linkDeps, a.manifest) linkDeps = append(linkDeps, a.manifest)
staticResourcesNodesDepSet, staticRRODirsDepSet, staticManifestsDepSet, sharedLibs, libFlags := staticResourcesNodesDepSet, sharedResourcesNodesDepSet, staticRRODirsDepSet, staticManifestsDepSet, sharedLibs, libFlags :=
aaptLibs(ctx, android.SdkContext(a), nil) aaptLibs(ctx, android.SdkContext(a), nil)
_ = sharedResourcesNodesDepSet
_ = staticRRODirsDepSet _ = staticRRODirsDepSet
staticDeps := transitiveAarDeps(staticResourcesNodesDepSet.ToList()) staticDeps := transitiveAarDeps(staticResourcesNodesDepSet.ToList())
linkDeps = append(linkDeps, sharedLibs...) linkDeps = append(linkDeps, sharedLibs...)

View file

@ -726,6 +726,9 @@ func TestAndroidResourceProcessor(t *testing.T) {
appUsesRP bool appUsesRP bool
directLibUsesRP bool directLibUsesRP bool
transitiveLibUsesRP bool transitiveLibUsesRP bool
sharedLibUsesRP bool
sharedTransitiveStaticLibUsesRP bool
sharedTransitiveSharedLibUsesRP bool
dontVerifyApp bool dontVerifyApp bool
appResources []string appResources []string
@ -760,6 +763,14 @@ func TestAndroidResourceProcessor(t *testing.T) {
transitiveImportResources []string transitiveImportResources []string
transitiveImportOverlays []string transitiveImportOverlays []string
transitiveImportImports []string transitiveImportImports []string
dontVerifyShared bool
sharedResources []string
sharedOverlays []string
sharedImports []string
sharedSrcJars []string
sharedClasspath []string
sharedCombined []string
}{ }{
{ {
// Test with all modules set to use_resource_processor: false (except android_library_import modules, // Test with all modules set to use_resource_processor: false (except android_library_import modules,
@ -779,10 +790,14 @@ func TestAndroidResourceProcessor(t *testing.T) {
"out/soong/.intermediates/direct_import/android_common/package-res.apk", "out/soong/.intermediates/direct_import/android_common/package-res.apk",
"out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat", "out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat",
}, },
appImports: []string{"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk"}, appImports: []string{
"out/soong/.intermediates/shared/android_common/package-res.apk",
"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk",
},
appSrcJars: []string{"out/soong/.intermediates/app/android_common/gen/android/R.srcjar"}, appSrcJars: []string{"out/soong/.intermediates/app/android_common/gen/android/R.srcjar"},
appClasspath: []string{ appClasspath: []string{
"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar", "out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar",
"out/soong/.intermediates/shared/android_common/turbine-combined/shared.jar",
"out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar", "out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar",
"out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar",
}, },
@ -819,6 +834,26 @@ func TestAndroidResourceProcessor(t *testing.T) {
transitiveClasspath: []string{"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar"}, transitiveClasspath: []string{"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar"},
transitiveCombined: nil, transitiveCombined: nil,
sharedResources: nil,
sharedOverlays: []string{
"out/soong/.intermediates/shared_transitive_static/android_common/package-res.apk",
"out/soong/.intermediates/shared/android_common/aapt2/shared/res/values_strings.arsc.flat",
},
sharedImports: []string{
"out/soong/.intermediates/shared_transitive_shared/android_common/package-res.apk",
"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk",
},
sharedSrcJars: []string{"out/soong/.intermediates/shared/android_common/gen/android/R.srcjar"},
sharedClasspath: []string{
"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar",
"out/soong/.intermediates/shared_transitive_shared/android_common/turbine-combined/shared_transitive_shared.jar",
"out/soong/.intermediates/shared_transitive_static/android_common/turbine-combined/shared_transitive_static.jar",
},
sharedCombined: []string{
"out/soong/.intermediates/shared/android_common/javac/shared.jar",
"out/soong/.intermediates/shared_transitive_static/android_common/javac/shared_transitive_static.jar",
},
directImportResources: nil, directImportResources: nil,
directImportOverlays: []string{"out/soong/.intermediates/direct_import/android_common/flat-res/gen_res.flata"}, directImportOverlays: []string{"out/soong/.intermediates/direct_import/android_common/flat-res/gen_res.flata"},
directImportImports: []string{ directImportImports: []string{
@ -839,6 +874,9 @@ func TestAndroidResourceProcessor(t *testing.T) {
appUsesRP: true, appUsesRP: true,
directLibUsesRP: true, directLibUsesRP: true,
transitiveLibUsesRP: true, transitiveLibUsesRP: true,
sharedLibUsesRP: true,
sharedTransitiveSharedLibUsesRP: true,
sharedTransitiveStaticLibUsesRP: true,
appResources: nil, appResources: nil,
appOverlays: []string{ appOverlays: []string{
@ -850,11 +888,15 @@ func TestAndroidResourceProcessor(t *testing.T) {
"out/soong/.intermediates/direct_import/android_common/package-res.apk", "out/soong/.intermediates/direct_import/android_common/package-res.apk",
"out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat", "out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat",
}, },
appImports: []string{"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk"}, appImports: []string{
"out/soong/.intermediates/shared/android_common/package-res.apk",
"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk",
},
appSrcJars: nil, appSrcJars: nil,
appClasspath: []string{ appClasspath: []string{
"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar", "out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar",
"out/soong/.intermediates/app/android_common/busybox/R.jar", "out/soong/.intermediates/app/android_common/busybox/R.jar",
"out/soong/.intermediates/shared/android_common/turbine-combined/shared.jar",
"out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar", "out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar",
"out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar",
}, },
@ -899,6 +941,27 @@ func TestAndroidResourceProcessor(t *testing.T) {
}, },
transitiveCombined: nil, transitiveCombined: nil,
sharedResources: nil,
sharedOverlays: []string{"out/soong/.intermediates/shared/android_common/aapt2/shared/res/values_strings.arsc.flat"},
sharedImports: []string{
"out/soong/.intermediates/shared_transitive_shared/android_common/package-res.apk",
"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk",
"out/soong/.intermediates/shared_transitive_static/android_common/package-res.apk",
},
sharedSrcJars: nil,
sharedClasspath: []string{
"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar",
"out/soong/.intermediates/shared_transitive_static/android_common/busybox/R.jar",
"out/soong/.intermediates/shared_transitive_shared/android_common/busybox/R.jar",
"out/soong/.intermediates/shared/android_common/busybox/R.jar",
"out/soong/.intermediates/shared_transitive_shared/android_common/turbine-combined/shared_transitive_shared.jar",
"out/soong/.intermediates/shared_transitive_static/android_common/turbine-combined/shared_transitive_static.jar",
},
sharedCombined: []string{
"out/soong/.intermediates/shared/android_common/javac/shared.jar",
"out/soong/.intermediates/shared_transitive_static/android_common/javac/shared_transitive_static.jar",
},
directImportResources: nil, directImportResources: nil,
directImportOverlays: []string{"out/soong/.intermediates/direct_import/android_common/flat-res/gen_res.flata"}, directImportOverlays: []string{"out/soong/.intermediates/direct_import/android_common/flat-res/gen_res.flata"},
directImportImports: []string{ directImportImports: []string{
@ -930,12 +993,16 @@ func TestAndroidResourceProcessor(t *testing.T) {
"out/soong/.intermediates/direct_import/android_common/package-res.apk", "out/soong/.intermediates/direct_import/android_common/package-res.apk",
"out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat", "out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat",
}, },
appImports: []string{"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk"}, appImports: []string{
"out/soong/.intermediates/shared/android_common/package-res.apk",
"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk",
},
appSrcJars: nil, appSrcJars: nil,
appClasspath: []string{ appClasspath: []string{
"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar", "out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar",
// R.jar has to come before direct.jar // R.jar has to come before direct.jar
"out/soong/.intermediates/app/android_common/busybox/R.jar", "out/soong/.intermediates/app/android_common/busybox/R.jar",
"out/soong/.intermediates/shared/android_common/turbine-combined/shared.jar",
"out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar", "out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar",
"out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar",
}, },
@ -948,6 +1015,7 @@ func TestAndroidResourceProcessor(t *testing.T) {
dontVerifyDirect: true, dontVerifyDirect: true,
dontVerifyTransitive: true, dontVerifyTransitive: true,
dontVerifyShared: true,
dontVerifyDirectImport: true, dontVerifyDirectImport: true,
dontVerifyTransitiveImport: true, dontVerifyTransitiveImport: true,
}, },
@ -968,10 +1036,14 @@ func TestAndroidResourceProcessor(t *testing.T) {
"out/soong/.intermediates/direct_import/android_common/package-res.apk", "out/soong/.intermediates/direct_import/android_common/package-res.apk",
"out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat", "out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat",
}, },
appImports: []string{"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk"}, appImports: []string{
"out/soong/.intermediates/shared/android_common/package-res.apk",
"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk",
},
appSrcJars: []string{"out/soong/.intermediates/app/android_common/gen/android/R.srcjar"}, appSrcJars: []string{"out/soong/.intermediates/app/android_common/gen/android/R.srcjar"},
appClasspath: []string{ appClasspath: []string{
"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar", "out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar",
"out/soong/.intermediates/shared/android_common/turbine-combined/shared.jar",
"out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar", "out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar",
"out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar",
}, },
@ -1005,6 +1077,7 @@ func TestAndroidResourceProcessor(t *testing.T) {
}, },
dontVerifyTransitive: true, dontVerifyTransitive: true,
dontVerifyShared: true,
dontVerifyDirectImport: true, dontVerifyDirectImport: true,
dontVerifyTransitiveImport: true, dontVerifyTransitiveImport: true,
}, },
@ -1025,10 +1098,14 @@ func TestAndroidResourceProcessor(t *testing.T) {
"out/soong/.intermediates/direct_import/android_common/package-res.apk", "out/soong/.intermediates/direct_import/android_common/package-res.apk",
"out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat", "out/soong/.intermediates/app/android_common/aapt2/app/res/values_strings.arsc.flat",
}, },
appImports: []string{"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk"}, appImports: []string{
"out/soong/.intermediates/shared/android_common/package-res.apk",
"out/soong/.intermediates/default/java/framework-res/android_common/package-res.apk",
},
appSrcJars: []string{"out/soong/.intermediates/app/android_common/gen/android/R.srcjar"}, appSrcJars: []string{"out/soong/.intermediates/app/android_common/gen/android/R.srcjar"},
appClasspath: []string{ appClasspath: []string{
"out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar", "out/soong/.intermediates/default/java/android_stubs_current/android_common/turbine-combined/android_stubs_current.jar",
"out/soong/.intermediates/shared/android_common/turbine-combined/shared.jar",
"out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar", "out/soong/.intermediates/direct/android_common/turbine-combined/direct.jar",
"out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar", "out/soong/.intermediates/direct_import/android_common/aar/classes-combined.jar",
}, },
@ -1068,6 +1145,7 @@ func TestAndroidResourceProcessor(t *testing.T) {
}, },
transitiveCombined: nil, transitiveCombined: nil,
dontVerifyShared: true,
dontVerifyDirectImport: true, dontVerifyDirectImport: true,
dontVerifyTransitiveImport: true, dontVerifyTransitiveImport: true,
}, },
@ -1082,6 +1160,7 @@ func TestAndroidResourceProcessor(t *testing.T) {
srcs: ["app/app.java"], srcs: ["app/app.java"],
resource_dirs: ["app/res"], resource_dirs: ["app/res"],
manifest: "app/AndroidManifest.xml", manifest: "app/AndroidManifest.xml",
libs: ["shared"],
static_libs: ["direct", "direct_import"], static_libs: ["direct", "direct_import"],
use_resource_processor: %v, use_resource_processor: %v,
} }
@ -1105,6 +1184,35 @@ func TestAndroidResourceProcessor(t *testing.T) {
use_resource_processor: %v, use_resource_processor: %v,
} }
android_library {
name: "shared",
sdk_version: "current",
srcs: ["shared/shared.java"],
resource_dirs: ["shared/res"],
manifest: "shared/AndroidManifest.xml",
use_resource_processor: %v,
libs: ["shared_transitive_shared"],
static_libs: ["shared_transitive_static"],
}
android_library {
name: "shared_transitive_shared",
sdk_version: "current",
srcs: ["shared_transitive_shared/shared_transitive_shared.java"],
resource_dirs: ["shared_transitive_shared/res"],
manifest: "shared_transitive_shared/AndroidManifest.xml",
use_resource_processor: %v,
}
android_library {
name: "shared_transitive_static",
sdk_version: "current",
srcs: ["shared_transitive_static/shared.java"],
resource_dirs: ["shared_transitive_static/res"],
manifest: "shared_transitive_static/AndroidManifest.xml",
use_resource_processor: %v,
}
android_library_import { android_library_import {
name: "direct_import", name: "direct_import",
sdk_version: "current", sdk_version: "current",
@ -1130,12 +1238,16 @@ func TestAndroidResourceProcessor(t *testing.T) {
sdk_version: "current", sdk_version: "current",
aars: ["transitive_import_dep.aar"], aars: ["transitive_import_dep.aar"],
} }
`, testCase.appUsesRP, testCase.directLibUsesRP, testCase.transitiveLibUsesRP) `, testCase.appUsesRP, testCase.directLibUsesRP, testCase.transitiveLibUsesRP,
testCase.sharedLibUsesRP, testCase.sharedTransitiveSharedLibUsesRP, testCase.sharedTransitiveStaticLibUsesRP)
fs := android.MockFS{ fs := android.MockFS{
"app/res/values/strings.xml": nil, "app/res/values/strings.xml": nil,
"direct/res/values/strings.xml": nil, "direct/res/values/strings.xml": nil,
"transitive/res/values/strings.xml": nil, "transitive/res/values/strings.xml": nil,
"shared/res/values/strings.xml": nil,
"shared_transitive_static/res/values/strings.xml": nil,
"shared_transitive_shared/res/values/strings.xml": nil,
} }
result := android.GroupFixturePreparers( result := android.GroupFixturePreparers(
@ -1182,6 +1294,7 @@ func TestAndroidResourceProcessor(t *testing.T) {
app := getAaptInfo("app") app := getAaptInfo("app")
direct := getAaptInfo("direct") direct := getAaptInfo("direct")
transitive := getAaptInfo("transitive") transitive := getAaptInfo("transitive")
shared := getAaptInfo("shared")
directImport := getAaptInfo("direct_import") directImport := getAaptInfo("direct_import")
transitiveImport := getAaptInfo("transitive_import") transitiveImport := getAaptInfo("transitive_import")
@ -1212,6 +1325,15 @@ func TestAndroidResourceProcessor(t *testing.T) {
android.AssertPathsRelativeToTopEquals(t, "transitive combined", testCase.transitiveCombined, transitive.combined) android.AssertPathsRelativeToTopEquals(t, "transitive combined", testCase.transitiveCombined, transitive.combined)
} }
if !testCase.dontVerifyShared {
android.AssertPathsRelativeToTopEquals(t, "shared resources", testCase.sharedResources, shared.resources)
android.AssertPathsRelativeToTopEquals(t, "shared overlays", testCase.sharedOverlays, shared.overlays)
android.AssertPathsRelativeToTopEquals(t, "shared imports", testCase.sharedImports, shared.imports)
android.AssertPathsRelativeToTopEquals(t, "shared srcjars", testCase.sharedSrcJars, shared.srcJars)
android.AssertPathsRelativeToTopEquals(t, "shared classpath", testCase.sharedClasspath, shared.classpath)
android.AssertPathsRelativeToTopEquals(t, "shared combined", testCase.sharedCombined, shared.combined)
}
if !testCase.dontVerifyDirectImport { if !testCase.dontVerifyDirectImport {
android.AssertPathsRelativeToTopEquals(t, "direct_import resources", testCase.directImportResources, directImport.resources) android.AssertPathsRelativeToTopEquals(t, "direct_import resources", testCase.directImportResources, directImport.resources)
android.AssertPathsRelativeToTopEquals(t, "direct_import overlays", testCase.directImportOverlays, directImport.overlays) android.AssertPathsRelativeToTopEquals(t, "direct_import overlays", testCase.directImportOverlays, directImport.overlays)