Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 17:23:01 +08:00
|
|
|
// Copyright 2018 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 (
|
|
|
|
"strings"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
vendorPublicLibrarySuffix = ".vendorpublic"
|
|
|
|
|
2019-05-09 09:56:13 +08:00
|
|
|
vendorPublicLibrariesKey = android.NewOnceKey("vendorPublicLibraries")
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 17:23:01 +08:00
|
|
|
vendorPublicLibrariesLock sync.Mutex
|
|
|
|
)
|
|
|
|
|
2019-05-09 09:56:13 +08:00
|
|
|
func vendorPublicLibraries(config android.Config) *[]string {
|
|
|
|
return config.Once(vendorPublicLibrariesKey, func() interface{} {
|
|
|
|
return &[]string{}
|
|
|
|
}).(*[]string)
|
|
|
|
}
|
|
|
|
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 17:23:01 +08:00
|
|
|
// Creates a stub shared library for a vendor public library. Vendor public libraries
|
|
|
|
// are vendor libraries (owned by them and installed to /vendor partition) that are
|
|
|
|
// exposed to Android apps via JNI. The libraries are made public by being listed in
|
|
|
|
// /vendor/etc/public.libraries.txt.
|
|
|
|
//
|
|
|
|
// This stub library is a build-time only artifact that provides symbols that are
|
|
|
|
// exposed from a vendor public library.
|
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
//
|
|
|
|
// vendor_public_library {
|
|
|
|
// name: "libfoo",
|
|
|
|
// symbol_file: "libfoo.map.txt",
|
|
|
|
// export_public_headers: ["libfoo_headers"],
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// cc_headers {
|
|
|
|
// name: "libfoo_headers",
|
|
|
|
// export_include_dirs: ["include"],
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
type vendorPublicLibraryProperties struct {
|
|
|
|
// Relative path to the symbol map.
|
|
|
|
Symbol_file *string
|
|
|
|
|
|
|
|
// Whether the system library uses symbol versions.
|
|
|
|
Unversioned *bool
|
|
|
|
|
|
|
|
// list of header libs to re-export include directories from.
|
|
|
|
Export_public_headers []string `android:"arch_variant"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type vendorPublicLibraryStubDecorator struct {
|
|
|
|
*libraryDecorator
|
|
|
|
|
|
|
|
Properties vendorPublicLibraryProperties
|
|
|
|
|
|
|
|
versionScriptPath android.ModuleGenPath
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *vendorPublicLibraryStubDecorator) Name(name string) string {
|
|
|
|
return name + vendorPublicLibrarySuffix
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *vendorPublicLibraryStubDecorator) compilerInit(ctx BaseModuleContext) {
|
|
|
|
stub.baseCompiler.compilerInit(ctx)
|
|
|
|
|
|
|
|
name := ctx.baseModuleName()
|
|
|
|
if strings.HasSuffix(name, vendorPublicLibrarySuffix) {
|
|
|
|
ctx.PropertyErrorf("name", "Do not append %q manually, just use the base name", vendorPublicLibrarySuffix)
|
|
|
|
}
|
|
|
|
|
|
|
|
vendorPublicLibrariesLock.Lock()
|
|
|
|
defer vendorPublicLibrariesLock.Unlock()
|
2019-05-09 09:56:13 +08:00
|
|
|
vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
|
|
|
|
for _, lib := range *vendorPublicLibraries {
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 17:23:01 +08:00
|
|
|
if lib == name {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2019-05-09 09:56:13 +08:00
|
|
|
*vendorPublicLibraries = append(*vendorPublicLibraries, name)
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 17:23:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *vendorPublicLibraryStubDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags {
|
|
|
|
flags = stub.baseCompiler.compilerFlags(ctx, flags, deps)
|
|
|
|
return addStubLibraryCompilerFlags(flags)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *vendorPublicLibraryStubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
|
|
|
objs, versionScript := compileStubLibrary(ctx, flags, String(stub.Properties.Symbol_file), "current", "")
|
|
|
|
stub.versionScriptPath = versionScript
|
|
|
|
return objs
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *vendorPublicLibraryStubDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
|
|
|
headers := stub.Properties.Export_public_headers
|
|
|
|
deps.HeaderLibs = append(deps.HeaderLibs, headers...)
|
|
|
|
deps.ReexportHeaderLibHeaders = append(deps.ReexportHeaderLibHeaders, headers...)
|
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *vendorPublicLibraryStubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
|
|
|
stub.libraryDecorator.libName = strings.TrimSuffix(ctx.ModuleName(), vendorPublicLibrarySuffix)
|
|
|
|
return stub.libraryDecorator.linkerFlags(ctx, flags)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *vendorPublicLibraryStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
|
|
|
|
objs Objects) android.Path {
|
|
|
|
if !Bool(stub.Properties.Unversioned) {
|
|
|
|
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
|
2019-11-05 01:37:55 +08:00
|
|
|
flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag)
|
2019-06-11 09:02:25 +08:00
|
|
|
flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 17:23:01 +08:00
|
|
|
}
|
|
|
|
return stub.libraryDecorator.link(ctx, flags, deps, objs)
|
|
|
|
}
|
|
|
|
|
2019-04-04 05:37:46 +08:00
|
|
|
// vendor_public_library creates a stub shared library for a vendor public
|
|
|
|
// library. This stub library is a build-time only artifact that provides
|
|
|
|
// symbols that are exposed from a vendor public library. Example:
|
|
|
|
//
|
|
|
|
// vendor_public_library {
|
|
|
|
// name: "libfoo",
|
|
|
|
// symbol_file: "libfoo.map.txt",
|
|
|
|
// export_public_headers: ["libfoo_headers"],
|
|
|
|
// }
|
Allow platform modules to link to vendor public libraries
Normally, when building with VNDK, platform modules are not allowed to
link against vendor libraries, because the ABI of the vendor libraries
are not guaranteed to be stable and may differ across multiple vendor
images.
However, the vendor public libraries are the exceptions. Vendor public
libraries are vendor libraries that are exposed to 3rd party apps and
listed in /vendor/etc/public.libraries.txt. Since they are intended to
be exposed to public, their ABI stability is guaranteed (by definition,
though it is up to the vendor to actually guarantee it).
This change provides a way to make a vendor lib as public by defining a
module of type 'vendor_public_library' with a map file that enumerates
public symbols that are publicized:
cc_library {
name: "libvendor",
proprietary: true,
...
}
vendor_public_library {
name: "libvendor",
symbol_file: "libvendor.map.txt",
}
This defines a stub library module named libvendor.vendorpublic from the
map file. `shared_libs: ["libvendor"]` is redirected to the stub library
when it is from the outside of the vendor partition.
Bug: 74275385
Test: m -j
Test: cc_test.go passes
Change-Id: I5bed94d7c4282b777632ab2f0fb63c203ee313ba
2018-03-19 17:23:01 +08:00
|
|
|
func vendorPublicLibraryFactory() android.Module {
|
|
|
|
module, library := NewLibrary(android.DeviceSupported)
|
|
|
|
library.BuildOnlyShared()
|
|
|
|
module.stl = nil
|
|
|
|
module.sanitize = nil
|
|
|
|
library.StripProperties.Strip.None = BoolPtr(true)
|
|
|
|
|
|
|
|
stub := &vendorPublicLibraryStubDecorator{
|
|
|
|
libraryDecorator: library,
|
|
|
|
}
|
|
|
|
module.compiler = stub
|
|
|
|
module.linker = stub
|
|
|
|
module.installer = nil
|
|
|
|
|
|
|
|
module.AddProperties(
|
|
|
|
&stub.Properties,
|
|
|
|
&library.MutatedProperties,
|
|
|
|
&library.flagExporter.Properties)
|
|
|
|
|
|
|
|
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
android.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
|
|
|
|
}
|