List of VNDK-related libs are exported to make

LL-NDK, VNDK-core, VNDK-SP libraries are exported to make as
SOONG_LLNDK_LIBRARIES, SOONG_VNDK_CORE_LIBRARIES, and
SOONG_VNDK_SAMEPROCESS_LIBRARIES. This can be used to auto-generate
ld.config.txt from a template.

Bug: 64013660
Test: BOARD_VNDK_VERSION=current m -j successful
Test: check out/soong/make_vars*.mk and look for SOONG_*_LIBRARIES

Merged-In: I0f4c5d05d9cd28c3fc9fdcca6ce0e6eaeaacbe8d
Change-Id: I0f4c5d05d9cd28c3fc9fdcca6ce0e6eaeaacbe8d
(cherry picked from commit d5b18a55bb)
This commit is contained in:
Jiyong Park 2017-08-03 21:22:50 +09:00 committed by Colin Cross
parent 2b3cb9cd39
commit ab0fd5f060
7 changed files with 55 additions and 17 deletions

View file

@ -35,6 +35,7 @@ func init() {
android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("link", linkageMutator).Parallel()
ctx.BottomUp("vndk", vndkMutator).Parallel()
ctx.BottomUp("image", vendorMutator).Parallel()
ctx.BottomUp("ndk_api", ndkApiMutator).Parallel()
ctx.BottomUp("test_per_src", testPerSrcMutator).Parallel()
@ -464,7 +465,7 @@ func (ctx *moduleContextImpl) isVndkSp() bool {
// Create source abi dumps if the module belongs to the list of VndkLibraries.
func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool {
return ctx.ctx.Device() && (ctx.mod.isVndk() || inList(ctx.baseModuleName(), config.LLndkLibraries()))
return ctx.ctx.Device() && (ctx.mod.isVndk() || inList(ctx.baseModuleName(), llndkLibraries))
}
func (ctx *moduleContextImpl) selectedStl() string {
@ -762,7 +763,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
} else {
variantLibs = append(variantLibs, entry+ndkLibrarySuffix)
}
} else if ctx.vndk() && inList(entry, config.LLndkLibraries()) {
} else if ctx.vndk() && inList(entry, llndkLibraries) {
nonvariantLibs = append(nonvariantLibs, entry+llndkLibrarySuffix)
} else {
nonvariantLibs = append(nonvariantLibs, entry)
@ -1126,7 +1127,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
case sharedDepTag, sharedExportDepTag, lateSharedDepTag:
libName := strings.TrimSuffix(name, llndkLibrarySuffix)
libName = strings.TrimPrefix(libName, "prebuilt_")
isLLndk := inList(libName, config.LLndkLibraries())
isLLndk := inList(libName, llndkLibraries)
if c.vndk() && (Bool(cc.Properties.Vendor_available) || isLLndk) {
libName += vendorSuffix
}

View file

@ -191,17 +191,6 @@ func bionicHeaders(bionicArch, kernelArch string) string {
}, " ")
}
func VndkLibraries() []string {
return []string{}
}
// This needs to be kept up to date with the list in system/core/rootdir/etc/ld.config.txt:
// [vendor]
// namespace.default.link.system.shared_libs
func LLndkLibraries() []string {
return []string{"libc", "libm", "libdl", "liblog", "libandroid_net", "ld-android"}
}
func replaceFirst(slice []string, from, to string) {
if slice[0] != from {
panic(fmt.Errorf("Expected %q, found %q", from, to))

View file

@ -21,7 +21,6 @@ import (
"github.com/google/blueprint/pathtools"
"android/soong/android"
"android/soong/cc/config"
)
type LibraryProperties struct {
@ -621,7 +620,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
}
func vndkVsNdk(ctx ModuleContext) bool {
if inList(ctx.baseModuleName(), config.LLndkLibraries()) {
if inList(ctx.baseModuleName(), llndkLibraries) {
return false
}
return true

View file

@ -59,6 +59,10 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("BOARD_VNDK_VERSION", "")
}
ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(vndkCoreLibraries, " "))
ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(vndkSpLibraries, " "))
ctx.Strict("LLNDK_LIBRARIES", strings.Join(llndkLibraries, " "))
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", strings.Join(asanCflags, " "))
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", strings.Join(asanLdflags, " "))
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES", strings.Join(asanLibs, " "))

View file

@ -79,7 +79,7 @@ func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags {
func sabiDepsMutator(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok &&
(c.isVndk() || inList(c.Name(), config.LLndkLibraries()) ||
(c.isVndk() || inList(c.Name(), llndkLibraries) ||
(c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) {
mctx.VisitDirectDeps(func(m blueprint.Module) {
tag := mctx.OtherModuleDependencyTag(m)

View file

@ -131,3 +131,10 @@ func addPrefix(list []string, prefix string) []string {
}
return list
}
func addSuffix(list []string, suffix string) []string {
for i := range list {
list[i] = list[i] + suffix
}
return list
}

View file

@ -15,6 +15,9 @@
package cc
import (
"strings"
"sync"
"android/soong/android"
)
@ -96,3 +99,38 @@ func (vndk *vndkdep) vndkCheckLinkType(ctx android.ModuleContext, to *Module) {
return
}
}
var (
vndkCoreLibraries []string
vndkSpLibraries []string
llndkLibraries []string
vndkLibrariesLock sync.Mutex
)
// gather list of vndk-core, vndk-sp, and ll-ndk libs
func vndkMutator(mctx android.BottomUpMutatorContext) {
if m, ok := mctx.Module().(*Module); ok {
if _, ok := m.linker.(*llndkStubDecorator); ok {
vndkLibrariesLock.Lock()
defer vndkLibrariesLock.Unlock()
name := strings.TrimSuffix(m.Name(), llndkLibrarySuffix)
if !inList(name, llndkLibraries) {
llndkLibraries = append(llndkLibraries, name)
}
} else if lib, ok := m.linker.(*libraryDecorator); ok && lib.shared() {
if m.vndkdep.isVndk() {
vndkLibrariesLock.Lock()
defer vndkLibrariesLock.Unlock()
if m.vndkdep.isVndkSp() {
if !inList(m.Name(), vndkSpLibraries) {
vndkSpLibraries = append(vndkSpLibraries, m.Name())
}
} else {
if !inList(m.Name(), vndkCoreLibraries) {
vndkCoreLibraries = append(vndkCoreLibraries, m.Name())
}
}
}
}
}
}