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/cc/cc.go b/cc/cc.go
index 67132e4..5d41400 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -689,6 +689,27 @@
return c.linker != nil && c.linker.nativeCoverage()
}
+func (c *Module) ExportedIncludeDirs() android.Paths {
+ if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
+ return flagsProducer.exportedDirs()
+ }
+ return []android.Path{}
+}
+
+func (c *Module) ExportedSystemIncludeDirs() android.Paths {
+ if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
+ return flagsProducer.exportedSystemDirs()
+ }
+ return []android.Path{}
+}
+
+func (c *Module) ExportedFlags() []string {
+ if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok {
+ return flagsProducer.exportedFlags()
+ }
+ return []string{}
+}
+
func isBionic(name string) bool {
switch name {
case "libc", "libm", "libdl", "linker":
@@ -1290,7 +1311,7 @@
}
// Split name#version into name and version
-func stubsLibNameAndVersion(name string) (string, string) {
+func StubsLibNameAndVersion(name string) (string, string) {
if sharp := strings.LastIndex(name, "#"); sharp != -1 && sharp != len(name)-1 {
version := name[sharp+1:]
libname := name[:sharp]
@@ -1337,7 +1358,7 @@
nonvariantLibs = []string{}
for _, entry := range list {
// strip #version suffix out
- name, _ := stubsLibNameAndVersion(entry)
+ name, _ := StubsLibNameAndVersion(entry)
if ctx.useSdk() && inList(name, ndkPrebuiltSharedLibraries) {
if !inList(name, ndkMigratedLibs) {
nonvariantLibs = append(nonvariantLibs, name+".ndk."+version)
@@ -1443,7 +1464,7 @@
// If the version is not specified, add dependency to the latest stubs library.
// The stubs library will be used when the depending module is built for APEX and
// the dependent module is not in the same APEX.
- latestVersion := latestStubsVersionFor(actx.Config(), name)
+ latestVersion := LatestStubsVersionFor(actx.Config(), name)
if version == "" && latestVersion != "" && versionVariantAvail {
actx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "shared"},
@@ -1466,7 +1487,7 @@
lib = impl
}
- name, version := stubsLibNameAndVersion(lib)
+ name, version := StubsLibNameAndVersion(lib)
sharedLibNames = append(sharedLibNames, name)
addSharedLibDependencies(depTag, name, version)
@@ -2142,7 +2163,9 @@
if shared, ok := c.linker.(interface {
shared() bool
}); ok {
- return shared.shared()
+ // Stub libs and prebuilt libs in a versioned SDK are not
+ // installable to APEX even though they are shared libs.
+ return shared.shared() && !c.IsStubs() && c.ContainingSdk().Unversioned()
} else if _, ok := c.linker.(testPerSrc); ok {
return true
}