install *.so in different paths for their types
Shared libraries are now installed to different directories depending on their types. * NDK libraries: /system/lib/ndk * VNDK libraries: /system/lib/vndk * VNDK-ext libraries: /system/lib/vndk-ext * Framework-only libraries: /system/lib * Vendor-only libraries: /vendor/lib * Same-process HALs: /vendor/lib/sameprocess In addition, a new module type vndk_ext_library is added. It is almost identical to cc_shared_library but it introduces another attribute 'extends'. This is use to reference the vndk library that this vndk-ext library is extending. For example, in order to extend a vndk library libFoo: cc_library { name: "libFoo", srcs: [...] } --------------------- vndk_ext_library { name: "libFoo-extended", srcs: [...] extends: "libFoo" } Then, libFoo will be installed as /system/lib/vndk/libFoo.so and libFoo-extended will be installed as /system/lib/vndk-ext/libFoo.so. Note that file name of the latter is libFoo.so, not libFoo-extended.so: file name of an extending module is automatically set to that of the extended module. Bug: 33681361 Test: build & run. Libraries must be in the correct directories. Change-Id: Ia1eb3940605d582a252c78da0f3a5b36fdab062b
This commit is contained in:
@@ -145,6 +145,8 @@ bootstrap_go_package {
|
|||||||
"cc/ndk_headers.go",
|
"cc/ndk_headers.go",
|
||||||
"cc/ndk_library.go",
|
"cc/ndk_library.go",
|
||||||
"cc/ndk_sysroot.go",
|
"cc/ndk_sysroot.go",
|
||||||
|
|
||||||
|
"cc/vndk_library.go",
|
||||||
],
|
],
|
||||||
testSrcs: [
|
testSrcs: [
|
||||||
"cc/cc_test.go",
|
"cc/cc_test.go",
|
||||||
|
@@ -496,3 +496,7 @@ func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
|
|||||||
}
|
}
|
||||||
return coverage
|
return coverage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *deviceConfig) SameProcessHalDeps() []string {
|
||||||
|
return append([]string(nil), c.config.ProductVariables.SameProcessHalDeps...)
|
||||||
|
}
|
||||||
|
@@ -135,6 +135,8 @@ type productVariables struct {
|
|||||||
ArtUseReadBarrier *bool `json:",omitempty"`
|
ArtUseReadBarrier *bool `json:",omitempty"`
|
||||||
|
|
||||||
BtConfigIncludeDir *string `json:",omitempty"`
|
BtConfigIncludeDir *string `json:",omitempty"`
|
||||||
|
|
||||||
|
SameProcessHalDeps []string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func boolPtr(v bool) *bool {
|
func boolPtr(v bool) *bool {
|
||||||
|
@@ -156,6 +156,14 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (vndkLibrary *vndkExtLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
||||||
|
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
|
||||||
|
fmt.Fprintln(w, "LOCAL_EXTENDS_MODULE := ", vndkLibrary.properties.Extends)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
vndkLibrary.libraryDecorator.AndroidMk(ctx, ret)
|
||||||
|
}
|
||||||
|
|
||||||
func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
func (object *objectLinker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
||||||
ret.Custom = func(w io.Writer, name, prefix, moduleDir string) error {
|
ret.Custom = func(w io.Writer, name, prefix, moduleDir string) error {
|
||||||
out := ret.OutputFile.Path()
|
out := ret.OutputFile.Path()
|
||||||
|
15
cc/cc.go
15
cc/cc.go
@@ -162,6 +162,9 @@ type ModuleContextIntf interface {
|
|||||||
vndk() bool
|
vndk() bool
|
||||||
selectedStl() string
|
selectedStl() string
|
||||||
baseModuleName() string
|
baseModuleName() string
|
||||||
|
isNdk() bool
|
||||||
|
isVndk() bool
|
||||||
|
isSameProcessHal() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModuleContext interface {
|
type ModuleContext interface {
|
||||||
@@ -404,6 +407,18 @@ func (ctx *moduleContextImpl) baseModuleName() string {
|
|||||||
return ctx.mod.ModuleBase.BaseModuleName()
|
return ctx.mod.ModuleBase.BaseModuleName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *moduleContextImpl) isNdk() bool {
|
||||||
|
return inList(ctx.baseModuleName(), ndkPrebuiltSharedLibraries)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *moduleContextImpl) isVndk() bool {
|
||||||
|
return config.IsVndkLibrary(ctx.baseModuleName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *moduleContextImpl) isSameProcessHal() bool {
|
||||||
|
return inList(ctx.baseModuleName(), ctx.ctx.DeviceConfig().SameProcessHalDeps())
|
||||||
|
}
|
||||||
|
|
||||||
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
|
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
|
||||||
return &Module{
|
return &Module{
|
||||||
hod: hod,
|
hod: hod,
|
||||||
|
@@ -176,3 +176,11 @@ func bionicHeaders(bionicArch, kernelArch string) string {
|
|||||||
func VndkLibraries() []string {
|
func VndkLibraries() []string {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func VndkIndirectLibraries() []string {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsVndkLibrary(name string) bool {
|
||||||
|
return inList(name, VndkLibraries()) || inList(name, VndkIndirectLibraries())
|
||||||
|
}
|
||||||
|
@@ -47,6 +47,7 @@ type baseInstaller struct {
|
|||||||
|
|
||||||
dir string
|
dir string
|
||||||
dir64 string
|
dir64 string
|
||||||
|
subDir string
|
||||||
relative string
|
relative string
|
||||||
location installLocation
|
location installLocation
|
||||||
|
|
||||||
@@ -60,14 +61,14 @@ func (installer *baseInstaller) installerProps() []interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath {
|
func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath {
|
||||||
subDir := installer.dir
|
dir := installer.dir
|
||||||
if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
|
if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
|
||||||
subDir = installer.dir64
|
dir = installer.dir64
|
||||||
}
|
}
|
||||||
if !ctx.Host() && !ctx.Arch().Native {
|
if !ctx.Host() && !ctx.Arch().Native {
|
||||||
subDir = filepath.Join(subDir, ctx.Arch().ArchType.String())
|
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
||||||
}
|
}
|
||||||
return android.PathForModuleInstall(ctx, subDir, installer.Properties.Relative_install_path, installer.relative)
|
return android.PathForModuleInstall(ctx, dir, installer.subDir, installer.Properties.Relative_install_path, installer.relative)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
|
func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
|
||||||
|
@@ -587,6 +587,26 @@ func (library *libraryDecorator) toc() android.OptionalPath {
|
|||||||
|
|
||||||
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
|
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
|
||||||
if !ctx.static() {
|
if !ctx.static() {
|
||||||
|
if ctx.Device() {
|
||||||
|
if ctx.isNdk() {
|
||||||
|
library.baseInstaller.subDir = "ndk"
|
||||||
|
if ctx.Proprietary() {
|
||||||
|
ctx.ModuleErrorf("NDK library must not be proprietary")
|
||||||
|
}
|
||||||
|
} else if ctx.isVndk() {
|
||||||
|
library.baseInstaller.subDir = "vndk"
|
||||||
|
if ctx.Proprietary() {
|
||||||
|
ctx.ModuleErrorf("VNDK library must not be proprietary")
|
||||||
|
}
|
||||||
|
} else if ctx.isSameProcessHal() {
|
||||||
|
library.baseInstaller.subDir = "sameprocess"
|
||||||
|
if !ctx.Proprietary() {
|
||||||
|
ctx.ModuleErrorf("SameProcess HAL library must be proprietary")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Do nothing for other types of lib
|
||||||
|
}
|
||||||
|
}
|
||||||
library.baseInstaller.install(ctx, file)
|
library.baseInstaller.install(ctx, file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||||||
ctx.Strict("BOARD_VNDK_VERSION", "")
|
ctx.Strict("BOARD_VNDK_VERSION", "")
|
||||||
}
|
}
|
||||||
ctx.Strict("VNDK_LIBRARIES", strings.Join(config.VndkLibraries(), " "))
|
ctx.Strict("VNDK_LIBRARIES", strings.Join(config.VndkLibraries(), " "))
|
||||||
|
ctx.Strict("VNDK_INDIRECT_LIBRARIES", strings.Join(config.VndkIndirectLibraries(), " "))
|
||||||
|
|
||||||
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", asanCflags)
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS", asanCflags)
|
||||||
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
|
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
|
||||||
|
85
cc/vndk_library.go
Normal file
85
cc/vndk_library.go
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
// Copyright 2017 Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package cc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/google/blueprint"
|
||||||
|
|
||||||
|
"android/soong/android"
|
||||||
|
"android/soong/cc/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type vndkExtLibraryProperties struct {
|
||||||
|
// Name of the VNDK library module that this VNDK-ext library is extending.
|
||||||
|
// This library will have the same file name and soname as the original VNDK
|
||||||
|
// library, but will be installed in /system/lib/vndk-ext rather
|
||||||
|
// than /system/lib/vndk.
|
||||||
|
Extends string
|
||||||
|
}
|
||||||
|
|
||||||
|
type vndkExtLibraryDecorator struct {
|
||||||
|
*libraryDecorator
|
||||||
|
|
||||||
|
properties vndkExtLibraryProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
android.RegisterModuleType("vndk_ext_library", vndkExtLibraryFactory)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (deco *vndkExtLibraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||||
|
extends := deco.properties.Extends
|
||||||
|
if extends != "" {
|
||||||
|
if config.IsVndkLibrary(extends) {
|
||||||
|
// TODO(jiyong): ensure that the module referenced by 'extends' exists. Don't know how...
|
||||||
|
// Adding a dependency was not successful because it leads to circular dependency
|
||||||
|
// in between this and the 'extends' module.
|
||||||
|
// Ideally, this should be something like follows:
|
||||||
|
// otherCtx = findModuleByName(deco.properties.Extends)
|
||||||
|
// if otherCtx != nil && otherCtx.isVndk() {
|
||||||
|
// deco.libaryDecorator.libName = otherCtx.getBaseName()
|
||||||
|
// }
|
||||||
|
deco.libraryDecorator.libName = extends
|
||||||
|
} else {
|
||||||
|
ctx.PropertyErrorf("extends", "%s should be a VNDK or VNDK-indirect library", extends)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ctx.PropertyErrorf("extends", "missing. A VNDK-ext library must extend existing VNDK library")
|
||||||
|
}
|
||||||
|
return deco.libraryDecorator.linkerFlags(ctx, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (deco *vndkExtLibraryDecorator) install(ctx ModuleContext, file android.Path) {
|
||||||
|
deco.libraryDecorator.baseInstaller.subDir = "vndk-ext"
|
||||||
|
deco.libraryDecorator.baseInstaller.install(ctx, file)
|
||||||
|
}
|
||||||
|
|
||||||
|
func vndkExtLibraryFactory() (blueprint.Module, []interface{}) {
|
||||||
|
module, library := NewLibrary(android.DeviceSupported)
|
||||||
|
library.BuildOnlyShared()
|
||||||
|
|
||||||
|
_, props := module.Init()
|
||||||
|
|
||||||
|
deco := &vndkExtLibraryDecorator{
|
||||||
|
libraryDecorator: library,
|
||||||
|
}
|
||||||
|
|
||||||
|
module.installer = deco
|
||||||
|
module.linker = deco
|
||||||
|
|
||||||
|
props = append(props, &deco.properties)
|
||||||
|
|
||||||
|
return module, props
|
||||||
|
}
|
Reference in New Issue
Block a user