diff options
Diffstat (limited to 'java/app.go')
| -rwxr-xr-x | java/app.go | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/java/app.go b/java/app.go index 7ae73f797..e4432ff4b 100755 --- a/java/app.go +++ b/java/app.go @@ -425,7 +425,8 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) { a.aapt.splitNames = a.appProperties.Package_splits a.aapt.LoggingParent = String(a.overridableAppProperties.Logging_parent) - a.aapt.buildActions(ctx, android.SdkContext(a), a.classLoaderContexts, aaptLinkFlags...) + a.aapt.buildActions(ctx, android.SdkContext(a), a.classLoaderContexts, + a.usesLibraryProperties.Exclude_uses_libs, aaptLinkFlags...) // apps manifests are handled by aapt, don't let Module see them a.properties.Manifest = nil @@ -1211,6 +1212,23 @@ type UsesLibraryProperties struct { // libraries, because SDK ones are automatically picked up by Soong. The <uses-library> name // normally is the same as the module name, but there are exceptions. Provides_uses_lib *string + + // A list of shared library names to exclude from the classpath of the APK. Adding a library here + // will prevent it from being used when precompiling the APK and prevent it from being implicitly + // added to the APK's manifest's <uses-library> elements. + // + // Care must be taken when using this as it could result in runtime errors if the APK actually + // uses classes provided by the library and which are not provided in any other way. + // + // This is primarily intended for use by various CTS tests that check the runtime handling of the + // android.test.base shared library (and related libraries) but which depend on some common + // libraries that depend on the android.test.base library. Without this those tests will end up + // with a <uses-library android:name="android.test.base"/> in their manifest which would either + // render the tests worthless (as they would be testing the wrong behavior), or would break the + // test altogether by providing access to classes that the tests were not expecting. Those tests + // provide the android.test.base statically and use jarjar to rename them so they do not collide + // with the classes provided by the android.test.base library. + Exclude_uses_libs []string } // usesLibrary provides properties and helper functions for AndroidApp and AndroidAppImport to verify that the @@ -1432,17 +1450,15 @@ func androidAppCertificateBp2Build(ctx android.TopDownMutatorContext, module *An } type bazelAndroidAppAttributes struct { - Srcs bazel.LabelListAttribute + *javaLibraryAttributes Manifest bazel.Label Custom_package *string Resource_files bazel.LabelListAttribute - Deps bazel.LabelListAttribute } // ConvertWithBp2build is used to convert android_app to Bazel. func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { - //TODO(b/209577426): Support multiple arch variants - srcs := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, a.properties.Srcs, a.properties.Exclude_srcs)) + libAttrs := a.convertLibraryAttrsBp2Build(ctx) manifest := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml") @@ -1454,15 +1470,12 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { resourceFiles.Includes = append(resourceFiles.Includes, files...) } - deps := bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, a.properties.Static_libs)) - attrs := &bazelAndroidAppAttributes{ - Srcs: srcs, - Manifest: android.BazelLabelForModuleSrcSingle(ctx, manifest), + libAttrs, + android.BazelLabelForModuleSrcSingle(ctx, manifest), // TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES - Custom_package: a.overridableAppProperties.Package_name, - Resource_files: bazel.MakeLabelListAttribute(resourceFiles), - Deps: deps, + a.overridableAppProperties.Package_name, + bazel.MakeLabelListAttribute(resourceFiles), } props := bazel.BazelTargetModuleProperties{Rule_class: "android_binary", Bzl_load_location: "@rules_android//rules:rules.bzl"} |