From 716828ab4ec2a673e6022171bb2b52584ee8e916 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 15 Jul 2019 15:29:23 +0900 Subject: [PATCH 1/2] Revert "Don't build hiddenapi flags or encode dex for unbundled builds" This reverts commit 7b8a567f44b3fdb30eac8211e8ed8e27fb162797. Bug: 137282010 Test: With the CL above this one, the unbundled mainline module build does not fail. Merged-In: I2f49fa7dbe1da92cb282a9bc14acd5830888ed17 Change-Id: I2f49fa7dbe1da92cb282a9bc14acd5830888ed17 --- java/hiddenapi_singleton.go | 2 +- java/java.go | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go index b1ddab48d..9627dc64b 100644 --- a/java/hiddenapi_singleton.go +++ b/java/hiddenapi_singleton.go @@ -61,7 +61,7 @@ func (h *hiddenAPISingleton) GenerateBuildActions(ctx android.SingletonContext) stubFlagsRule(ctx) // These rules depend on files located in frameworks/base, skip them if running in a tree that doesn't have them. - if ctx.Config().FrameworksBaseDirExists(ctx) && !ctx.Config().UnbundledBuild() { + if ctx.Config().FrameworksBaseDirExists(ctx) { h.flags = flagsRule(ctx) h.metadata = metadataRule(ctx) } else { diff --git a/java/java.go b/java/java.go index ff6bbacc5..bf738c4d3 100644 --- a/java/java.go +++ b/java/java.go @@ -1270,11 +1270,9 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path return } - if !ctx.Config().UnbundledBuild() { - // Hidden API CSV generation and dex encoding - dexOutputFile = j.hiddenAPI.hiddenAPI(ctx, dexOutputFile, j.implementationJarFile, - j.deviceProperties.UncompressDex) - } + // Hidden API CSV generation and dex encoding + dexOutputFile = j.hiddenAPI.hiddenAPI(ctx, dexOutputFile, j.implementationJarFile, + j.deviceProperties.UncompressDex) // merge dex jar with resources if necessary if j.resourceJar != nil { From 53554e25593d6498a229d1dc89208aade4137008 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 15 Jul 2019 15:31:16 +0900 Subject: [PATCH 2/2] 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 Merged-In: I2c00af07aac4a15770d3acab011a36e2e4803bfc Change-Id: I2c00af07aac4a15770d3acab011a36e2e4803bfc --- apex/apex.go | 11 +++++++---- java/hiddenapi_singleton.go | 2 +- java/sdk_library.go | 11 ++++++++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 04b667f85..e5e586010 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1327,10 +1327,13 @@ func (p *Prebuilt) installable() bool { } func (p *Prebuilt) DepsMutator(ctx android.BottomUpMutatorContext) { - // If the device is configured to use flattened APEX, don't set - // p.properties.Source so that the prebuilt module (which is - // a non-flattened APEX) is not used. - forceDisable := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild() + // If the device is configured to use flattened APEX, force disable the prebuilt because + // the prebuilt is a non-flattened one. + forceDisable := ctx.Config().FlattenApex() + + // Force disable the prebuilts when we are doing unbundled build. We do unbundled build + // to build the prebuilts themselves. + forceDisable = forceDisable || !ctx.Config().UnbundledBuild() // b/137216042 don't use prebuilts when address sanitizer is on forceDisable = forceDisable || android.InList("address", ctx.Config().SanitizeDevice()) || diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go index 9627dc64b..09936ea78 100644 --- a/java/hiddenapi_singleton.go +++ b/java/hiddenapi_singleton.go @@ -94,7 +94,7 @@ func stubFlagsRule(ctx android.SingletonContext) { // Add the android.test.base to the set of stubs only if the android.test.base module is on // the boot jars list as the runtime will only enforce hiddenapi access against modules on // that list. - if inList("android.test.base", ctx.Config().BootJars()) { + if inList("android.test.base", ctx.Config().BootJars()) && !ctx.Config().UnbundledBuildUsePrebuiltSdks() { publicStubModules = append(publicStubModules, "android.test.base.stubs") } diff --git a/java/sdk_library.go b/java/sdk_library.go index 974131cf9..84be4dda9 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -162,15 +162,20 @@ var _ Dependency = (*SdkLibrary)(nil) 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)) if !Bool(module.properties.No_standard_libs) { - 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)