diff options
author | 2021-08-03 15:42:27 +0100 | |
---|---|---|
committer | 2021-10-05 15:47:05 +0100 | |
commit | 1e18e98b14855689b972a027d3ee8d175c5f0fcf (patch) | |
tree | 1dd725ba561033fe818acbf01a6219683c449f1a /java/hiddenapi_modular.go | |
parent | 191be3a186a0face85909b92b28e3dc8a27940be (diff) |
Allow implementation details to be excluded from signature patterns file
Previously, the signature-patterns.csv file (which was output in an sdk
snapshot) included implementation details, e.g. the names of classes
that are not part of any API, including the hidden API. This change
allows a bootclasspath_fragment module owner to customize the generated
signature patterns file to remove as many implementation details as
possible from the sdk snapshot. That means that implementation only
changes would not require that sdk snapshots be updated in sync with
the corresponding APEX.
Module owners can remove implementation in the following ways:
1) Limit the number of packages that are treated as split packages by
explicitly specifying the split packages in the split_packages
property. A split package is one whose classes are provided by
separate bootclasspath_fragment modules and so the signature
patterns has to include every class in that package provided by a
specific bootclasspath_fragment module, including implementation
classes, instead of just listing the package.
The default is to treat all packages as being split, so if no
split_packages is specified then it defaults to ["*"] which matches
all packages. Assuming that no package was split unless specifically
stated would require that all the modules that had split packages
explicitly list them before this change could be submitted as
without them this change would break the build.
Once all existing modules with split packages have been updated to
include them then the default may be changed.
2) Adding package prefixes for any hierarchy of packages that are
owned solely by that bootclasspath_fragment. This removes the need
to list the packages in that hierarchy, including implementation
specific packages.
Bug: 194063708
Test: atest --host verify_overlaps_test signature_patterns_test
m out/soong/hiddenapi/hiddenapi-flags.csv
- manually change files to cause difference in flags to check
that it detects the differences.
Change-Id: If2f90cfc41b6fff9fa4ac8b9d4973110938b9392
Diffstat (limited to 'java/hiddenapi_modular.go')
-rw-r--r-- | java/hiddenapi_modular.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index f1e30f320..0cc960d5c 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -943,13 +943,22 @@ func (s SignatureCsvSubsets) RelativeToTop() []string { // buildRuleSignaturePatternsFile creates a rule to generate a file containing the set of signature // patterns that will select a subset of the monolithic flags. -func buildRuleSignaturePatternsFile(ctx android.ModuleContext, flagsPath android.Path) android.Path { +func buildRuleSignaturePatternsFile(ctx android.ModuleContext, flagsPath android.Path, splitPackages []string, packagePrefixes []string) android.Path { patternsFile := android.PathForModuleOut(ctx, "modular-hiddenapi", "signature-patterns.csv") // Create a rule to validate the output from the following rule. rule := android.NewRuleBuilder(pctx, ctx) + + // Quote any * in the packages to avoid them being expanded by the shell. + quotedSplitPackages := []string{} + for _, pkg := range splitPackages { + quotedSplitPackages = append(quotedSplitPackages, strings.ReplaceAll(pkg, "*", "\\*")) + } + rule.Command(). BuiltTool("signature_patterns"). FlagWithInput("--flags ", flagsPath). + FlagForEachArg("--split-package ", quotedSplitPackages). + FlagForEachArg("--package-prefix ", packagePrefixes). FlagWithOutput("--output ", patternsFile) rule.Build("hiddenAPISignaturePatterns", "hidden API signature patterns") |