From 0b659866e872fa0e4c17ac8bbc48aa3fdf436c69 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 13 Apr 2021 13:02:29 +0100 Subject: Support UNSAFE_DISABLE_HIDDENAPI_FLAGS in platform_bootclasspath Previously attempting to use m UNSAFE_DISABLE_HIDDENAPI_FLAGS would cause a build failure. It is necessary when UNSAFE_DISABLE_HIDDENAPI_FLAGS=true to create empty files for the monolithic files so that those usages which are not protected by the build flag, e.g. in dists or CTS tests like CtsHiddenApiBlocklistTestApiTestCases do not cause ninja failures due to reliance on a file that does not exist and has no rule to create it. Bug: 177892522 Test: m nothing m UNSAFE_DISABLE_HIDDENAPI_FLAGS=true CtsHiddenApiBlocklistTestApiTestCases Change-Id: I05d0b3680dbc0b5b7c7c0d792550faf848829647 --- java/platform_bootclasspath.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'java/platform_bootclasspath.go') diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index fa13332dc..d98ce6719 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -73,13 +73,13 @@ type platformBootclasspathModule struct { fragments []android.Module // Path to the monolithic hiddenapi-flags.csv file. - hiddenAPIFlagsCSV android.Path + hiddenAPIFlagsCSV android.OutputPath // Path to the monolithic hiddenapi-index.csv file. - hiddenAPIIndexCSV android.Path + hiddenAPIIndexCSV android.OutputPath // Path to the monolithic hiddenapi-unsupported.csv file. - hiddenAPIMetadataCSV android.Path + hiddenAPIMetadataCSV android.OutputPath } // ApexVariantReference specifies a particular apex variant of a module. @@ -266,6 +266,20 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android. b.hiddenAPIIndexCSV = hiddenAPISingletonPaths(ctx).index b.hiddenAPIMetadataCSV = hiddenAPISingletonPaths(ctx).metadata + // Don't run any hiddenapi rules if UNSAFE_DISABLE_HIDDENAPI_FLAGS=true. This is a performance + // optimization that can be used to reduce the incremental build time but as its name suggests it + // can be unsafe to use, e.g. when the changes affect anything that goes on the bootclasspath. + if ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") { + paths := android.OutputPaths{b.hiddenAPIFlagsCSV, b.hiddenAPIIndexCSV, b.hiddenAPIMetadataCSV} + for _, path := range paths { + ctx.Build(pctx, android.BuildParams{ + Rule: android.Touch, + Output: path, + }) + } + return + } + moduleSpecificFlagsPaths := android.Paths{} for _, module := range modules { if h, ok := module.(hiddenAPIIntf); ok { -- cgit v1.2.3-59-g8ed1b