From fcf79850d8430155119378e247c79dfc6443838a Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 20 Jul 2022 14:18:24 +0000 Subject: [PATCH] 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 --- apex/apex.go | 2 +- java/platform_compat_config.go | 14 ++++++++------ sdk/compat_config_sdk_test.go | 35 +++++++++++++++++++++++++++------- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index c31d87b5d..4394a30f9 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -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"} diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index f442ddfd4..1c4249507 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -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) { diff --git a/sdk/compat_config_sdk_test.go b/sdk/compat_config_sdk_test.go index d166add00..45e8e0ed6 100644 --- a/sdk/compat_config_sdk_test.go +++ b/sdk/compat_config_sdk_test.go @@ -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"], + } +`) +}