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
This commit is contained in:
@@ -686,13 +686,50 @@ func (s StubDexJarsByModule) StubDexJarsForScope(scope *HiddenAPIScope) android.
|
||||
return stubDexJars
|
||||
}
|
||||
|
||||
// HiddenAPIFlagInput encapsulates information obtained from a module and its dependencies that are
|
||||
// needed for hidden API flag generation.
|
||||
type HiddenAPIFlagInput struct {
|
||||
type HiddenAPIPropertyInfo struct {
|
||||
// FlagFilesByCategory contains the flag files that override the initial flags that are derived
|
||||
// from the stub dex files.
|
||||
FlagFilesByCategory FlagFilesByCategory
|
||||
|
||||
// See HiddenAPIFlagFileProperties.Package_prefixes
|
||||
PackagePrefixes []string
|
||||
|
||||
// See HiddenAPIFlagFileProperties.Single_packages
|
||||
SinglePackages []string
|
||||
|
||||
// See HiddenAPIFlagFileProperties.Split_packages
|
||||
SplitPackages []string
|
||||
}
|
||||
|
||||
// newHiddenAPIPropertyInfo creates a new initialized HiddenAPIPropertyInfo struct.
|
||||
func newHiddenAPIPropertyInfo() HiddenAPIPropertyInfo {
|
||||
return HiddenAPIPropertyInfo{
|
||||
FlagFilesByCategory: FlagFilesByCategory{},
|
||||
}
|
||||
}
|
||||
|
||||
// extractFlagFilesFromProperties extracts the paths to flag files that are specified in the
|
||||
// supplied properties and stores them in this struct.
|
||||
func (i *HiddenAPIPropertyInfo) extractFlagFilesFromProperties(ctx android.ModuleContext, p *HiddenAPIFlagFileProperties) {
|
||||
for _, category := range HiddenAPIFlagFileCategories {
|
||||
paths := android.PathsForModuleSrc(ctx, category.propertyValueReader(p))
|
||||
i.FlagFilesByCategory[category] = paths
|
||||
}
|
||||
}
|
||||
|
||||
// extractPackageRulesFromProperties extracts the package rules that are specified in the supplied
|
||||
// properties and stores them in this struct.
|
||||
func (i *HiddenAPIPropertyInfo) extractPackageRulesFromProperties(p *HiddenAPIPackageProperties) {
|
||||
i.PackagePrefixes = p.Hidden_api.Package_prefixes
|
||||
i.SinglePackages = p.Hidden_api.Single_packages
|
||||
i.SplitPackages = p.Hidden_api.Split_packages
|
||||
}
|
||||
|
||||
// HiddenAPIFlagInput encapsulates information obtained from a module and its dependencies that are
|
||||
// needed for hidden API flag generation.
|
||||
type HiddenAPIFlagInput struct {
|
||||
HiddenAPIPropertyInfo
|
||||
|
||||
// StubDexJarsByScope contains the stub dex jars for different *HiddenAPIScope and which determine
|
||||
// the initial flags for each dex member.
|
||||
StubDexJarsByScope StubDexJarsByModule
|
||||
@@ -714,10 +751,10 @@ type HiddenAPIFlagInput struct {
|
||||
RemovedTxtFiles android.Paths
|
||||
}
|
||||
|
||||
// newHiddenAPIFlagInput creates a new initialize HiddenAPIFlagInput struct.
|
||||
// newHiddenAPIFlagInput creates a new initialized HiddenAPIFlagInput struct.
|
||||
func newHiddenAPIFlagInput() HiddenAPIFlagInput {
|
||||
input := HiddenAPIFlagInput{
|
||||
FlagFilesByCategory: FlagFilesByCategory{},
|
||||
HiddenAPIPropertyInfo: newHiddenAPIPropertyInfo(),
|
||||
StubDexJarsByScope: StubDexJarsByModule{},
|
||||
DependencyStubDexJarsByScope: StubDexJarsByModule{},
|
||||
AdditionalStubDexJarsByScope: StubDexJarsByModule{},
|
||||
@@ -773,15 +810,6 @@ func (i *HiddenAPIFlagInput) gatherStubLibInfo(ctx android.ModuleContext, conten
|
||||
i.RemovedTxtFiles = android.SortedUniquePaths(i.RemovedTxtFiles)
|
||||
}
|
||||
|
||||
// extractFlagFilesFromProperties extracts the paths to flag files that are specified in the
|
||||
// supplied properties and stores them in this struct.
|
||||
func (i *HiddenAPIFlagInput) extractFlagFilesFromProperties(ctx android.ModuleContext, p *HiddenAPIFlagFileProperties) {
|
||||
for _, category := range HiddenAPIFlagFileCategories {
|
||||
paths := android.PathsForModuleSrc(ctx, category.propertyValueReader(p))
|
||||
i.FlagFilesByCategory[category] = paths
|
||||
}
|
||||
}
|
||||
|
||||
func (i *HiddenAPIFlagInput) transitiveStubDexJarsByScope() StubDexJarsByModule {
|
||||
transitive := i.DependencyStubDexJarsByScope
|
||||
transitive.addStubDexJarsByModule(i.StubDexJarsByScope)
|
||||
|
Reference in New Issue
Block a user