Refactor handling of hidden API property provided information

In preparation for adding hidden API properties to individual
java_sdk_library modules this change refactors the handling of that
information.

1. Renames HiddenApiPackageProperties to HiddenAPIPackageProperties
   to be consistent with other similar structs.

2. Creates a new HiddenAPIPropertyInfo struct to be used to provide
   property derived information from one module to another. It includes
   both flag files as well as the information about which packages are
   used.

3. The HiddenAPIPropertyInfo is embedded within the existing
   HiddenAPIFlagInput in place of the existing flag files field.

4. The fields in the HiddenAPIPropertyInfo struct are populated from
   the HiddenAPI*Properties structs.

5. Access to package information is retrieved from the info struct
   instead of directly from the properties. That means that no changes
   will be needed to this code when info from other modules is merged
   into the struct in a follow up change.

Bug: 240406019
Test: packages/modules/common/build/mainline_modules_sdks.sh
      # Ran the previous command with and without this change to make
      # sure that this change does not change the sdk snapshot
      # contents.
Change-Id: I773279a4b621bcc3c40e3bfe193f2c7b0caeccd6
(cherry picked from commit 1e9e9388d8)
Merged-In: I773279a4b621bcc3c40e3bfe193f2c7b0caeccd6
This commit is contained in:
Paul Duffin
2022-07-27 15:55:06 +00:00
committed by Cherrypicker Worker
parent 719cc628ce
commit 710a9edf21
2 changed files with 52 additions and 21 deletions

View File

@@ -145,7 +145,7 @@ type bootclasspathFragmentProperties struct {
BootclasspathFragmentsDepsProperties
}
type HiddenApiPackageProperties struct {
type HiddenAPIPackageProperties struct {
Hidden_api struct {
// Contains prefixes of a package hierarchy that is provided solely by this
// bootclasspath_fragment.
@@ -222,8 +222,8 @@ type HiddenApiPackageProperties struct {
}
type SourceOnlyBootclasspathProperties struct {
HiddenApiPackageProperties
Coverage HiddenApiPackageProperties
HiddenAPIPackageProperties
Coverage HiddenAPIPackageProperties
}
type BootclasspathFragmentModule struct {
@@ -293,7 +293,7 @@ func bootclasspathFragmentFactory() android.Module {
return
}
err = proptools.AppendProperties(&m.sourceOnlyProperties.HiddenApiPackageProperties, &m.sourceOnlyProperties.Coverage, nil)
err = proptools.AppendProperties(&m.sourceOnlyProperties.HiddenAPIPackageProperties, &m.sourceOnlyProperties.Coverage, nil)
if err != nil {
ctx.PropertyErrorf("coverage", "error trying to append hidden api coverage specific properties: %s", err)
return
@@ -827,6 +827,9 @@ func (b *BootclasspathFragmentModule) createHiddenAPIFlagInput(ctx android.Modul
// Populate with flag file paths from the properties.
input.extractFlagFilesFromProperties(ctx, &b.properties.Hidden_api)
// Populate with package rules from the properties.
input.extractPackageRulesFromProperties(&b.sourceOnlyProperties.HiddenAPIPackageProperties)
// Add the stub dex jars from this module's fragment dependencies.
input.DependencyStubDexJarsByScope.addStubDexJarsByModule(dependencyHiddenApiInfo.TransitiveStubDexJarsByScope)
@@ -862,9 +865,9 @@ func (b *BootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleC
// If the module specifies split_packages or package_prefixes then use those to generate the
// signature patterns.
splitPackages := b.sourceOnlyProperties.Hidden_api.Split_packages
packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes
singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages
splitPackages := input.SplitPackages
packagePrefixes := input.PackagePrefixes
singlePackages := input.SinglePackages
if splitPackages != nil || packagePrefixes != nil || singlePackages != nil {
output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages)