summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2025-01-21 15:38:58 -0800
committer Colin Cross <ccross@android.com> 2025-02-03 22:19:24 -0800
commit1115b4bf39bb343d3bb2b47d2796496bac13e61e (patch)
tree509465326be642eba4e8500cd68a09af39494de8
parente5c7d7c59e63919e9b6ccd655c35fc5371a8bce9 (diff)
Don't merge apex variations with different UsePlatformApis
Merging apex variations with different UsePlatformApis results in the presence of an extra apex with UsePlatformApis false changing the behavior of an existing apex -> module dependency with UsePlatformApis true, which can't be supported with incremental analysis. Don't merge apex variations with different UsePlatformApis values, and add a _p suffix to the UsePlatformApis variation so they can coexist. Test: Test_mergeApexVariations Bug: 372543712 Change-Id: I0e857a646a0449f87e4de6e6306ec921bc46fac1
-rw-r--r--android/apex.go3
-rw-r--r--android/apex_test.go19
-rw-r--r--apex/apex_test.go4
3 files changed, 18 insertions, 8 deletions
diff --git a/android/apex.go b/android/apex.go
index 08c82eb5a..c2f73a9c1 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -105,6 +105,9 @@ func (i ApexInfo) AddJSONData(d *map[string]interface{}) {
// thus wouldn't be merged.
func (i ApexInfo) mergedName() string {
name := "apex" + strconv.Itoa(i.MinSdkVersion.FinalOrFutureInt())
+ if i.UsePlatformApis {
+ name += "_p"
+ }
return name
}
diff --git a/android/apex_test.go b/android/apex_test.go
index 78597b234..acc195de2 100644
--- a/android/apex_test.go
+++ b/android/apex_test.go
@@ -193,7 +193,7 @@ func Test_mergeApexVariations(t *testing.T) {
},
},
{
- name: "merge different UsePlatformApis but don't allow using platform api",
+ name: "don't merge different UsePlatformApis",
in: []ApexInfo{
{
ApexVariationName: "foo",
@@ -213,13 +213,20 @@ func Test_mergeApexVariations(t *testing.T) {
{
ApexVariationName: "apex10000",
MinSdkVersion: FutureApiLevel,
- InApexVariants: []string{"foo", "bar"},
+ InApexVariants: []string{"foo"},
+ ForPrebuiltApex: NotForPrebuiltApex,
+ },
+ {
+ ApexVariationName: "apex10000_p",
+ MinSdkVersion: FutureApiLevel,
+ UsePlatformApis: true,
+ InApexVariants: []string{"bar"},
ForPrebuiltApex: NotForPrebuiltApex,
},
},
wantAliases: [][2]string{
{"foo", "apex10000"},
- {"bar", "apex10000"},
+ {"bar", "apex10000_p"},
},
},
{
@@ -242,7 +249,7 @@ func Test_mergeApexVariations(t *testing.T) {
},
wantMerged: []ApexInfo{
{
- ApexVariationName: "apex10000",
+ ApexVariationName: "apex10000_p",
MinSdkVersion: FutureApiLevel,
UsePlatformApis: true,
InApexVariants: []string{"foo", "bar"},
@@ -250,8 +257,8 @@ func Test_mergeApexVariations(t *testing.T) {
},
},
wantAliases: [][2]string{
- {"foo", "apex10000"},
- {"bar", "apex10000"},
+ {"foo", "apex10000_p"},
+ {"bar", "apex10000_p"},
},
},
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 78f24635e..d6cb79aa4 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -1249,12 +1249,12 @@ func TestApexCanUsePrivateApis(t *testing.T) {
// Ensure that we are using non-stub variants of mylib2 and libfoo.shared_from_rust (because
// of the platform_apis: true)
- mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_apex10000").Rule("ld").Args["libFlags"]
+ mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_apex10000_p").Rule("ld").Args["libFlags"]
ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_current/mylib2.so")
ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared/mylib2.so")
ensureNotContains(t, mylibLdFlags, "libmylib2_rust/android_arm64_armv8-a_shared_current/unstripped/libmylib2_rust.so")
ensureContains(t, mylibLdFlags, "libmylib2_rust/android_arm64_armv8-a_shared/unstripped/libmylib2_rust.so")
- rustDeps := ctx.ModuleForTests("foo.rust", "android_arm64_armv8-a_apex10000").Rule("rustc").Args["linkFlags"]
+ rustDeps := ctx.ModuleForTests("foo.rust", "android_arm64_armv8-a_apex10000_p").Rule("rustc").Args["linkFlags"]
ensureNotContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared_current/libfoo.shared_from_rust.so")
ensureContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared/libfoo.shared_from_rust.so")
ensureNotContains(t, rustDeps, "libmylib_rust.shared_from_rust/android_arm64_armv8-a_shared_current/unstripped/libmylib_rust.shared_from_rust.so")