Merge "Stop exporting systemserverclasspath_fragment when targeting S" into tm-dev
This commit is contained in:
commit
0147aca453
5 changed files with 110 additions and 9 deletions
|
@ -661,6 +661,10 @@ type SdkMemberType interface {
|
|||
// an Android.bp file.
|
||||
RequiresBpProperty() bool
|
||||
|
||||
// SupportedBuildReleases returns the string representation of a set of target build releases that
|
||||
// support this member type.
|
||||
SupportedBuildReleases() string
|
||||
|
||||
// UsableWithSdkAndSdkSnapshot returns true if the member type supports the sdk/sdk_snapshot,
|
||||
// false otherwise.
|
||||
UsableWithSdkAndSdkSnapshot() bool
|
||||
|
@ -760,6 +764,11 @@ type SdkMemberTypeBase struct {
|
|||
// property to be specifiable in an Android.bp file.
|
||||
BpPropertyNotRequired bool
|
||||
|
||||
// The name of the first targeted build release.
|
||||
//
|
||||
// If not specified then it is assumed to be available on all targeted build releases.
|
||||
SupportedBuildReleaseSpecification string
|
||||
|
||||
SupportsSdk bool
|
||||
HostOsDependent bool
|
||||
|
||||
|
@ -780,6 +789,10 @@ func (b *SdkMemberTypeBase) RequiresBpProperty() bool {
|
|||
return !b.BpPropertyNotRequired
|
||||
}
|
||||
|
||||
func (b *SdkMemberTypeBase) SupportedBuildReleases() string {
|
||||
return b.SupportedBuildReleaseSpecification
|
||||
}
|
||||
|
||||
func (b *SdkMemberTypeBase) UsableWithSdkAndSdkSnapshot() bool {
|
||||
return b.SupportsSdk
|
||||
}
|
||||
|
|
|
@ -164,6 +164,9 @@ var (
|
|||
android.SdkMemberTypeBase{
|
||||
PropertyName: "java_systemserver_libs",
|
||||
SupportsSdk: true,
|
||||
|
||||
// This was only added in Tiramisu.
|
||||
SupportedBuildReleaseSpecification: "Tiramisu+",
|
||||
},
|
||||
func(ctx android.SdkMemberContext, j *Library) android.Path {
|
||||
// Java systemserver libs are only provided in the SDK to provide access to their dex
|
||||
|
|
|
@ -28,6 +28,9 @@ func init() {
|
|||
SdkMemberTypeBase: android.SdkMemberTypeBase{
|
||||
PropertyName: "systemserverclasspath_fragments",
|
||||
SupportsSdk: true,
|
||||
|
||||
// This was only added in Tiramisu.
|
||||
SupportedBuildReleaseSpecification: "Tiramisu+",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -22,13 +22,16 @@ import (
|
|||
"android/soong/java"
|
||||
)
|
||||
|
||||
func TestSnapshotWithSystemServerClasspathFragment(t *testing.T) {
|
||||
func testSnapshotWithSystemServerClasspathFragment(t *testing.T, targetBuildRelease string, expectedUnversionedSdkSnapshot string, expectedVersionedSdkSnapshot string) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForSdkTestWithJava,
|
||||
java.PrepareForTestWithJavaDefaultModules,
|
||||
java.PrepareForTestWithJavaSdkLibraryFiles,
|
||||
java.FixtureWithLastReleaseApis("mysdklibrary"),
|
||||
dexpreopt.FixtureSetApexSystemServerJars("myapex:mylib", "myapex:mysdklibrary"),
|
||||
android.FixtureModifyEnv(func(env map[string]string) {
|
||||
env["SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE"] = targetBuildRelease
|
||||
}),
|
||||
prepareForSdkTestWithApex,
|
||||
|
||||
android.FixtureWithRootAndroidBp(`
|
||||
|
@ -83,7 +86,58 @@ func TestSnapshotWithSystemServerClasspathFragment(t *testing.T) {
|
|||
).RunTest(t)
|
||||
|
||||
CheckSnapshot(t, result, "mysdk", "",
|
||||
checkUnversionedAndroidBpContents(`
|
||||
checkUnversionedAndroidBpContents(expectedUnversionedSdkSnapshot),
|
||||
checkVersionedAndroidBpContents(expectedVersionedSdkSnapshot),
|
||||
)
|
||||
}
|
||||
|
||||
func TestSnapshotWithSystemServerClasspathFragment(t *testing.T) {
|
||||
t.Run("target-s", func(t *testing.T) {
|
||||
testSnapshotWithSystemServerClasspathFragment(t, "S", `
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
|
||||
java_sdk_library_import {
|
||||
name: "mysdklibrary",
|
||||
prefer: false,
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["myapex"],
|
||||
shared_library: false,
|
||||
public: {
|
||||
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
|
||||
current_api: "sdk_library/public/mysdklibrary.txt",
|
||||
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
|
||||
sdk_version: "current",
|
||||
},
|
||||
}
|
||||
`, `
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
|
||||
java_sdk_library_import {
|
||||
name: "mysdk_mysdklibrary@current",
|
||||
sdk_member_name: "mysdklibrary",
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["myapex"],
|
||||
shared_library: false,
|
||||
public: {
|
||||
jars: ["sdk_library/public/mysdklibrary-stubs.jar"],
|
||||
stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"],
|
||||
current_api: "sdk_library/public/mysdklibrary.txt",
|
||||
removed_api: "sdk_library/public/mysdklibrary-removed.txt",
|
||||
sdk_version: "current",
|
||||
},
|
||||
}
|
||||
|
||||
sdk_snapshot {
|
||||
name: "mysdk@current",
|
||||
visibility: ["//visibility:public"],
|
||||
java_sdk_libs: ["mysdk_mysdklibrary@current"],
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
t.Run("target-t", func(t *testing.T) {
|
||||
testSnapshotWithSystemServerClasspathFragment(t, "Tiramisu", `
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
|
||||
java_sdk_library_import {
|
||||
|
@ -120,8 +174,7 @@ prebuilt_systemserverclasspath_fragment {
|
|||
"mysdklibrary",
|
||||
],
|
||||
}
|
||||
`),
|
||||
checkVersionedAndroidBpContents(`
|
||||
`, `
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
|
||||
java_sdk_library_import {
|
||||
|
@ -166,6 +219,6 @@ sdk_snapshot {
|
|||
java_systemserver_libs: ["mysdk_mylib@current"],
|
||||
systemserverclasspath_fragments: ["mysdk_mysystemserverclasspathfragment@current"],
|
||||
}
|
||||
`),
|
||||
)
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ func (s *sdk) collectMembers(ctx android.ModuleContext) {
|
|||
// Finally, the member type slices are concatenated together to form a single slice. The order in
|
||||
// which they are concatenated is the order in which the member types were registered in the
|
||||
// android.SdkMemberTypesRegistry.
|
||||
func (s *sdk) groupMemberVariantsByMemberThenType(ctx android.ModuleContext, memberVariantDeps []sdkMemberVariantDep) []*sdkMember {
|
||||
func (s *sdk) groupMemberVariantsByMemberThenType(ctx android.ModuleContext, targetBuildRelease *buildRelease, memberVariantDeps []sdkMemberVariantDep) []*sdkMember {
|
||||
byType := make(map[android.SdkMemberType][]*sdkMember)
|
||||
byName := make(map[string]*sdkMember)
|
||||
|
||||
|
@ -265,13 +265,39 @@ func (s *sdk) groupMemberVariantsByMemberThenType(ctx android.ModuleContext, mem
|
|||
|
||||
var members []*sdkMember
|
||||
for _, memberListProperty := range s.memberTypeListProperties() {
|
||||
membersOfType := byType[memberListProperty.memberType]
|
||||
memberType := memberListProperty.memberType
|
||||
|
||||
if !isMemberTypeSupportedByTargetBuildRelease(memberType, targetBuildRelease) {
|
||||
continue
|
||||
}
|
||||
|
||||
membersOfType := byType[memberType]
|
||||
members = append(members, membersOfType...)
|
||||
}
|
||||
|
||||
return members
|
||||
}
|
||||
|
||||
// isMemberTypeSupportedByTargetBuildRelease returns true if the member type is supported by the
|
||||
// target build release.
|
||||
func isMemberTypeSupportedByTargetBuildRelease(memberType android.SdkMemberType, targetBuildRelease *buildRelease) bool {
|
||||
supportedByTargetBuildRelease := true
|
||||
supportedBuildReleases := memberType.SupportedBuildReleases()
|
||||
if supportedBuildReleases == "" {
|
||||
supportedBuildReleases = "S+"
|
||||
}
|
||||
|
||||
set, err := parseBuildReleaseSet(supportedBuildReleases)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("member type %s has invalid supported build releases %q: %s",
|
||||
memberType.SdkPropertyName(), supportedBuildReleases, err))
|
||||
}
|
||||
if !set.contains(targetBuildRelease) {
|
||||
supportedByTargetBuildRelease = false
|
||||
}
|
||||
return supportedByTargetBuildRelease
|
||||
}
|
||||
|
||||
func appendUniqueVariants(variants []android.SdkAware, newVariant android.SdkAware) []android.SdkAware {
|
||||
for _, v := range variants {
|
||||
if v == newVariant {
|
||||
|
@ -416,7 +442,7 @@ be unnecessary as every module in the sdk already has its own licenses property.
|
|||
|
||||
// Group the variants for each member module together and then group the members of each member
|
||||
// type together.
|
||||
members := s.groupMemberVariantsByMemberThenType(ctx, memberVariantDeps)
|
||||
members := s.groupMemberVariantsByMemberThenType(ctx, targetBuildRelease, memberVariantDeps)
|
||||
|
||||
// Create the prebuilt modules for each of the member modules.
|
||||
traits := s.gatherTraits()
|
||||
|
@ -795,6 +821,9 @@ func (s *sdk) addSnapshotPropertiesToPropertySet(builder *snapshotBuilder, prope
|
|||
if memberListProperty.getter == nil {
|
||||
continue
|
||||
}
|
||||
if !isMemberTypeSupportedByTargetBuildRelease(memberListProperty.memberType, builder.targetBuildRelease) {
|
||||
continue
|
||||
}
|
||||
names := memberListProperty.getter(dynamicMemberTypeListProperties)
|
||||
if len(names) > 0 {
|
||||
propertySet.AddProperty(memberListProperty.propertyName(), builder.versionedSdkMemberNames(names, false))
|
||||
|
|
Loading…
Reference in a new issue