From 91b4e3e78b51b0f177d07255f85d9abaea905d1d Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Wed, 23 Jan 2019 21:04:05 +0000 Subject: [PATCH] Disable all-assigned check in hiddenapi on master-art Master-art configurations do not have frameworks/base and therefore do not have hidden API flags. Pass --no-force-assign-all to `hiddenapi` when frameworks/base does not exist to disable the corresponding assertion. This enables us to enforce the assertion on non-master-art builds and also get rid of logspam about missing flags on ART buildbots. Test: art/tools/buildbot-build.sh on master-art Bug: 123143676 Change-Id: I074d9554fb11dab3eef904016375730520107ec2 --- android/config.go | 4 ++++ apex/apex.go | 2 +- java/hiddenapi.go | 21 ++++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/android/config.go b/android/config.go index 956c4afa2..07d0a87c3 100644 --- a/android/config.go +++ b/android/config.go @@ -774,6 +774,10 @@ func (c *config) DexPreoptProfileDir() string { return String(c.productVariables.DexPreoptProfileDir) } +func (c *config) FrameworksBaseDirExists(ctx PathContext) bool { + return ExistentPathForSource(ctx, "frameworks", "base").Valid() +} + func (c *deviceConfig) Arches() []Arch { var arches []Arch for _, target := range c.config.Targets[Android] { diff --git a/apex/apex.go b/apex/apex.go index 160db1c71..0aedb1abc 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -118,7 +118,7 @@ func init() { // projects, and hence cannot built 'aapt2'. Use the SDK prebuilt instead. hostBinToolVariableWithPrebuilt := func(name, prebuiltDir, tool string) { pctx.VariableFunc(name, func(ctx android.PackageVarContext) string { - if !android.ExistentPathForSource(ctx, "frameworks/base").Valid() { + if !ctx.Config().FrameworksBaseDirExists(ctx) { return filepath.Join(prebuiltDir, runtime.GOOS, "bin", tool) } else { return pctx.HostBinToolPath(ctx, tool).String() diff --git a/java/hiddenapi.go b/java/hiddenapi.go index a06a666f2..67df57552 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -67,7 +67,7 @@ var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", bluepr `for INPUT_DEX in $$(find $tmpDir/dex-input -maxdepth 1 -name 'classes*.dex' | sort); do ` + ` echo "--input-dex=$${INPUT_DEX}"; ` + ` echo "--output-dex=$tmpDir/dex-output/$$(basename $${INPUT_DEX})"; ` + - `done | xargs ${config.HiddenAPI} encode --api-flags=$flags && ` + + `done | xargs ${config.HiddenAPI} encode --api-flags=$flagsCsv $hiddenapiFlags && ` + `${config.SoongZipCmd} $soongZipFlags -o $tmpDir/dex.jar -C $tmpDir/dex-output -f "$tmpDir/dex-output/classes*.dex" && ` + `${config.MergeZipsCmd} -D -zipToNotStrip $tmpDir/dex.jar -stripFile "classes*.dex" $out $tmpDir/dex.jar $in`, CommandDeps: []string{ @@ -75,16 +75,17 @@ var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", bluepr "${config.SoongZipCmd}", "${config.MergeZipsCmd}", }, -}, "flags", "tmpDir", "soongZipFlags") +}, "flagsCsv", "hiddenapiFlags", "tmpDir", "soongZipFlags") func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath, dexInput android.WritablePath, uncompressDex bool) { - flags := &bootImagePath{ctx.Config().HiddenAPIFlags()} + flagsCsv := &bootImagePath{ctx.Config().HiddenAPIFlags()} // The encode dex rule requires unzipping and rezipping the classes.dex files, ensure that if it was uncompressed // in the input it stays uncompressed in the output. soongZipFlags := "" + hiddenapiFlags := "" tmpOutput := output tmpDir := android.PathForModuleOut(ctx, "hiddenapi", "dex") if uncompressDex { @@ -92,17 +93,23 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath, tmpOutput = android.PathForModuleOut(ctx, "hiddenapi", "unaligned", "unaligned.jar") tmpDir = android.PathForModuleOut(ctx, "hiddenapi", "unaligned") } + // If frameworks/base doesn't exist we must be building with the 'master-art' manifest. + // Disable assertion that all methods/fields have hidden API flags assigned. + if !ctx.Config().FrameworksBaseDirExists(ctx) { + hiddenapiFlags = "--no-force-assign-all" + } ctx.Build(pctx, android.BuildParams{ Rule: hiddenAPIEncodeDexRule, Description: "hiddenapi encode dex", Input: dexInput, Output: tmpOutput, - Implicit: flags, + Implicit: flagsCsv, Args: map[string]string{ - "flags": flags.String(), - "tmpDir": tmpDir.String(), - "soongZipFlags": soongZipFlags, + "flagsCsv": flagsCsv.String(), + "tmpDir": tmpDir.String(), + "soongZipFlags": soongZipFlags, + "hiddenapiFlags": hiddenapiFlags, }, })