Export any platform_compat_config used by apex to sdk snapshot

Previously, the platform_compat_config modules needed to be explicitly
listed in the sdk snapshot and the apex. This change will automatically
export them to the sdk snapshot when the apex is listed in its apexes
property.

Bug: 232401814
Test: m tethering-module-sdk
      # Before this change the generated snapshot did not contain the
      # platform_compat_config, after this change it did.
      m art-module-sdk
      # As that explicitly specifies the platform_compat_config in its
      # compat_configs property this change has no effect.
Change-Id: Ia854b9a52db2b1619fca41a387ce98d7f9f9efe9
This commit is contained in:
Paul Duffin 2022-07-20 14:18:24 +00:00
parent 1b3d5f836c
commit fcf79850d8
3 changed files with 37 additions and 14 deletions

View file

@ -640,7 +640,7 @@ var (
fsTag = &dependencyTag{name: "filesystem", payload: true}
bcpfTag = &dependencyTag{name: "bootclasspathFragment", payload: true, sourceOnly: true, memberType: java.BootclasspathFragmentSdkMemberType}
sscpfTag = &dependencyTag{name: "systemserverclasspathFragment", payload: true, sourceOnly: true, memberType: java.SystemServerClasspathFragmentSdkMemberType}
compatConfigTag = &dependencyTag{name: "compatConfig", payload: true, sourceOnly: true}
compatConfigTag = &dependencyTag{name: "compatConfig", payload: true, sourceOnly: true, memberType: java.CompatConfigSdkMemberType}
javaLibTag = &dependencyTag{name: "javaLib", payload: true}
jniLibTag = &dependencyTag{name: "jniLib", payload: true}
keyTag = &dependencyTag{name: "key"}

View file

@ -26,12 +26,14 @@ import (
func init() {
registerPlatformCompatConfigBuildComponents(android.InitRegistrationContext)
android.RegisterSdkMemberType(&compatConfigMemberType{
SdkMemberTypeBase: android.SdkMemberTypeBase{
PropertyName: "compat_configs",
SupportsSdk: true,
},
})
android.RegisterSdkMemberType(CompatConfigSdkMemberType)
}
var CompatConfigSdkMemberType = &compatConfigMemberType{
SdkMemberTypeBase: android.SdkMemberTypeBase{
PropertyName: "compat_configs",
SupportsSdk: true,
},
}
func registerPlatformCompatConfigBuildComponents(ctx android.RegistrationContext) {

View file

@ -21,16 +21,12 @@ import (
"android/soong/java"
)
func TestSnapshotWithCompatConfig(t *testing.T) {
func testSnapshotWithCompatConfig(t *testing.T, sdk string) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithPlatformCompatConfig,
).RunTestWithBp(t, `
sdk {
name: "mysdk",
compat_configs: ["myconfig"],
}
prepareForSdkTestWithApex,
).RunTestWithBp(t, sdk+`
platform_compat_config {
name: "myconfig",
}
@ -73,3 +69,28 @@ prebuilt_platform_compat_config {
}),
)
}
func TestSnapshotWithCompatConfig(t *testing.T) {
testSnapshotWithCompatConfig(t, `
sdk {
name: "mysdk",
compat_configs: ["myconfig"],
}
`)
}
func TestSnapshotWithCompatConfig_Apex(t *testing.T) {
testSnapshotWithCompatConfig(t, `
apex {
name: "myapex",
key: "myapex.key",
min_sdk_version: "2",
compat_configs: ["myconfig"],
}
sdk {
name: "mysdk",
apexes: ["myapex"],
}
`)
}