Put dependency in apex_manifest.json
To generate ld.config.txt dynamically(b/123722631), each APEX should provide some dependency information: a) list of libraries which other APEXes(or system) can use from this apex b) list of libraries which this apex uses from other APEXes(or system) This change puts dependency information in apex_manifest.json at build-time with two additional keys: a) provideNativeLibs b) requireNativeLibs Bug: 138695532 Test: m (runs soong tests) Test: find $OUT/apex -name apex_manifest.json -exec cat {} \; (shows contents of apex_manifest.json files) Change-Id: Iaad12c8c35454222ad177ce923cce76ef12a8a5a
This commit is contained in:
@@ -270,6 +270,13 @@ func ensureListNotContains(t *testing.T, result []string, notExpected string) {
|
||||
}
|
||||
}
|
||||
|
||||
func ensureListEmpty(t *testing.T, result []string) {
|
||||
t.Helper()
|
||||
if len(result) > 0 {
|
||||
t.Errorf("%q is expected to be empty", result)
|
||||
}
|
||||
}
|
||||
|
||||
// Minimal test
|
||||
func TestBasicApex(t *testing.T) {
|
||||
ctx, _ := testApex(t, `
|
||||
@@ -1060,6 +1067,109 @@ func TestHeaderLibsDependency(t *testing.T) {
|
||||
ensureContains(t, cFlags, "-Imy_include")
|
||||
}
|
||||
|
||||
func TestDependenciesInApexManifest(t *testing.T) {
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
name: "myapex_nodep",
|
||||
key: "myapex.key",
|
||||
native_shared_libs: ["lib_nodep"],
|
||||
compile_multilib: "both",
|
||||
file_contexts: "myapex",
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "myapex_dep",
|
||||
key: "myapex.key",
|
||||
native_shared_libs: ["lib_dep"],
|
||||
compile_multilib: "both",
|
||||
file_contexts: "myapex",
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "myapex_provider",
|
||||
key: "myapex.key",
|
||||
native_shared_libs: ["libfoo"],
|
||||
compile_multilib: "both",
|
||||
file_contexts: "myapex",
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "myapex_selfcontained",
|
||||
key: "myapex.key",
|
||||
native_shared_libs: ["lib_dep", "libfoo"],
|
||||
compile_multilib: "both",
|
||||
file_contexts: "myapex",
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
public_key: "testkey.avbpubkey",
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "lib_nodep",
|
||||
srcs: ["mylib.cpp"],
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "lib_dep",
|
||||
srcs: ["mylib.cpp"],
|
||||
shared_libs: ["libfoo"],
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libfoo",
|
||||
srcs: ["mytest.cpp"],
|
||||
stubs: {
|
||||
versions: ["1"],
|
||||
},
|
||||
system_shared_libs: [],
|
||||
stl: "none",
|
||||
}
|
||||
`)
|
||||
|
||||
names := func(s string) (ns []string) {
|
||||
for _, n := range strings.Split(s, " ") {
|
||||
if len(n) > 0 {
|
||||
ns = append(ns, n)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
var injectRule android.TestingBuildParams
|
||||
var provideNativeLibs, requireNativeLibs []string
|
||||
|
||||
injectRule = ctx.ModuleForTests("myapex_nodep", "android_common_myapex_nodep").Rule("injectApexDependency")
|
||||
provideNativeLibs = names(injectRule.Args["provideNativeLibs"])
|
||||
requireNativeLibs = names(injectRule.Args["requireNativeLibs"])
|
||||
ensureListEmpty(t, provideNativeLibs)
|
||||
ensureListEmpty(t, requireNativeLibs)
|
||||
|
||||
injectRule = ctx.ModuleForTests("myapex_dep", "android_common_myapex_dep").Rule("injectApexDependency")
|
||||
provideNativeLibs = names(injectRule.Args["provideNativeLibs"])
|
||||
requireNativeLibs = names(injectRule.Args["requireNativeLibs"])
|
||||
ensureListEmpty(t, provideNativeLibs)
|
||||
ensureListContains(t, requireNativeLibs, "libfoo.so")
|
||||
|
||||
injectRule = ctx.ModuleForTests("myapex_provider", "android_common_myapex_provider").Rule("injectApexDependency")
|
||||
provideNativeLibs = names(injectRule.Args["provideNativeLibs"])
|
||||
requireNativeLibs = names(injectRule.Args["requireNativeLibs"])
|
||||
ensureListContains(t, provideNativeLibs, "libfoo.so")
|
||||
ensureListEmpty(t, requireNativeLibs)
|
||||
|
||||
injectRule = ctx.ModuleForTests("myapex_selfcontained", "android_common_myapex_selfcontained").Rule("injectApexDependency")
|
||||
provideNativeLibs = names(injectRule.Args["provideNativeLibs"])
|
||||
requireNativeLibs = names(injectRule.Args["requireNativeLibs"])
|
||||
ensureListContains(t, provideNativeLibs, "libfoo.so")
|
||||
ensureListEmpty(t, requireNativeLibs)
|
||||
}
|
||||
|
||||
func TestNonTestApex(t *testing.T) {
|
||||
ctx, _ := testApex(t, `
|
||||
apex {
|
||||
|
Reference in New Issue
Block a user