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
(cherry picked from commit fcf79850d8430155119378e247c79dfc6443838a)
Merged-In: Ia854b9a52db2b1619fca41a387ce98d7f9f9efe9
diff --git a/apex/apex.go b/apex/apex.go
index 744a9a6..49e0d08 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -637,7 +637,7 @@
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 f442ddf..1c42495 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -26,12 +26,14 @@
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 d166add..45e8e0e 100644
--- a/sdk/compat_config_sdk_test.go
+++ b/sdk/compat_config_sdk_test.go
@@ -21,16 +21,12 @@
"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 @@
}),
)
}
+
+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"],
+ }
+`)
+}