From 43db9bee5e9327d6a3d333c763e24f8f72c84c24 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Mon, 30 Dec 2019 17:35:49 +0000 Subject: [PATCH] java_sdk_library: Allow creation of impl shared library to be disabled Most modules will be providing their implementations via APEX and so do not need to create an implementation shared library as part of this. Adds an api_only property which will: * Prevent the creation of the implementation library. * Prevent the creation of the .xml file needed at runtime to make the shared library available. * Prevent the library being added to the list of java sdk libraries used by make to handle installation. Bug: 145998881 Test: m checkbuild Change-Id: Ida5e46a81aa5b0a041882d90d5f362ec79fdddb2 --- java/sdk_library.go | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index c68a3d1c3..057586f7e 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -110,6 +110,9 @@ type sdkLibraryProperties struct { // Defaults to "api". Api_dir *string + // If set to true there is no runtime library. + Api_only *bool + // local files that are used within user customized droiddoc options. Droiddoc_option_files []string @@ -183,7 +186,10 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { } func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { - module.Library.GenerateAndroidBuildActions(ctx) + // Don't build an implementation library if this is api only. + if !proptools.Bool(module.sdkLibraryProperties.Api_only) { + module.Library.GenerateAndroidBuildActions(ctx) + } module.buildPermissionsFile(ctx) @@ -247,6 +253,9 @@ func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) { } func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries { + if proptools.Bool(module.sdkLibraryProperties.Api_only) { + return nil + } entriesList := module.Library.AndroidMkEntries() entries := &entriesList[0] entries.Required = append(entries.Required, module.xmlFileName()) @@ -773,16 +782,18 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) { // for test API stubs module.createStubsLibrary(mctx, apiScopeTest) module.createStubsSources(mctx, apiScopeTest) - - // for runtime - module.createXmlFile(mctx) } - // record java_sdk_library modules so that they are exported to make - javaSdkLibraries := javaSdkLibraries(mctx.Config()) - javaSdkLibrariesLock.Lock() - defer javaSdkLibrariesLock.Unlock() - *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) + if !proptools.Bool(module.sdkLibraryProperties.Api_only) { + // for runtime + module.createXmlFile(mctx) + + // record java_sdk_library modules so that they are exported to make + javaSdkLibraries := javaSdkLibraries(mctx.Config()) + javaSdkLibrariesLock.Lock() + defer javaSdkLibrariesLock.Unlock() + *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) + } } func (module *SdkLibrary) InitSdkLibraryProperties() {