Retry: Separate hidden API flags needed in sdk snapshots for S and T

Previous change that was reverted: https://r.android.com/1835222
An additional test was added that revealed a bug in the previous change
which has been fixed here.

Previously, the behavior of the stub_flags and all_flags properties
was different between S and T. In S they contained paths for the
complete set of stub flags and all the encoded flags. However, in T
they contained filtered sets of flags which if used in S would prevent
build checks from detecting possible inconsistencies. Also, a new
signature_patterns property was added in T that is not supported in S.

This change creates separate properties/files for T and reverts the
behavior of the properties/files that were added in S back to how they
behaved in S. The new properties are called filtered_stub_flags and
filtered_flags.

The S and T properties are tagged with the appropriate
supported_build_releases tag to ensure that they are only output when
specifically targeted.

Bug: 197842263
Test: m nothing
Change-Id: I1ce0a3d6623dabf73e32af1a7457b9b444fc3b7c
This commit is contained in:
Paul Duffin 2021-08-10 16:14:16 +01:00
parent 6e06f911a5
commit 191be3a186
6 changed files with 163 additions and 56 deletions

View file

@ -5058,8 +5058,9 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
metadata: "my-bootclasspath-fragment/metadata.csv",
index: "my-bootclasspath-fragment/index.csv",
stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
all_flags: "my-bootclasspath-fragment/all-flags.csv",
signature_patterns: "my-bootclasspath-fragment/signature-patterns.csv",
filtered_stub_flags: "my-bootclasspath-fragment/filtered-stub-flags.csv",
filtered_flags: "my-bootclasspath-fragment/filtered-flags.csv",
},
}
@ -5109,8 +5110,9 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
metadata: "my-bootclasspath-fragment/metadata.csv",
index: "my-bootclasspath-fragment/index.csv",
stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
all_flags: "my-bootclasspath-fragment/all-flags.csv",
signature_patterns: "my-bootclasspath-fragment/signature-patterns.csv",
filtered_stub_flags: "my-bootclasspath-fragment/filtered-stub-flags.csv",
filtered_flags: "my-bootclasspath-fragment/filtered-flags.csv",
},
}
@ -5238,8 +5240,9 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
metadata: "my-bootclasspath-fragment/metadata.csv",
index: "my-bootclasspath-fragment/index.csv",
stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
all_flags: "my-bootclasspath-fragment/all-flags.csv",
signature_patterns: "my-bootclasspath-fragment/signature-patterns.csv",
filtered_stub_flags: "my-bootclasspath-fragment/filtered-stub-flags.csv",
filtered_flags: "my-bootclasspath-fragment/filtered-flags.csv",
},
}
@ -5324,8 +5327,9 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
metadata: "my-bootclasspath-fragment/metadata.csv",
index: "my-bootclasspath-fragment/index.csv",
stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
all_flags: "my-bootclasspath-fragment/all-flags.csv",
signature_patterns: "my-bootclasspath-fragment/signature-patterns.csv",
filtered_stub_flags: "my-bootclasspath-fragment/filtered-stub-flags.csv",
filtered_flags: "my-bootclasspath-fragment/filtered-flags.csv",
},
}
@ -5408,8 +5412,9 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
metadata: "my-bootclasspath-fragment/metadata.csv",
index: "my-bootclasspath-fragment/index.csv",
stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
all_flags: "my-bootclasspath-fragment/all-flags.csv",
signature_patterns: "my-bootclasspath-fragment/signature-patterns.csv",
filtered_stub_flags: "my-bootclasspath-fragment/filtered-stub-flags.csv",
filtered_flags: "my-bootclasspath-fragment/filtered-flags.csv",
},
}
@ -7441,8 +7446,9 @@ func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) {
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
metadata: "my-bootclasspath-fragment/metadata.csv",
index: "my-bootclasspath-fragment/index.csv",
stub_flags: "my-bootclasspath-fragment/stub-flags.csv",
all_flags: "my-bootclasspath-fragment/all-flags.csv",
signature_patterns: "my-bootclasspath-fragment/signature-patterns.csv",
filtered_stub_flags: "my-bootclasspath-fragment/filtered-stub-flags.csv",
filtered_flags: "my-bootclasspath-fragment/filtered-flags.csv",
},
}

View file

