2017-03-19 21:44:32 +01:00
|
|
|
// 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 (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
llndkLibrarySuffix = ".llndk"
|
2017-10-19 08:59:33 +02:00
|
|
|
llndkHeadersSuffix = ".llndk"
|
2017-03-19 21:44:32 +01:00
|
|
|
)
|
|
|
|
|
2020-12-17 01:46:01 +01:00
|
|
|
// Holds properties to describe a stub shared library based on the provided version file.
|
|
|
|
// The stub library will actually be built by the cc_library module that points to this
|
|
|
|
// module with the llndk_stubs property.
|
|
|
|
// TODO(ccross): move the properties from llndk_library modules directly into the cc_library
|
|
|
|
// modules and remove the llndk_library modules.
|
2017-03-19 21:44:32 +01:00
|
|
|
//
|
|
|
|
// Example:
|
|
|
|
//
|
|
|
|
// llndk_library {
|
2017-04-08 00:21:13 +02:00
|
|
|
// name: "libfoo",
|
2017-03-19 21:44:32 +01:00
|
|
|
// symbol_file: "libfoo.map.txt",
|
|
|
|
// export_include_dirs: ["include_vndk"],
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
type llndkLibraryProperties struct {
|
|
|
|
// Relative path to the symbol map.
|
|
|
|
// An example file can be seen here: TODO(danalbert): Make an example.
|
2017-11-07 19:57:05 +01:00
|
|
|
Symbol_file *string
|
2017-03-19 21:44:32 +01:00
|
|
|
|
|
|
|
// Whether to export any headers as -isystem instead of -I. Mainly for use by
|
|
|
|
// bionic/libc.
|
2017-11-07 19:57:05 +01:00
|
|
|
Export_headers_as_system *bool
|
2017-03-19 21:44:32 +01:00
|
|
|
|
|
|
|
// Which headers to process with versioner. This really only handles
|
|
|
|
// bionic/libc/include right now.
|
|
|
|
Export_preprocessed_headers []string
|
|
|
|
|
|
|
|
// Whether the system library uses symbol versions.
|
2017-11-07 19:57:05 +01:00
|
|
|
Unversioned *bool
|
2017-08-16 07:05:54 +02:00
|
|
|
|
2017-10-19 08:59:33 +02:00
|
|
|
// list of llndk headers to re-export include directories from.
|
|
|
|
Export_llndk_headers []string `android:"arch_variant"`
|
2020-12-17 01:46:01 +01:00
|
|
|
|
|
|
|
// whether this module can be directly depended upon by libs that are installed
|
|
|
|
// to /vendor and /product.
|
|
|
|
// When set to true, this module can only be depended on by VNDK libraries, not
|
|
|
|
// vendor nor product libraries. This effectively hides this module from
|
|
|
|
// non-system modules. Default value is false.
|
|
|
|
Private *bool
|
2017-03-19 21:44:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type llndkStubDecorator struct {
|
|
|
|
*libraryDecorator
|
|
|
|
|
|
|
|
Properties llndkLibraryProperties
|
|
|
|
}
|
|
|
|
|
2020-10-14 03:43:54 +02:00
|
|
|
var _ versionedInterface = (*llndkStubDecorator)(nil)
|
|
|
|
|
2017-11-16 23:33:08 +01:00
|
|
|
func (stub *llndkStubDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags {
|
2020-12-17 01:46:01 +01:00
|
|
|
return flags
|
2017-07-19 20:39:53 +02:00
|
|
|
}
|
|
|
|
|
2017-03-19 21:44:32 +01:00
|
|
|
func (stub *llndkStubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
2020-12-17 01:46:01 +01:00
|
|
|
return Objects{}
|
2017-03-19 21:44:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *llndkStubDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
2017-10-19 08:59:33 +02:00
|
|
|
return deps
|
2017-03-19 21:44:32 +01:00
|
|
|
}
|
|
|
|
|
2017-04-08 00:21:13 +02:00
|
|
|
func (stub *llndkStubDecorator) Name(name string) string {
|
2020-10-14 03:43:54 +02:00
|
|
|
if strings.HasSuffix(name, llndkLibrarySuffix) {
|
|
|
|
return name
|
|
|
|
}
|
2017-04-08 00:21:13 +02:00
|
|
|
return name + llndkLibrarySuffix
|
|
|
|
}
|
|
|
|
|
2021-01-06 23:07:27 +01:00
|
|
|
func (stub *llndkStubDecorator) linkerProps() []interface{} {
|
|
|
|
props := stub.libraryDecorator.linkerProps()
|
|
|
|
return append(props, &stub.Properties)
|
|
|
|
}
|
|
|
|
|
2017-03-19 21:44:32 +01:00
|
|
|
func (stub *llndkStubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
2020-10-14 03:43:54 +02:00
|
|
|
stub.libraryDecorator.libName = stub.implementationModuleName(ctx.ModuleName())
|
2017-03-19 21:44:32 +01:00
|
|
|
return stub.libraryDecorator.linkerFlags(ctx, flags)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
|
|
|
|
objs Objects) android.Path {
|
2020-12-17 01:46:01 +01:00
|
|
|
return nil
|
2017-03-19 21:44:32 +01:00
|
|
|
}
|
|
|
|
|
2019-03-25 18:21:31 +01:00
|
|
|
func (stub *llndkStubDecorator) nativeCoverage() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-10-14 03:43:54 +02:00
|
|
|
func (stub *llndkStubDecorator) implementationModuleName(name string) string {
|
|
|
|
return strings.TrimSuffix(name, llndkLibrarySuffix)
|
|
|
|
}
|
|
|
|
|
2020-09-29 02:32:47 +02:00
|
|
|
func (stub *llndkStubDecorator) buildStubs() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-11-14 12:53:00 +01:00
|
|
|
func NewLLndkStubLibrary() *Module {
|
2017-03-19 21:44:32 +01:00
|
|
|
module, library := NewLibrary(android.DeviceSupported)
|
|
|
|
module.stl = nil
|
|
|
|
module.sanitize = nil
|
2020-08-19 14:53:01 +02:00
|
|
|
library.disableStripping()
|
2017-03-19 21:44:32 +01:00
|
|
|
|
|
|
|
stub := &llndkStubDecorator{
|
|
|
|
libraryDecorator: library,
|
|
|
|
}
|
|
|
|
module.compiler = stub
|
|
|
|
module.linker = stub
|
|
|
|
module.installer = nil
|
2020-10-24 02:22:06 +02:00
|
|
|
module.library = stub
|
2017-03-19 21:44:32 +01:00
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
return module
|
2017-03-19 21:44:32 +01:00
|
|
|
}
|
|
|
|
|
2019-04-03 23:37:46 +02:00
|
|
|
// llndk_library creates a stub llndk shared library based on the provided
|
|
|
|
// version file. Example:
|
|
|
|
//
|
|
|
|
// llndk_library {
|
|
|
|
// name: "libfoo",
|
|
|
|
// symbol_file: "libfoo.map.txt",
|
|
|
|
// export_include_dirs: ["include_vndk"],
|
|
|
|
// }
|
2018-12-19 09:12:36 +01:00
|
|
|
func LlndkLibraryFactory() android.Module {
|
2017-11-14 12:53:00 +01:00
|
|
|
module := NewLLndkStubLibrary()
|
2021-01-06 23:07:27 +01:00
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
|
|
|
// isVestigialLLNDKModule returns true if m is a vestigial llndk_library module used to provide
|
|
|
|
// properties to the LLNDK variant of a cc_library.
|
|
|
|
func isVestigialLLNDKModule(m *Module) bool {
|
|
|
|
_, ok := m.linker.(*llndkStubDecorator)
|
|
|
|
return ok
|
2017-03-19 21:44:32 +01:00
|
|
|
}
|
|
|
|
|
2017-10-19 08:59:33 +02:00
|
|
|
type llndkHeadersDecorator struct {
|
|
|
|
*libraryDecorator
|
|
|
|
}
|
|
|
|
|
2019-04-03 23:37:46 +02:00
|
|
|
// llndk_headers contains a set of c/c++ llndk headers files which are imported
|
|
|
|
// by other soongs cc modules.
|
2017-10-19 08:59:33 +02:00
|
|
|
func llndkHeadersFactory() android.Module {
|
|
|
|
module, library := NewLibrary(android.DeviceSupported)
|
|
|
|
library.HeaderOnly()
|
2020-07-08 00:56:02 +02:00
|
|
|
module.stl = nil
|
|
|
|
module.sanitize = nil
|
2017-10-19 08:59:33 +02:00
|
|
|
|
|
|
|
decorator := &llndkHeadersDecorator{
|
|
|
|
libraryDecorator: library,
|
|
|
|
}
|
|
|
|
|
|
|
|
module.compiler = nil
|
|
|
|
module.linker = decorator
|
|
|
|
module.installer = nil
|
2020-10-24 02:22:06 +02:00
|
|
|
module.library = decorator
|
2017-10-19 08:59:33 +02:00
|
|
|
|
2019-04-17 06:12:10 +02:00
|
|
|
module.AddProperties(
|
|
|
|
&module.Properties,
|
|
|
|
&library.MutatedProperties,
|
|
|
|
&library.flagExporter.Properties)
|
2017-10-19 08:59:33 +02:00
|
|
|
|
2019-07-29 14:27:18 +02:00
|
|
|
module.Init()
|
2017-10-19 08:59:33 +02:00
|
|
|
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2017-03-19 21:44:32 +01:00
|
|
|
func init() {
|
2018-12-19 09:12:36 +01:00
|
|
|
android.RegisterModuleType("llndk_library", LlndkLibraryFactory)
|
2017-10-19 08:59:33 +02:00
|
|
|
android.RegisterModuleType("llndk_headers", llndkHeadersFactory)
|
2017-03-19 21:44:32 +01:00
|
|
|
}
|