native shared libs in an SDK can be snapshotted
The snapshot script can now handle native shared libs in an SDK.
Bug: 138182343
Test: create following sdk module:
sdk {
name: "mysdk",
native_shared_libs: ["libc", "libdl"],
}
, then execute `m mysdk` and execute the update_prebuilt-1.sh as
prompted. Following directories are generated under the directory where
mysdk is defined at:
1
├── aidl
├── Android.bp
├── arm64
│ ├── include
│ ├── include_gen
│ └── lib
│ ├── libc.so
│ └── libdl.so
├── include
│ └── bionic
│ └── libc
│ └── include
│ ├── alloca.h
│ ├── android
│ │ ├── api-level.h
<omitted>
Change-Id: Ia1dcc5564c1cd17c6ccf441d06d5995af55db9ee
diff --git a/sdk/sdk.go b/sdk/sdk.go
index d189043..002fb5d 100644
--- a/sdk/sdk.go
+++ b/sdk/sdk.go
@@ -24,6 +24,7 @@
// This package doesn't depend on the apex package, but import it to make its mutators to be
// registered before mutators in this package. See RegisterPostDepsMutators for more details.
_ "android/soong/apex"
+ "android/soong/cc"
)
func init() {
@@ -148,10 +149,17 @@
targets := mctx.MultiTargets()
for _, target := range targets {
- mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
- {Mutator: "image", Variation: "core"},
- {Mutator: "link", Variation: "shared"},
- }...), sdkMemberDepTag, m.properties.Native_shared_libs...)
+ for _, lib := range m.properties.Native_shared_libs {
+ name, version := cc.StubsLibNameAndVersion(lib)
+ if version == "" {
+ version = cc.LatestStubsVersionFor(mctx.Config(), name)
+ }
+ mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
+ {Mutator: "image", Variation: "core"},
+ {Mutator: "link", Variation: "shared"},
+ {Mutator: "version", Variation: version},
+ }...), sdkMemberDepTag, name)
+ }
}
}
}