@ -168,6 +168,76 @@ func TestPlatformBootclasspath_Fragments(t *testing.T) {
android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex10000/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
}
// TestPlatformBootclasspath_LegacyPrebuiltFragment verifies that the
// prebuilt_bootclasspath_fragment falls back to using the complete stub-flags/all-flags if the
// filtered files are not provided.
//
// TODO: Remove once all prebuilts use the filtered_... properties.
func TestPlatformBootclasspath_LegacyPrebuiltFragment(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
java.FixtureConfigureApexBootJars("myapex:foo"),
java.PrepareForTestWithJavaSdkLibraryFiles,
).RunTestWithBp(t, `
prebuilt_apex {
name: "myapex",
src: "myapex.apex",
exported_bootclasspath_fragments: ["mybootclasspath-fragment"],
}
// A prebuilt java_sdk_library_import that is not preferred by default but will be preferred
// because AlwaysUsePrebuiltSdks() is true.
java_sdk_library_import {
name: "foo",
prefer: false,
shared_library: false,
permitted_packages: ["foo"],
public: {
jars: ["sdk_library/public/foo-stubs.jar"],
stub_srcs: ["sdk_library/public/foo_stub_sources"],
current_api: "sdk_library/public/foo.txt",
removed_api: "sdk_library/public/foo-removed.txt",
sdk_version: "current",
},
apex_available: ["myapex"],
}
prebuilt_bootclasspath_fragment {
name: "mybootclasspath-fragment",
apex_available: [
"myapex",
],
contents: [
"foo",
],
hidden_api: {
stub_flags: "prebuilt-stub-flags.csv",
annotation_flags: "prebuilt-annotation-flags.csv",
metadata: "prebuilt-metadata.csv",
index: "prebuilt-index.csv",
all_flags: "prebuilt-all-flags.csv",
},
}
platform_bootclasspath {
name: "myplatform-bootclasspath",
fragments: [
{
apex: "myapex",
module:"mybootclasspath-fragment",
},
],
}
`,
)
pbcp := result.Module("myplatform-bootclasspath", "android_common")
info := result.ModuleProvider(pbcp, java.MonolithicHiddenAPIInfoProvider).(java.MonolithicHiddenAPIInfo)
android.AssertArrayString(t, "stub flags", []string{"prebuilt-stub-flags.csv:out/soong/.intermediates/mybootclasspath-fragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
android.AssertArrayString(t, "all flags", []string{"prebuilt-all-flags.csv:out/soong/.intermediates/mybootclasspath-fragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
}
func TestPlatformBootclasspathDependencies(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,

View file

@ -767,14 +767,20 @@ type bootclasspathFragmentSdkMemberProperties struct {
// The path to the generated index.csv file.
Index_path android.OptionalPath
// The path to the generated signature-patterns.csv file.
Signature_patterns_path android.OptionalPath
// The path to the generated stub-flags.csv file.
Stub_flags_path android.OptionalPath
Stub_flags_path android.OptionalPath `supported_build_releases:"S"`
// The path to the generated all-flags.csv file.
All_flags_path android.OptionalPath
All_flags_path android.OptionalPath `supported_build_releases:"S"`
// The path to the generated signature-patterns.csv file.
Signature_patterns_path android.OptionalPath `supported_build_releases:"T+"`
// The path to the generated filtered-stub-flags.csv file.
Filtered_stub_flags_path android.OptionalPath `supported_build_releases:"T+"`
// The path to the generated filtered-flags.csv file.
Filtered_flags_path android.OptionalPath `supported_build_releases:"T+"`
}
func (b *bootclasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
@ -793,10 +799,13 @@ func (b *bootclasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx andro
b.Metadata_path = android.OptionalPathForPath(hiddenAPIInfo.MetadataPath)
b.Index_path = android.OptionalPathForPath(hiddenAPIInfo.IndexPath)
b.Signature_patterns_path = android.OptionalPathForPath(hiddenAPIInfo.SignaturePatternsPath)
b.Stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.StubFlagsPath)
b.All_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AllFlagsPath)
b.Signature_patterns_path = android.OptionalPathForPath(hiddenAPIInfo.SignaturePatternsPath)
b.Filtered_stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.FilteredStubFlagsPath)
b.Filtered_flags_path = android.OptionalPathForPath(hiddenAPIInfo.FilteredFlagsPath)
// Copy stub_libs properties.
b.Stub_libs = module.properties.Api.Stub_libs
b.Core_platform_stub_libs = module.properties.Core_platform_api.Stub_libs
@ -861,9 +870,13 @@ func (b *bootclasspathFragmentSdkMemberProperties) AddToPropertySet(ctx android.
copyOptionalPath(b.Annotation_flags_path, "annotation_flags")
copyOptionalPath(b.Metadata_path, "metadata")
copyOptionalPath(b.Index_path, "index")
copyOptionalPath(b.Signature_patterns_path, "signature_patterns")
copyOptionalPath(b.Stub_flags_path, "stub_flags")
copyOptionalPath(b.All_flags_path, "all_flags")
copyOptionalPath(b.Signature_patterns_path, "signature_patterns")
copyOptionalPath(b.Filtered_stub_flags_path, "filtered_stub_flags")
copyOptionalPath(b.Filtered_flags_path, "filtered_flags")
}
var _ android.SdkMemberType = (*bootclasspathFragmentMemberType)(nil)
@ -889,6 +902,12 @@ type prebuiltBootclasspathFragmentProperties struct {
// The path to the all-flags.csv file created by the bootclasspath_fragment.
All_flags *string `android:"path"`
// The path to the filtered-stub-flags.csv file created by the bootclasspath_fragment.
Filtered_stub_flags *string `android:"path"`
// The path to the filtered-flags.csv file created by the bootclasspath_fragment.
Filtered_flags *string `android:"path"`
}
}
@ -915,9 +934,9 @@ func (module *prebuiltBootclasspathFragmentModule) Name() string {
// produceHiddenAPIOutput returns a path to the prebuilt all-flags.csv or nil if none is specified.
func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput {
pathForOptionalSrc := func(src *string) android.Path {
pathForOptionalSrc := func(src *string, defaultPath android.Path) android.Path {
if src == nil {
return nil
return defaultPath
}
return android.PathForModuleSrc(ctx, *src)
}
@ -938,13 +957,19 @@ func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx an
AnnotationFlagsPath: pathForSrc("hidden_api.annotation_flags", module.prebuiltProperties.Hidden_api.Annotation_flags),
MetadataPath: pathForSrc("hidden_api.metadata", module.prebuiltProperties.Hidden_api.Metadata),
IndexPath: pathForSrc("hidden_api.index", module.prebuiltProperties.Hidden_api.Index),
SignaturePatternsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Signature_patterns),
StubFlagsPath: pathForSrc("hidden_api.stub_flags", module.prebuiltProperties.Hidden_api.Stub_flags),
AllFlagsPath: pathForSrc("hidden_api.all_flags", module.prebuiltProperties.Hidden_api.All_flags),
SignaturePatternsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Signature_patterns, nil),
// TODO: Temporarily handle stub_flags/all_flags properties until prebuilts have been updated.
StubFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Stub_flags, nil),
AllFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.All_flags, nil),
},
EncodedBootDexFilesByModule: encodedBootDexJarsByModule,
}
// TODO: Temporarily fallback to stub_flags/all_flags properties until prebuilts have been updated.
output.FilteredStubFlagsPath = pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Filtered_stub_flags, output.StubFlagsPath)
output.FilteredFlagsPath = pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Filtered_flags, output.AllFlagsPath)
return &output
}

