Support hidden API processing for fragments with dependencies
Previously, a bootclasspath_fragment that depended on classes provided by another bootclasspath_fragment did not support hidden API processing as it would not supply information about those dependencies. This change adds support for that as follows. Each fragment: 1. Exports the transitive sets of stub dex jars for each of the public, system, test and core_platform APIs (where relevant). 2. Adds dependencies onto its dependent fragments. 3. Retrieves the API stubs dex jars from its dependent fragments and passes them to the "hiddenapi list" tool which will use them to resolve dependencies but will not output them to the generated flags. Once the flags are generated the existing encoding functionality encodes the flags into the dex files of the bootclasspath_fragment's content modules which are then packaged into the apex. Bug: 179354495 Test: m com.android.sdkext - verify that this does not change the contents of the apex files Change-Id: I3e82a6dbb437f1e417e5d7e25aeb212e378603d0
This commit is contained in:
@@ -367,6 +367,11 @@ func (b *BootclasspathFragmentModule) DepsMutator(ctx android.BottomUpMutatorCon
|
||||
dexpreopt.RegisterToolDeps(ctx)
|
||||
}
|
||||
|
||||
func (b *BootclasspathFragmentModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
// Add dependencies on all the fragments.
|
||||
b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx)
|
||||
}
|
||||
|
||||
func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
// Only perform a consistency check if this module is the active module. That will prevent an
|
||||
// unused prebuilt that was created without instrumentation from breaking an instrumentation
|
||||
@@ -387,8 +392,10 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo
|
||||
}
|
||||
})
|
||||
|
||||
fragments := gatherApexModulePairDepsWithTag(ctx, bootclasspathFragmentDepTag)
|
||||
|
||||
// Perform hidden API processing.
|
||||
hiddenAPIFlagOutput := b.generateHiddenAPIBuildActions(ctx, contents)
|
||||
hiddenAPIFlagOutput := b.generateHiddenAPIBuildActions(ctx, contents, fragments)
|
||||
|
||||
// Verify that the image_name specified on a bootclasspath_fragment is valid even if this is a
|
||||
// prebuilt which will not use the image config.
|
||||
@@ -502,10 +509,10 @@ func (b *BootclasspathFragmentModule) getImageConfig(ctx android.EarlyModuleCont
|
||||
}
|
||||
|
||||
// generateHiddenAPIBuildActions generates all the hidden API related build rules.
|
||||
func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, contents []android.Module) *HiddenAPIFlagOutput {
|
||||
func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.ModuleContext, contents []android.Module, fragments []android.Module) *HiddenAPIFlagOutput {
|
||||
|
||||
// Create hidden API input structure.
|
||||
input := b.createHiddenAPIFlagInput(ctx, contents)
|
||||
input := b.createHiddenAPIFlagInput(ctx, contents, fragments)
|
||||
|
||||
var output *HiddenAPIFlagOutput
|
||||
|
||||
@@ -531,8 +538,10 @@ func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.
|
||||
// perform its own flag generation.
|
||||
FlagFilesByCategory: input.FlagFilesByCategory,
|
||||
|
||||
// Make these available for tests.
|
||||
StubDexJarsByKind: input.StubDexJarsByKind,
|
||||
// Other bootclasspath_fragments that depend on this need the transitive set of stub dex jars
|
||||
// from this to resolve any references from their code to classes provided by this fragment
|
||||
// and the fragments this depends upon.
|
||||
TransitiveStubDexJarsByKind: input.transitiveStubDexJarsByKind(),
|
||||
}
|
||||
|
||||
if output != nil {
|
||||
@@ -549,7 +558,13 @@ func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android.
|
||||
|
||||
// createHiddenAPIFlagInput creates a HiddenAPIFlagInput struct and initializes it with information derived
|
||||
// from the properties on this module and its dependencies.
|
||||
func (b *BootclasspathFragmentModule) createHiddenAPIFlagInput(ctx android.ModuleContext, contents []android.Module) HiddenAPIFlagInput {
|
||||
func (b *BootclasspathFragmentModule) createHiddenAPIFlagInput(ctx android.ModuleContext, contents []android.Module, fragments []android.Module) HiddenAPIFlagInput {
|
||||
|
||||
// Merge the HiddenAPIInfo from all the fragment dependencies.
|
||||
dependencyHiddenApiInfo := newHiddenAPIInfo()
|
||||
dependencyHiddenApiInfo.mergeFromFragmentDeps(ctx, fragments)
|
||||
|
||||
// Create hidden API flag input structure.
|
||||
input := newHiddenAPIFlagInput()
|
||||
|
||||
// Update the input structure with information obtained from the stub libraries.
|
||||
@@ -558,6 +573,9 @@ func (b *BootclasspathFragmentModule) createHiddenAPIFlagInput(ctx android.Modul
|
||||
// Populate with flag file paths from the properties.
|
||||
input.extractFlagFilesFromProperties(ctx, &b.properties.Hidden_api)
|
||||
|
||||
// Store the stub dex jars from this module's fragment dependencies.
|
||||
input.DependencyStubDexJarsByKind = dependencyHiddenApiInfo.TransitiveStubDexJarsByKind
|
||||
|
||||
return input
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user