diff options
author | Paul Duffin <paulduffin@google.com> | 2021-07-01 15:47:24 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-07-01 15:47:24 +0000 |
commit | fb5229b3bcf3c8830c1dd287dce9053c5d335905 (patch) | |
tree | e8cf02c6a654ced1a0e505886c8eaa50b467e6f7 /java | |
parent | f4a65fee9823c0994fcda3d04934722eb6819f1c (diff) | |
parent | 71e98fa3034ce6993c618a85540824ea2ad9d6a9 (diff) |
Merge "Revert "Make bootclasspath_fragments always perform hidden API processing"" into sc-dev
Diffstat (limited to 'java')
-rw-r--r-- | java/bootclasspath_fragment.go | 22 | ||||
-rw-r--r-- | java/hiddenapi_modular.go | 37 |
2 files changed, 56 insertions, 3 deletions
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 769e901a7..73dcd1951 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -576,9 +576,25 @@ func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android. // Create hidden API input structure. input := b.createHiddenAPIFlagInput(ctx, contents, fragments) - // Delegate the production of the hidden API all-flags.csv file to a module type specific method. - common := ctx.Module().(commonBootclasspathFragment) - output := common.produceHiddenAPIOutput(ctx, contents, input) + var output *HiddenAPIOutput + + // Hidden API processing is conditional as a temporary workaround as not all + // bootclasspath_fragments provide the appropriate information needed for hidden API processing + // which leads to breakages of the build. + // TODO(b/179354495): Stop hidden API processing being conditional once all bootclasspath_fragment + // modules have been updated to support it. + if input.canPerformHiddenAPIProcessing(ctx, b.properties) { + // Delegate the production of the hidden API all-flags.csv file to a module type specific method. + common := ctx.Module().(commonBootclasspathFragment) + output = common.produceHiddenAPIOutput(ctx, contents, input) + } else { + // As hidden API processing cannot be performed fall back to trying to retrieve the legacy + // encoded boot dex files, i.e. those files encoded by the individual libraries and returned + // from the DexJarBuildPath() method. + output = &HiddenAPIOutput{ + EncodedBootDexFilesByModule: retrieveLegacyEncodedBootDexFiles(ctx, contents), + } + } // Initialize a HiddenAPIInfo structure. hiddenAPIInfo := HiddenAPIInfo{ diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index e15d9952d..0895951ab 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -20,6 +20,7 @@ import ( "android/soong/android" "github.com/google/blueprint" + "github.com/google/blueprint/proptools" ) // Contains support for processing hiddenAPI in a modular fashion. @@ -696,6 +697,42 @@ func newHiddenAPIFlagInput() HiddenAPIFlagInput { return input } +// canPerformHiddenAPIProcessing determines whether hidden API processing should be performed. +// +// A temporary workaround to avoid existing bootclasspath_fragments that do not provide the +// appropriate information needed for hidden API processing breaking the build. +// TODO(b/179354495): Remove this workaround. +func (i *HiddenAPIFlagInput) canPerformHiddenAPIProcessing(ctx android.ModuleContext, properties bootclasspathFragmentProperties) bool { + // Performing hidden API processing without stubs is not supported and it is unlikely to ever be + // required as the whole point of adding something to the bootclasspath fragment is to add it to + // the bootclasspath in order to be used by something else in the system. Without any stubs it + // cannot do that. + if len(i.StubDexJarsByScope) == 0 { + return false + } + + // Hidden API processing is always enabled in tests. + if ctx.Config().TestProductVariables != nil { + return true + } + + // A module that has fragments should have access to the information it needs in order to perform + // hidden API processing. + if len(properties.Fragments) != 0 { + return true + } + + // The art bootclasspath fragment does not depend on any other fragments but already supports + // hidden API processing. + imageName := proptools.String(properties.Image_name) + if imageName == "art" { + return true + } + + // Disable it for everything else. + return false +} + // gatherStubLibInfo gathers information from the stub libs needed by hidden API processing from the // dependencies added in hiddenAPIAddStubLibDependencies. // |