View file

@ -548,18 +548,18 @@ func (i *HiddenAPIInfo) mergeFromFragmentDeps(ctx android.ModuleContext, fragmen
}
}
// StubFlagSubset returns a SignatureCsvSubset that contains a path to a stub-flags.csv file and a
// path to a signature-patterns.csv file that defines a subset of the monolithic stub flags file,
// i.e. out/soong/hiddenapi/hiddenapi-stub-flags.txt, against which it will be compared.
// StubFlagSubset returns a SignatureCsvSubset that contains a path to a filtered-stub-flags.csv
// file and a path to a signature-patterns.csv file that defines a subset of the monolithic stub
// flags file, i.e. out/soong/hiddenapi/hiddenapi-stub-flags.txt, against which it will be compared.
func (i *HiddenAPIInfo) StubFlagSubset() SignatureCsvSubset {
return SignatureCsvSubset{i.StubFlagsPath, i.SignaturePatternsPath}
return SignatureCsvSubset{i.FilteredStubFlagsPath, i.SignaturePatternsPath}
}
// FlagSubset returns a SignatureCsvSubset that contains a path to an all-flags.csv file and a
// FlagSubset returns a SignatureCsvSubset that contains a path to a filtered-flags.csv file and a
// path to a signature-patterns.csv file that defines a subset of the monolithic flags file, i.e.
// out/soong/hiddenapi/hiddenapi-flags.csv, against which it will be compared.
func (i *HiddenAPIInfo) FlagSubset() SignatureCsvSubset {
return SignatureCsvSubset{i.AllFlagsPath, i.SignaturePatternsPath}
return SignatureCsvSubset{i.FilteredFlagsPath, i.SignaturePatternsPath}
}
var HiddenAPIInfoProvider = blueprint.NewProvider(HiddenAPIInfo{})
@ -784,9 +784,6 @@ func (i *HiddenAPIFlagInput) transitiveStubDexJarsByScope() StubDexJarsByModule
// HiddenAPIFlagOutput contains paths to output files from the hidden API flag generation for a
// bootclasspath_fragment module.
type HiddenAPIFlagOutput struct {
// The path to the generated stub-flags.csv file.
StubFlagsPath android.Path
// The path to the generated annotation-flags.csv file.
AnnotationFlagsPath android.Path
@ -796,12 +793,21 @@ type HiddenAPIFlagOutput struct {
// The path to the generated index.csv file.
IndexPath android.Path
// The path to the generated stub-flags.csv file.
StubFlagsPath android.Path
// The path to the generated all-flags.csv file.
AllFlagsPath android.Path
// The path to the generated signature-patterns.txt file which defines the subset of the
// monolithic hidden API files provided in this.
SignaturePatternsPath android.Path
// The path to the generated filtered-stub-flags.csv file.
FilteredStubFlagsPath android.Path
// The path to the generated filtered-flags.csv file.
FilteredFlagsPath android.Path
}
// bootDexJarByModule is a map from base module name (without prebuilt_ prefix) to the boot dex
@ -1067,11 +1073,13 @@ func hiddenAPIRulesForBootclasspathFragment(ctx android.ModuleContext, contents
// Store the paths in the info for use by other modules and sdk snapshot generation.
output := HiddenAPIOutput{
HiddenAPIFlagOutput: HiddenAPIFlagOutput{
StubFlagsPath: filteredStubFlagsCSV,
AnnotationFlagsPath: annotationFlagsCSV,
MetadataPath: metadataCSV,
IndexPath: indexCSV,
AllFlagsPath: filteredFlagsCSV,
AnnotationFlagsPath: annotationFlagsCSV,
MetadataPath: metadataCSV,
IndexPath: indexCSV,
StubFlagsPath: stubFlagsCSV,
AllFlagsPath: allFlagsCSV,
FilteredStubFlagsPath: filteredStubFlagsCSV,
FilteredFlagsPath: filteredFlagsCSV,
},
EncodedBootDexFilesByModule: encodedBootDexJarsByModule,
}

View file

@ -138,8 +138,8 @@ prebuilt_bootclasspath_fragment {
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
signature_patterns: "hiddenapi/signature-patterns.csv",
stub_flags: "hiddenapi/filtered-stub-flags.csv",
all_flags: "hiddenapi/filtered-flags.csv",
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
filtered_flags: "hiddenapi/filtered-flags.csv",
},
}
@ -166,8 +166,8 @@ prebuilt_bootclasspath_fragment {
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
signature_patterns: "hiddenapi/signature-patterns.csv",
stub_flags: "hiddenapi/filtered-stub-flags.csv",
all_flags: "hiddenapi/filtered-flags.csv",
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
filtered_flags: "hiddenapi/filtered-flags.csv",
},
}
@ -339,8 +339,8 @@ prebuilt_bootclasspath_fragment {
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
signature_patterns: "hiddenapi/signature-patterns.csv",
stub_flags: "hiddenapi/filtered-stub-flags.csv",
all_flags: "hiddenapi/filtered-flags.csv",
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
filtered_flags: "hiddenapi/filtered-flags.csv",
},
}
@ -424,8 +424,8 @@ prebuilt_bootclasspath_fragment {
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
signature_patterns: "hiddenapi/signature-patterns.csv",
stub_flags: "hiddenapi/filtered-stub-flags.csv",
all_flags: "hiddenapi/filtered-flags.csv",
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
filtered_flags: "hiddenapi/filtered-flags.csv",
},
}
@ -649,8 +649,8 @@ prebuilt_bootclasspath_fragment {
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
signature_patterns: "hiddenapi/signature-patterns.csv",
stub_flags: "hiddenapi/filtered-stub-flags.csv",
all_flags: "hiddenapi/filtered-flags.csv",
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
filtered_flags: "hiddenapi/filtered-flags.csv",
},
}
@ -852,8 +852,8 @@ prebuilt_bootclasspath_fragment {
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
signature_patterns: "hiddenapi/signature-patterns.csv",
stub_flags: "hiddenapi/filtered-stub-flags.csv",
all_flags: "hiddenapi/filtered-flags.csv",
filtered_stub_flags: "hiddenapi/filtered-stub-flags.csv",
filtered_flags: "hiddenapi/filtered-flags.csv",
},
}

View file

@ -753,9 +753,8 @@ prebuilt_bootclasspath_fragment {
annotation_flags: "hiddenapi/annotation-flags.csv",
metadata: "hiddenapi/metadata.csv",
index: "hiddenapi/index.csv",
signature_patterns: "hiddenapi/signature-patterns.csv",
stub_flags: "hiddenapi/filtered-stub-flags.csv",
all_flags: "hiddenapi/filtered-flags.csv",
stub_flags: "hiddenapi/stub-flags.csv",
all_flags: "hiddenapi/all-flags.csv",
},
}
@ -781,9 +780,8 @@ java_sdk_library_import {
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv
.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt
.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt