From 77590a82638fdd3d1d9e12cd57270e1a9cb2eaa7 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 28 Apr 2022 14:13:30 +0000 Subject: [PATCH] Allow framework-media to build the framework-media.impl The framework-media java_sdk_library is currently api_only for legacy reasons. This change allows it to also build the framework-media.impl library by making the following changes: * Adds impl_only_static_libs to allow the implementation to statically include other libraries, something no other java_sdk_library has needed to do. * Passes the apex_availability property through to the impl library so it can be statically included in the updatable-media which is what is included in the apex, again for legacy reasons. Bug: 190807367 Bug: 229932396 Test: m com.android.media media-module-sdk # Compare before and after this change (and corresponding change # to updatable-media/framework-media. Change-Id: I9e1837edcca6f5fa84fc611274cf8fbba8a896b8 --- java/sdk_library.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index c37ed1a27..fb032559e 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -377,6 +377,9 @@ type sdkLibraryProperties struct { // List of Java libraries that will be in the classpath when building the implementation lib Impl_only_libs []string `android:"arch_variant"` + // List of Java libraries that will included in the implementation lib. + Impl_only_static_libs []string `android:"arch_variant"` + // List of Java libraries that will be in the classpath when building stubs Stub_only_libs []string `android:"arch_variant"` @@ -1346,10 +1349,12 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) visibility := childModuleVisibility(module.sdkLibraryProperties.Impl_library_visibility) props := struct { - Name *string - Visibility []string - Instrument bool - Libs []string + Name *string + Visibility []string + Instrument bool + Libs []string + Static_libs []string + Apex_available []string }{ Name: proptools.StringPtr(module.implLibraryModuleName()), Visibility: visibility, @@ -1358,6 +1363,12 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) // Set the impl_only libs. Note that the module's "Libs" get appended as well, via the // addition of &module.properties below. Libs: module.sdkLibraryProperties.Impl_only_libs, + // Set the impl_only static libs. Note that the module's "static_libs" get appended as well, via the + // addition of &module.properties below. + Static_libs: module.sdkLibraryProperties.Impl_only_static_libs, + // Pass the apex_available settings down so that the impl library can be statically + // embedded within a library that is added to an APEX. Needed for updatable-media. + Apex_available: module.ApexAvailable(), } properties := []interface{}{ @@ -1814,8 +1825,9 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) } - // Add the impl_only_libs *after* we're done using the Libs prop in submodules. + // Add the impl_only_libs and impl_only_static_libs *after* we're done using them in submodules. module.properties.Libs = append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...) + module.properties.Static_libs = append(module.properties.Static_libs, module.sdkLibraryProperties.Impl_only_static_libs...) } func (module *SdkLibrary) InitSdkLibraryProperties() {