Fix the unbundled mainline module build
This change fixes two problems:
1) the prebuilt apexes are force disabled for the unbundled builds
because we need to build the modules from the source then
2) the dependencies from an sdk_library module to
*.stubs.{public|system|tests} are not added for the unbundled build
because the stubs modules are disabled.
Bug: 137282010
Test: unbundled mainline builds are successful
Test: build com.android.media and inspect the jar file to see if
hiddenapi flags are there
$ cd out/dist/mainline_modules_arm
$ unzip com.android.media.apex apex_payload.img
$ mkdir -p mnt
$ sudo mount -o ro,loop apex_payload.img mnt
$ dexdump2 mnt/javalib/updatable-media.jar | grep hiddenapi
shows results
Change-Id: I2c00af07aac4a15770d3acab011a36e2e4803bfc
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 1182b96..d38088d 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -149,16 +149,21 @@
var _ SdkLibraryDependency = (*SdkLibrary)(nil)
func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
+ useBuiltStubs := !ctx.Config().UnbundledBuildUsePrebuiltSdks()
// Add dependencies to the stubs library
- ctx.AddVariationDependencies(nil, publicApiStubsTag, module.stubsName(apiScopePublic))
+ if useBuiltStubs {
+ ctx.AddVariationDependencies(nil, publicApiStubsTag, module.stubsName(apiScopePublic))
+ }
ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic))
sdkDep := decodeSdkDep(ctx, sdkContext(&module.Library))
if sdkDep.hasStandardLibs() {
- ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
+ if useBuiltStubs {
+ ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
+ ctx.AddVariationDependencies(nil, testApiStubsTag, module.stubsName(apiScopeTest))
+ }
ctx.AddVariationDependencies(nil, systemApiFileTag, module.docsName(apiScopeSystem))
ctx.AddVariationDependencies(nil, testApiFileTag, module.docsName(apiScopeTest))
- ctx.AddVariationDependencies(nil, testApiStubsTag, module.stubsName(apiScopeTest))
}
module.Library.deps(ctx)