summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chan Wang <chanwang@google.com> 2025-01-10 10:23:21 +0000
committer Chan Wang <chanwang@google.com> 2025-01-10 13:35:53 +0000
commita8c8e20d0da3c6231906c225099f38d983ade041 (patch)
tree0cd50b7539921b71020f1c992ccc3ac3b4204c74
parent473f6be94715dbf33d19509b7523de1e03405314 (diff)
Collect dependencies of updatable apexes only for AOSP APEX
Bug: 380222284 Test: m nothing --no-skip-soong-tests Change-Id: Ic629fce1d3cde728e6bd4b67f76ae72244669f54
-rw-r--r--apex/apex_singleton.go5
-rw-r--r--apex/apex_test.go85
2 files changed, 79 insertions, 11 deletions
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index 7b3acb509..263e0a52c 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -18,6 +18,7 @@ package apex
import (
"encoding/json"
+ "strings"
"github.com/google/blueprint"
@@ -94,7 +95,9 @@ func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContex
apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider)
if path := binaryInfo.FlatListPath(); path != nil {
if binaryInfo.Updatable() || apexInfo.Updatable {
- updatableFlatLists = append(updatableFlatLists, path)
+ if strings.HasPrefix(module.String(), "com.android.") {
+ updatableFlatLists = append(updatableFlatLists, path)
+ }
}
}
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 0472488c7..465789c12 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -2129,11 +2129,11 @@ func TestApexMinSdkVersion_InVendorApex(t *testing.T) {
android.AssertStringDoesContain(t, "cflags", cflags, "-target aarch64-linux-android29")
}
-func TestTrackAllowedDeps(t *testing.T) {
+func TestTrackAllowedDepsForAndroidApex(t *testing.T) {
t.Parallel()
ctx := testApex(t, `
apex {
- name: "myapex",
+ name: "com.android.myapex",
key: "myapex.key",
updatable: true,
native_shared_libs: [
@@ -2161,7 +2161,7 @@ func TestTrackAllowedDeps(t *testing.T) {
srcs: ["mylib.cpp"],
shared_libs: ["libbar"],
min_sdk_version: "29",
- apex_available: ["myapex"],
+ apex_available: ["com.android.myapex"],
}
cc_library {
@@ -2173,20 +2173,24 @@ func TestTrackAllowedDeps(t *testing.T) {
name: "yourlib",
srcs: ["mylib.cpp"],
min_sdk_version: "29",
- apex_available: ["myapex", "myapex2", "//apex_available:platform"],
+ apex_available: ["com.android.myapex", "myapex2", "//apex_available:platform"],
}
`, withFiles(android.MockFS{
"packages/modules/common/build/allowed_deps.txt": nil,
- }))
+ }),
+ android.FixtureMergeMockFs(android.MockFS{
+ "system/sepolicy/apex/com.android.myapex-file_contexts": nil,
+ }))
depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton")
inputs := depsinfo.Rule("generateApexDepsInfoFilesRule").BuildParams.Inputs.Strings()
- android.AssertStringListContains(t, "updatable myapex should generate depsinfo file", inputs,
- "out/soong/.intermediates/myapex/android_common_myapex/depsinfo/flatlist.txt")
+
+ android.AssertStringListContains(t, "updatable com.android.myapex should generate depsinfo file", inputs,
+ "out/soong/.intermediates/com.android.myapex/android_common_com.android.myapex/depsinfo/flatlist.txt")
android.AssertStringListDoesNotContain(t, "non-updatable myapex2 should not generate depsinfo file", inputs,
"out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt")
- myapex := ctx.ModuleForTests("myapex", "android_common_myapex")
+ myapex := ctx.ModuleForTests("com.android.myapex", "android_common_com.android.myapex")
flatlist := strings.Split(android.ContentFromFileRuleForTests(t, ctx,
myapex.Output("depsinfo/flatlist.txt")), "\n")
android.AssertStringListContains(t, "deps with stubs should be tracked in depsinfo as external dep",
@@ -2197,22 +2201,83 @@ func TestTrackAllowedDeps(t *testing.T) {
flatlist, "yourlib(minSdkVersion:29)")
}
-func TestTrackAllowedDeps_SkipWithoutAllowedDepsTxt(t *testing.T) {
+func TestNotTrackAllowedDepsForNonAndroidApex(t *testing.T) {
t.Parallel()
ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
updatable: true,
+ native_shared_libs: [
+ "mylib",
+ "yourlib",
+ ],
min_sdk_version: "29",
}
+ apex {
+ name: "myapex2",
+ key: "myapex.key",
+ updatable: false,
+ native_shared_libs: ["yourlib"],
+ }
+
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
- `)
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ shared_libs: ["libbar"],
+ min_sdk_version: "29",
+ apex_available: ["myapex"],
+ }
+
+ cc_library {
+ name: "libbar",
+ stubs: { versions: ["29", "30"] },
+ }
+
+ cc_library {
+ name: "yourlib",
+ srcs: ["mylib.cpp"],
+ min_sdk_version: "29",
+ apex_available: ["myapex", "myapex2", "//apex_available:platform"],
+ }
+ `, withFiles(android.MockFS{
+ "packages/modules/common/build/allowed_deps.txt": nil,
+ }))
+
+ depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton")
+ inputs := depsinfo.Rule("generateApexDepsInfoFilesRule").BuildParams.Inputs.Strings()
+ android.AssertStringListDoesNotContain(t, "updatable myapex should generate depsinfo file", inputs,
+ "out/soong/.intermediates/myapex/android_common_myapex/depsinfo/flatlist.txt")
+ android.AssertStringListDoesNotContain(t, "non-updatable myapex2 should not generate depsinfo file", inputs,
+ "out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt")
+}
+
+func TestTrackAllowedDeps_SkipWithoutAllowedDepsTxt(t *testing.T) {
+ t.Parallel()
+ ctx := testApex(t, `
+ apex {
+ name: "com.android.myapex",
+ key: "myapex.key",
+ updatable: true,
+ min_sdk_version: "29",
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `,
+ android.FixtureMergeMockFs(android.MockFS{
+ "system/sepolicy/apex/com.android.myapex-file_contexts": nil,
+ }))
depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton")
if nil != depsinfo.MaybeRule("generateApexDepsInfoFilesRule").Output {
t.Error("apex_depsinfo_singleton shouldn't run when allowed_deps.txt doesn't exist")