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
}
diff --git a/cc/library.go b/cc/library.go
index 1943e89..19a0787 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -158,6 +158,10 @@
// listed in local_include_dirs.
Export_include_dirs []string `android:"arch_variant"`
+ // list of directories that will be added to the system include path
+ // using -isystem for this module and any module that links against this module.
+ Export_system_include_dirs []string `android:"arch_variant"`
+
Target struct {
Vendor struct {
// list of exported include directories, like
@@ -245,10 +249,13 @@
func (f *flagExporter) exportIncludes(ctx ModuleContext) {
f.dirs = append(f.dirs, f.exportedIncludes(ctx)...)
+ f.systemDirs = append(f.systemDirs, android.PathsForModuleSrc(ctx, f.Properties.Export_system_include_dirs)...)
}
func (f *flagExporter) exportIncludesAsSystem(ctx ModuleContext) {
+ // all dirs are force exported as system
f.systemDirs = append(f.systemDirs, f.exportedIncludes(ctx)...)
+ f.systemDirs = append(f.systemDirs, android.PathsForModuleSrc(ctx, f.Properties.Export_system_include_dirs)...)
}
func (f *flagExporter) reexportDirs(dirs ...android.Path) {
@@ -1280,7 +1287,7 @@
var stubsVersionsLock sync.Mutex
-func latestStubsVersionFor(config android.Config, name string) string {
+func LatestStubsVersionFor(config android.Config, name string) string {
versions, ok := stubsVersionsFor(config)[name]
if ok && len(versions) > 0 {
// the versions are alreay sorted in ascending order