Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1149c2c1 authored by Paul Duffin's avatar Paul Duffin Committed by Gerrit Code Review
Browse files

Merge changes I66445302,I773279a4

* changes:
  Push Hidden_api inside HiddenAPIFlagFileProperties
  Refactor handling of hidden API property provided information
parents e29d230b 9b61abbd
Loading
Loading
Loading
Loading
+12 −9
Original line number Original line Diff line number Diff line
@@ -128,7 +128,7 @@ type bootclasspathFragmentProperties struct {
	Coverage BootclasspathFragmentCoverageAffectedProperties
	Coverage BootclasspathFragmentCoverageAffectedProperties


	// Hidden API related properties.
	// Hidden API related properties.
	Hidden_api HiddenAPIFlagFileProperties
	HiddenAPIFlagFileProperties


	// The list of additional stub libraries which this fragment's contents use but which are not
	// The list of additional stub libraries which this fragment's contents use but which are not
	// provided by another bootclasspath_fragment.
	// provided by another bootclasspath_fragment.
@@ -145,7 +145,7 @@ type bootclasspathFragmentProperties struct {
	BootclasspathFragmentsDepsProperties
	BootclasspathFragmentsDepsProperties
}
}


type HiddenApiPackageProperties struct {
type HiddenAPIPackageProperties struct {
	Hidden_api struct {
	Hidden_api struct {
		// Contains prefixes of a package hierarchy that is provided solely by this
		// Contains prefixes of a package hierarchy that is provided solely by this
		// bootclasspath_fragment.
		// bootclasspath_fragment.
@@ -222,8 +222,8 @@ type HiddenApiPackageProperties struct {
}
}


type SourceOnlyBootclasspathProperties struct {
type SourceOnlyBootclasspathProperties struct {
	HiddenApiPackageProperties
	HiddenAPIPackageProperties
	Coverage HiddenApiPackageProperties
	Coverage HiddenAPIPackageProperties
}
}


type BootclasspathFragmentModule struct {
type BootclasspathFragmentModule struct {
@@ -293,7 +293,7 @@ func bootclasspathFragmentFactory() android.Module {
				return
				return
			}
			}


			err = proptools.AppendProperties(&m.sourceOnlyProperties.HiddenApiPackageProperties, &m.sourceOnlyProperties.Coverage, nil)
			err = proptools.AppendProperties(&m.sourceOnlyProperties.HiddenAPIPackageProperties, &m.sourceOnlyProperties.Coverage, nil)
			if err != nil {
			if err != nil {
				ctx.PropertyErrorf("coverage", "error trying to append hidden api coverage specific properties: %s", err)
				ctx.PropertyErrorf("coverage", "error trying to append hidden api coverage specific properties: %s", err)
				return
				return
@@ -825,7 +825,10 @@ func (b *BootclasspathFragmentModule) createHiddenAPIFlagInput(ctx android.Modul
	input.gatherStubLibInfo(ctx, contents)
	input.gatherStubLibInfo(ctx, contents)


	// Populate with flag file paths from the properties.
	// Populate with flag file paths from the properties.
	input.extractFlagFilesFromProperties(ctx, &b.properties.Hidden_api)
	input.extractFlagFilesFromProperties(ctx, &b.properties.HiddenAPIFlagFileProperties)

	// Populate with package rules from the properties.
	input.extractPackageRulesFromProperties(&b.sourceOnlyProperties.HiddenAPIPackageProperties)


	// Add the stub dex jars from this module's fragment dependencies.
	// Add the stub dex jars from this module's fragment dependencies.
	input.DependencyStubDexJarsByScope.addStubDexJarsByModule(dependencyHiddenApiInfo.TransitiveStubDexJarsByScope)
	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
	// If the module specifies split_packages or package_prefixes then use those to generate the
	// signature patterns.
	// signature patterns.
	splitPackages := b.sourceOnlyProperties.Hidden_api.Split_packages
	splitPackages := input.SplitPackages
	packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes
	packagePrefixes := input.PackagePrefixes
	singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages
	singlePackages := input.SinglePackages
	if splitPackages != nil || packagePrefixes != nil || singlePackages != nil {
	if splitPackages != nil || packagePrefixes != nil || singlePackages != nil {
		output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
		output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
			ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages)
			ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages)
+74 −41
Original line number Original line Diff line number Diff line
@@ -378,24 +378,28 @@ func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name,
// with one Java package per line. All members of all classes within that package (but not nested
// with one Java package per line. All members of all classes within that package (but not nested
// packages) will be updated in a property specific way.
// packages) will be updated in a property specific way.
type HiddenAPIFlagFileProperties struct {
type HiddenAPIFlagFileProperties struct {
	Hidden_api struct {
		// Marks each signature in the referenced files as being unsupported.
		// Marks each signature in the referenced files as being unsupported.
		Unsupported []string `android:"path"`
		Unsupported []string `android:"path"`


	// Marks each signature in the referenced files as being unsupported because it has been removed.
		// Marks each signature in the referenced files as being unsupported because it has been
	// Any conflicts with other flags are ignored.
		// removed. Any conflicts with other flags are ignored.
		Removed []string `android:"path"`
		Removed []string `android:"path"`


	// Marks each signature in the referenced files as being supported only for targetSdkVersion <= R
		// Marks each signature in the referenced files as being supported only for
	// and low priority.
		// targetSdkVersion <= R and low priority.
		Max_target_r_low_priority []string `android:"path"`
		Max_target_r_low_priority []string `android:"path"`


	// Marks each signature in the referenced files as being supported only for targetSdkVersion <= Q.
		// Marks each signature in the referenced files as being supported only for
		// targetSdkVersion <= Q.
		Max_target_q []string `android:"path"`
		Max_target_q []string `android:"path"`


	// Marks each signature in the referenced files as being supported only for targetSdkVersion <= P.
		// Marks each signature in the referenced files as being supported only for
		// targetSdkVersion <= P.
		Max_target_p []string `android:"path"`
		Max_target_p []string `android:"path"`


	// Marks each signature in the referenced files as being supported only for targetSdkVersion <= O
		// Marks each signature in the referenced files as being supported only for
		// targetSdkVersion <= O
		// and low priority. Any conflicts with other flags are ignored.
		// and low priority. Any conflicts with other flags are ignored.
		Max_target_o_low_priority []string `android:"path"`
		Max_target_o_low_priority []string `android:"path"`


@@ -405,6 +409,7 @@ type HiddenAPIFlagFileProperties struct {
		// Marks each signature in every package in the referenced files as being unsupported.
		// Marks each signature in every package in the referenced files as being unsupported.
		Unsupported_packages []string `android:"path"`
		Unsupported_packages []string `android:"path"`
	}
	}
}


type hiddenAPIFlagFileCategory struct {
type hiddenAPIFlagFileCategory struct {
	// PropertyName is the name of the property for this category.
	// PropertyName is the name of the property for this category.
@@ -428,7 +433,7 @@ var hiddenAPIRemovedFlagFileCategory = &hiddenAPIFlagFileCategory{
	// See HiddenAPIFlagFileProperties.Removed
	// See HiddenAPIFlagFileProperties.Removed
	PropertyName: "removed",
	PropertyName: "removed",
	propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
	propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
		return properties.Removed
		return properties.Hidden_api.Removed
	},
	},
	commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
	commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
		command.FlagWithInput("--unsupported ", path).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "removed")
		command.FlagWithInput("--unsupported ", path).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "removed")
@@ -440,7 +445,7 @@ var HiddenAPIFlagFileCategories = []*hiddenAPIFlagFileCategory{
	{
	{
		PropertyName: "unsupported",
		PropertyName: "unsupported",
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
			return properties.Unsupported
			return properties.Hidden_api.Unsupported
		},
		},
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
			command.FlagWithInput("--unsupported ", path)
			command.FlagWithInput("--unsupported ", path)
@@ -451,7 +456,7 @@ var HiddenAPIFlagFileCategories = []*hiddenAPIFlagFileCategory{
	{
	{
		PropertyName: "max_target_r_low_priority",
		PropertyName: "max_target_r_low_priority",
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
			return properties.Max_target_r_low_priority
			return properties.Hidden_api.Max_target_r_low_priority
		},
		},
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
			command.FlagWithInput("--max-target-r ", path).FlagWithArg("--tag ", "lo-prio")
			command.FlagWithInput("--max-target-r ", path).FlagWithArg("--tag ", "lo-prio")
@@ -461,7 +466,7 @@ var HiddenAPIFlagFileCategories = []*hiddenAPIFlagFileCategory{
	{
	{
		PropertyName: "max_target_q",
		PropertyName: "max_target_q",
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
			return properties.Max_target_q
			return properties.Hidden_api.Max_target_q
		},
		},
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
			command.FlagWithInput("--max-target-q ", path)
			command.FlagWithInput("--max-target-q ", path)
@@ -471,7 +476,7 @@ var HiddenAPIFlagFileCategories = []*hiddenAPIFlagFileCategory{
	{
	{
		PropertyName: "max_target_p",
		PropertyName: "max_target_p",
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
			return properties.Max_target_p
			return properties.Hidden_api.Max_target_p
		},
		},
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
			command.FlagWithInput("--max-target-p ", path)
			command.FlagWithInput("--max-target-p ", path)
@@ -481,7 +486,7 @@ var HiddenAPIFlagFileCategories = []*hiddenAPIFlagFileCategory{
	{
	{
		PropertyName: "max_target_o_low_priority",
		PropertyName: "max_target_o_low_priority",
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
			return properties.Max_target_o_low_priority
			return properties.Hidden_api.Max_target_o_low_priority
		},
		},
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
			command.FlagWithInput("--max-target-o ", path).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "lo-prio")
			command.FlagWithInput("--max-target-o ", path).Flag("--ignore-conflicts ").FlagWithArg("--tag ", "lo-prio")
@@ -491,7 +496,7 @@ var HiddenAPIFlagFileCategories = []*hiddenAPIFlagFileCategory{
	{
	{
		PropertyName: "blocked",
		PropertyName: "blocked",
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
			return properties.Blocked
			return properties.Hidden_api.Blocked
		},
		},
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
			command.FlagWithInput("--blocked ", path)
			command.FlagWithInput("--blocked ", path)
@@ -501,7 +506,7 @@ var HiddenAPIFlagFileCategories = []*hiddenAPIFlagFileCategory{
	{
	{
		PropertyName: "unsupported_packages",
		PropertyName: "unsupported_packages",
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
		propertyValueReader: func(properties *HiddenAPIFlagFileProperties) []string {
			return properties.Unsupported_packages
			return properties.Hidden_api.Unsupported_packages
		},
		},
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
		commandMutator: func(command *android.RuleBuilderCommand, path android.Path) {
			command.FlagWithInput("--unsupported ", path).Flag("--packages ")
			command.FlagWithInput("--unsupported ", path).Flag("--packages ")
@@ -686,13 +691,50 @@ func (s StubDexJarsByModule) StubDexJarsForScope(scope *HiddenAPIScope) android.
	return stubDexJars
	return stubDexJars
}
}


// HiddenAPIFlagInput encapsulates information obtained from a module and its dependencies that are
type HiddenAPIPropertyInfo struct {
// needed for hidden API flag generation.
type HiddenAPIFlagInput struct {
	// FlagFilesByCategory contains the flag files that override the initial flags that are derived
	// FlagFilesByCategory contains the flag files that override the initial flags that are derived
	// from the stub dex files.
	// from the stub dex files.
	FlagFilesByCategory FlagFilesByCategory
	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
	// StubDexJarsByScope contains the stub dex jars for different *HiddenAPIScope and which determine
	// the initial flags for each dex member.
	// the initial flags for each dex member.
	StubDexJarsByScope StubDexJarsByModule
	StubDexJarsByScope StubDexJarsByModule
@@ -714,10 +756,10 @@ type HiddenAPIFlagInput struct {
	RemovedTxtFiles android.Paths
	RemovedTxtFiles android.Paths
}
}


// newHiddenAPIFlagInput creates a new initialize HiddenAPIFlagInput struct.
// newHiddenAPIFlagInput creates a new initialized HiddenAPIFlagInput struct.
func newHiddenAPIFlagInput() HiddenAPIFlagInput {
func newHiddenAPIFlagInput() HiddenAPIFlagInput {
	input := HiddenAPIFlagInput{
	input := HiddenAPIFlagInput{
		FlagFilesByCategory:          FlagFilesByCategory{},
		HiddenAPIPropertyInfo:        newHiddenAPIPropertyInfo(),
		StubDexJarsByScope:           StubDexJarsByModule{},
		StubDexJarsByScope:           StubDexJarsByModule{},
		DependencyStubDexJarsByScope: StubDexJarsByModule{},
		DependencyStubDexJarsByScope: StubDexJarsByModule{},
		AdditionalStubDexJarsByScope: StubDexJarsByModule{},
		AdditionalStubDexJarsByScope: StubDexJarsByModule{},
@@ -773,15 +815,6 @@ func (i *HiddenAPIFlagInput) gatherStubLibInfo(ctx android.ModuleContext, conten
	i.RemovedTxtFiles = android.SortedUniquePaths(i.RemovedTxtFiles)
	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 {
func (i *HiddenAPIFlagInput) transitiveStubDexJarsByScope() StubDexJarsByModule {
	transitive := i.DependencyStubDexJarsByScope
	transitive := i.DependencyStubDexJarsByScope
	transitive.addStubDexJarsByModule(i.StubDexJarsByScope)
	transitive.addStubDexJarsByModule(i.StubDexJarsByScope)
+2 −2
Original line number Original line Diff line number Diff line
@@ -62,7 +62,7 @@ type platformBootclasspathModule struct {
type platformBootclasspathProperties struct {
type platformBootclasspathProperties struct {
	BootclasspathFragmentsDepsProperties
	BootclasspathFragmentsDepsProperties


	Hidden_api HiddenAPIFlagFileProperties
	HiddenAPIFlagFileProperties
}
}


func platformBootclasspathFactory() android.SingletonModule {
func platformBootclasspathFactory() android.SingletonModule {
@@ -372,7 +372,7 @@ func (b *platformBootclasspathModule) createAndProvideMonolithicHiddenAPIInfo(ct
	temporaryInput := newHiddenAPIFlagInput()
	temporaryInput := newHiddenAPIFlagInput()


	// Create paths to the flag files specified in the properties.
	// Create paths to the flag files specified in the properties.
	temporaryInput.extractFlagFilesFromProperties(ctx, &b.properties.Hidden_api)
	temporaryInput.extractFlagFilesFromProperties(ctx, &b.properties.HiddenAPIFlagFileProperties)


	// Create the monolithic info, by starting with the flag files specified on this and then merging
	// Create the monolithic info, by starting with the flag files specified on this and then merging
	// in information from all the fragment dependencies of this.
	// in information from all the fragment dependencies of this.