2016-10-07 01:12:58 +02:00
|
|
|
// Copyright 2016 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 (
|
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2019-12-19 15:38:36 +01:00
|
|
|
RegisterPrebuiltBuildComponents(android.InitRegistrationContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RegisterPrebuiltBuildComponents(ctx android.RegistrationContext) {
|
2020-03-12 21:17:14 +01:00
|
|
|
ctx.RegisterModuleType("cc_prebuilt_library", PrebuiltLibraryFactory)
|
2019-12-19 15:38:36 +01:00
|
|
|
ctx.RegisterModuleType("cc_prebuilt_library_shared", PrebuiltSharedLibraryFactory)
|
|
|
|
ctx.RegisterModuleType("cc_prebuilt_library_static", PrebuiltStaticLibraryFactory)
|
2020-03-11 22:45:49 +01:00
|
|
|
ctx.RegisterModuleType("cc_prebuilt_object", prebuiltObjectFactory)
|
2019-12-19 15:38:36 +01:00
|
|
|
ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type prebuiltLinkerInterface interface {
|
|
|
|
Name(string) string
|
|
|
|
prebuilt() *android.Prebuilt
|
|
|
|
}
|
|
|
|
|
2019-03-28 03:09:10 +01:00
|
|
|
type prebuiltLinkerProperties struct {
|
|
|
|
|
|
|
|
// a prebuilt library or binary. Can reference a genrule module that generates an executable file.
|
|
|
|
Srcs []string `android:"path,arch_variant"`
|
|
|
|
|
|
|
|
// Check the prebuilt ELF files (e.g. DT_SONAME, DT_NEEDED, resolution of undefined
|
|
|
|
// symbols, etc), default true.
|
|
|
|
Check_elf_files *bool
|
cc_prebuilt_library respect module name and stem
Installed name of prebuilt shared library should be stem or module name.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libbar.so"],
}
should install with the filename libfoo.so, and
cc_prebuilt_library_shared {
name: "libfoo",
stem: "libbaz",
srcs: ["libbar.so"],
}
should install with the filename libbaz.so.
Prebuilt Windows PE library should specify its import library.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libfoo.dll"],
windows_import_lib: "libfoo.lib",
enabled: false,
target: {
windows: {
enabled: true,
},
},
}
Bug: 151744695
Test: prebuilt_test.go && built walleye-userdebug
Change-Id: Ia8d0afb7fa46783c670870440432779c5fc7321a
2020-03-18 07:19:07 +01:00
|
|
|
|
|
|
|
// Optionally provide an import library if this is a Windows PE DLL prebuilt.
|
|
|
|
// This is needed only if this library is linked by other modules in build time.
|
|
|
|
// Only makes sense for the Windows target.
|
|
|
|
Windows_import_lib *string `android:"path,arch_variant"`
|
2019-03-28 03:09:10 +01:00
|
|
|
}
|
|
|
|
|
2017-03-17 21:28:06 +01:00
|
|
|
type prebuiltLinker struct {
|
2016-10-07 01:12:58 +02:00
|
|
|
android.Prebuilt
|
2018-11-20 04:59:08 +01:00
|
|
|
|
2019-03-28 03:09:10 +01:00
|
|
|
properties prebuiltLinkerProperties
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
|
|
|
|
2017-03-17 21:28:06 +01:00
|
|
|
func (p *prebuiltLinker) prebuilt() *android.Prebuilt {
|
2016-10-07 01:12:58 +02:00
|
|
|
return &p.Prebuilt
|
|
|
|
}
|
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
func (p *prebuiltLinker) PrebuiltSrcs() []string {
|
|
|
|
return p.properties.Srcs
|
|
|
|
}
|
|
|
|
|
2019-05-14 23:07:01 +02:00
|
|
|
type prebuiltLibraryInterface interface {
|
|
|
|
libraryInterface
|
|
|
|
prebuiltLinkerInterface
|
|
|
|
disablePrebuilt()
|
|
|
|
}
|
|
|
|
|
2017-03-17 21:28:06 +01:00
|
|
|
type prebuiltLibraryLinker struct {
|
|
|
|
*libraryDecorator
|
|
|
|
prebuiltLinker
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ prebuiltLinkerInterface = (*prebuiltLibraryLinker)(nil)
|
2019-05-14 23:07:01 +02:00
|
|
|
var _ prebuiltLibraryInterface = (*prebuiltLibraryLinker)(nil)
|
2017-03-17 21:28:06 +01:00
|
|
|
|
2018-08-14 01:02:49 +02:00
|
|
|
func (p *prebuiltLibraryLinker) linkerInit(ctx BaseModuleContext) {}
|
|
|
|
|
|
|
|
func (p *prebuiltLibraryLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
2019-01-14 08:35:08 +01:00
|
|
|
return p.libraryDecorator.linkerDeps(ctx, deps)
|
2018-08-14 01:02:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *prebuiltLibraryLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
2018-09-04 20:02:37 +02:00
|
|
|
return flags
|
2018-08-14 01:02:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *prebuiltLibraryLinker) linkerProps() []interface{} {
|
|
|
|
return p.libraryDecorator.linkerProps()
|
|
|
|
}
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
|
2016-09-27 02:33:01 +02:00
|
|
|
flags Flags, deps PathDeps, objs Objects) android.Path {
|
2020-02-21 11:57:00 +01:00
|
|
|
|
|
|
|
p.libraryDecorator.exportIncludes(ctx)
|
|
|
|
p.libraryDecorator.reexportDirs(deps.ReexportedDirs...)
|
|
|
|
p.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...)
|
|
|
|
p.libraryDecorator.reexportFlags(deps.ReexportedFlags...)
|
|
|
|
p.libraryDecorator.reexportDeps(deps.ReexportedDeps...)
|
|
|
|
p.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
|
|
|
|
|
2016-10-07 01:12:58 +02:00
|
|
|
// TODO(ccross): verify shared library dependencies
|
2020-03-12 21:17:14 +01:00
|
|
|
srcs := p.prebuiltSrcs()
|
|
|
|
if len(srcs) > 0 {
|
2018-09-05 23:20:03 +02:00
|
|
|
builderFlags := flagsToBuilderFlags(flags)
|
|
|
|
|
2020-03-12 21:17:14 +01:00
|
|
|
if len(srcs) > 1 {
|
|
|
|
ctx.PropertyErrorf("srcs", "multiple prebuilt source files")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
in := android.PathForModuleSrc(ctx, srcs[0])
|
2018-09-05 23:20:03 +02:00
|
|
|
|
cc_prebuilt_library respect module name and stem
Installed name of prebuilt shared library should be stem or module name.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libbar.so"],
}
should install with the filename libfoo.so, and
cc_prebuilt_library_shared {
name: "libfoo",
stem: "libbaz",
srcs: ["libbar.so"],
}
should install with the filename libbaz.so.
Prebuilt Windows PE library should specify its import library.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libfoo.dll"],
windows_import_lib: "libfoo.lib",
enabled: false,
target: {
windows: {
enabled: true,
},
},
}
Bug: 151744695
Test: prebuilt_test.go && built walleye-userdebug
Change-Id: Ia8d0afb7fa46783c670870440432779c5fc7321a
2020-03-18 07:19:07 +01:00
|
|
|
if p.static() {
|
|
|
|
return in
|
|
|
|
}
|
|
|
|
|
2018-09-05 23:20:03 +02:00
|
|
|
if p.shared() {
|
2018-09-05 01:28:17 +02:00
|
|
|
p.unstrippedOutputFile = in
|
2019-08-16 23:22:10 +02:00
|
|
|
libName := p.libraryDecorator.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
|
cc_prebuilt_library respect module name and stem
Installed name of prebuilt shared library should be stem or module name.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libbar.so"],
}
should install with the filename libfoo.so, and
cc_prebuilt_library_shared {
name: "libfoo",
stem: "libbaz",
srcs: ["libbar.so"],
}
should install with the filename libbaz.so.
Prebuilt Windows PE library should specify its import library.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libfoo.dll"],
windows_import_lib: "libfoo.lib",
enabled: false,
target: {
windows: {
enabled: true,
},
},
}
Bug: 151744695
Test: prebuilt_test.go && built walleye-userdebug
Change-Id: Ia8d0afb7fa46783c670870440432779c5fc7321a
2020-03-18 07:19:07 +01:00
|
|
|
outputFile := android.PathForModuleOut(ctx, libName)
|
|
|
|
var implicits android.Paths
|
|
|
|
|
2018-09-05 23:20:03 +02:00
|
|
|
if p.needsStrip(ctx) {
|
|
|
|
stripped := android.PathForModuleOut(ctx, "stripped", libName)
|
2019-05-31 05:53:29 +02:00
|
|
|
p.stripExecutableOrSharedLib(ctx, in, stripped, builderFlags)
|
2018-09-05 23:20:03 +02:00
|
|
|
in = stripped
|
|
|
|
}
|
|
|
|
|
2018-09-05 01:28:17 +02:00
|
|
|
// Optimize out relinking against shared libraries whose interface hasn't changed by
|
|
|
|
// depending on a table of contents file instead of the library itself.
|
|
|
|
tocFile := android.PathForModuleOut(ctx, libName+".toc")
|
|
|
|
p.tocFile = android.OptionalPathForPath(tocFile)
|
cc_prebuilt_library respect module name and stem
Installed name of prebuilt shared library should be stem or module name.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libbar.so"],
}
should install with the filename libfoo.so, and
cc_prebuilt_library_shared {
name: "libfoo",
stem: "libbaz",
srcs: ["libbar.so"],
}
should install with the filename libbaz.so.
Prebuilt Windows PE library should specify its import library.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libfoo.dll"],
windows_import_lib: "libfoo.lib",
enabled: false,
target: {
windows: {
enabled: true,
},
},
}
Bug: 151744695
Test: prebuilt_test.go && built walleye-userdebug
Change-Id: Ia8d0afb7fa46783c670870440432779c5fc7321a
2020-03-18 07:19:07 +01:00
|
|
|
TransformSharedObjectToToc(ctx, outputFile, tocFile, builderFlags)
|
|
|
|
|
|
|
|
if ctx.Windows() && p.properties.Windows_import_lib != nil {
|
|
|
|
// Consumers of this library actually links to the import library in build
|
|
|
|
// time and dynamically links to the DLL in run time. i.e.
|
|
|
|
// a.exe <-- static link --> foo.lib <-- dynamic link --> foo.dll
|
|
|
|
importLibSrc := android.PathForModuleSrc(ctx, String(p.properties.Windows_import_lib))
|
|
|
|
importLibName := p.libraryDecorator.getLibName(ctx) + ".lib"
|
|
|
|
importLibOutputFile := android.PathForModuleOut(ctx, importLibName)
|
|
|
|
implicits = append(implicits, importLibOutputFile)
|
|
|
|
|
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.Cp,
|
|
|
|
Description: "prebuilt import library",
|
|
|
|
Input: importLibSrc,
|
|
|
|
Output: importLibOutputFile,
|
|
|
|
Args: map[string]string{
|
|
|
|
"cpFlags": "-L",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2018-09-05 23:20:03 +02:00
|
|
|
|
cc_prebuilt_library respect module name and stem
Installed name of prebuilt shared library should be stem or module name.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libbar.so"],
}
should install with the filename libfoo.so, and
cc_prebuilt_library_shared {
name: "libfoo",
stem: "libbaz",
srcs: ["libbar.so"],
}
should install with the filename libbaz.so.
Prebuilt Windows PE library should specify its import library.
For example:
cc_prebuilt_library_shared {
name: "libfoo",
srcs: ["libfoo.dll"],
windows_import_lib: "libfoo.lib",
enabled: false,
target: {
windows: {
enabled: true,
},
},
}
Bug: 151744695
Test: prebuilt_test.go && built walleye-userdebug
Change-Id: Ia8d0afb7fa46783c670870440432779c5fc7321a
2020-03-18 07:19:07 +01:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
|
|
|
Rule: android.Cp,
|
|
|
|
Description: "prebuilt shared library",
|
|
|
|
Implicits: implicits,
|
|
|
|
Input: in,
|
|
|
|
Output: outputFile,
|
|
|
|
Args: map[string]string{
|
|
|
|
"cpFlags": "-L",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
return outputFile
|
|
|
|
}
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-03-12 21:17:14 +01:00
|
|
|
func (p *prebuiltLibraryLinker) prebuiltSrcs() []string {
|
|
|
|
srcs := p.properties.Srcs
|
|
|
|
if p.static() {
|
|
|
|
srcs = append(srcs, p.libraryDecorator.StaticProperties.Static.Srcs...)
|
|
|
|
}
|
|
|
|
if p.shared() {
|
|
|
|
srcs = append(srcs, p.libraryDecorator.SharedProperties.Shared.Srcs...)
|
|
|
|
}
|
|
|
|
|
|
|
|
return srcs
|
|
|
|
}
|
|
|
|
|
2018-12-18 18:47:14 +01:00
|
|
|
func (p *prebuiltLibraryLinker) shared() bool {
|
|
|
|
return p.libraryDecorator.shared()
|
|
|
|
}
|
|
|
|
|
2019-03-25 18:21:31 +01:00
|
|
|
func (p *prebuiltLibraryLinker) nativeCoverage() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-05-14 23:07:01 +02:00
|
|
|
func (p *prebuiltLibraryLinker) disablePrebuilt() {
|
|
|
|
p.properties.Srcs = nil
|
|
|
|
}
|
|
|
|
|
2020-03-31 17:05:34 +02:00
|
|
|
func (p *prebuiltLibraryLinker) skipInstall(mod *Module) {
|
|
|
|
mod.ModuleBase.SkipInstall()
|
|
|
|
}
|
|
|
|
|
2019-12-11 16:22:32 +01:00
|
|
|
func NewPrebuiltLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
2017-05-17 20:30:45 +02:00
|
|
|
module, library := NewLibrary(hod)
|
2016-10-07 01:12:58 +02:00
|
|
|
module.compiler = nil
|
|
|
|
|
|
|
|
prebuilt := &prebuiltLibraryLinker{
|
|
|
|
libraryDecorator: library,
|
|
|
|
}
|
|
|
|
module.linker = prebuilt
|
2020-03-31 17:05:34 +02:00
|
|
|
module.installer = prebuilt
|
2017-03-17 21:28:06 +01:00
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
module.AddProperties(&prebuilt.properties)
|
|
|
|
|
2020-03-12 21:17:14 +01:00
|
|
|
srcsSupplier := func() []string {
|
|
|
|
return prebuilt.prebuiltSrcs()
|
|
|
|
}
|
|
|
|
|
|
|
|
android.InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
|
2018-12-18 18:47:14 +01:00
|
|
|
|
2019-12-11 16:22:32 +01:00
|
|
|
// Prebuilt libraries can be used in SDKs.
|
Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.
A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:
sdk {
name: "mysdk#20",
java_libs: ["myjavalib_mysdk_20"],
}
java_import {
name: "myjavalib_mysdk_20",
srcs: ["myjavalib-v20.jar"],
sdk_member_name: "myjavalib",
}
sdk {
name: "mysdk#21",
java_libs: ["myjavalib_mysdk_21"],
}
java_import {
name: "myjavalib_mysdk_21",
srcs: ["myjavalib-v21.jar"],
sdk_member_name: "myjavalib",
}
java_library {
name: "myjavalib",
srcs: ["**/*/*.java"],
}
An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.
apex {
name: "myapex",
java_libs: ["libX", "libY"],
uses_sdks: ["mysdk#20"],
}
With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).
Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-07-17 13:08:41 +02:00
|
|
|
android.InitSdkAwareModule(module)
|
2019-12-11 16:22:32 +01:00
|
|
|
return module, library
|
|
|
|
}
|
|
|
|
|
2020-03-12 21:17:14 +01:00
|
|
|
// cc_prebuilt_library installs a precompiled shared library that are
|
|
|
|
// listed in the srcs property in the device's directory.
|
|
|
|
func PrebuiltLibraryFactory() android.Module {
|
|
|
|
module, _ := NewPrebuiltLibrary(android.HostAndDeviceSupported)
|
|
|
|
|
|
|
|
// Prebuilt shared libraries can be included in APEXes
|
|
|
|
android.InitApexModule(module)
|
|
|
|
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2019-12-11 16:22:32 +01:00
|
|
|
// cc_prebuilt_library_shared installs a precompiled shared library that are
|
|
|
|
// listed in the srcs property in the device's directory.
|
|
|
|
func PrebuiltSharedLibraryFactory() android.Module {
|
|
|
|
module, _ := NewPrebuiltSharedLibrary(android.HostAndDeviceSupported)
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
|
|
|
module, library := NewPrebuiltLibrary(hod)
|
|
|
|
library.BuildOnlyShared()
|
|
|
|
|
|
|
|
// Prebuilt shared libraries can be included in APEXes
|
|
|
|
android.InitApexModule(module)
|
2018-12-18 18:47:14 +01:00
|
|
|
|
2017-05-17 20:30:45 +02:00
|
|
|
return module, library
|
2017-03-17 21:28:06 +01:00
|
|
|
}
|
|
|
|
|
2019-03-28 03:09:10 +01:00
|
|
|
// cc_prebuilt_library_static installs a precompiled static library that are
|
|
|
|
// listed in the srcs property in the device's directory.
|
2019-08-23 04:17:39 +02:00
|
|
|
func PrebuiltStaticLibraryFactory() android.Module {
|
2017-05-17 20:30:45 +02:00
|
|
|
module, _ := NewPrebuiltStaticLibrary(android.HostAndDeviceSupported)
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
2019-12-11 16:22:32 +01:00
|
|
|
module, library := NewPrebuiltLibrary(hod)
|
2017-03-17 21:28:06 +01:00
|
|
|
library.BuildOnlyStatic()
|
2017-05-17 20:30:45 +02:00
|
|
|
return module, library
|
2017-03-17 21:28:06 +01:00
|
|
|
}
|
|
|
|
|
2020-03-11 22:45:49 +01:00
|
|
|
type prebuiltObjectProperties struct {
|
|
|
|
Srcs []string `android:"path,arch_variant"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type prebuiltObjectLinker struct {
|
|
|
|
android.Prebuilt
|
|
|
|
objectLinker
|
|
|
|
|
|
|
|
properties prebuiltObjectProperties
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *prebuiltObjectLinker) prebuilt() *android.Prebuilt {
|
|
|
|
return &p.Prebuilt
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ prebuiltLinkerInterface = (*prebuiltObjectLinker)(nil)
|
|
|
|
|
|
|
|
func (p *prebuiltObjectLinker) link(ctx ModuleContext,
|
|
|
|
flags Flags, deps PathDeps, objs Objects) android.Path {
|
|
|
|
if len(p.properties.Srcs) > 0 {
|
|
|
|
return p.Prebuilt.SingleSourcePath(ctx)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func newPrebuiltObject() *Module {
|
|
|
|
module := newObject()
|
|
|
|
prebuilt := &prebuiltObjectLinker{
|
|
|
|
objectLinker: objectLinker{
|
|
|
|
baseLinker: NewBaseLinker(nil),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
module.linker = prebuilt
|
|
|
|
module.AddProperties(&prebuilt.properties)
|
|
|
|
android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
|
|
|
|
android.InitSdkAwareModule(module)
|
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
|
|
|
func prebuiltObjectFactory() android.Module {
|
|
|
|
module := newPrebuiltObject()
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2017-03-17 21:28:06 +01:00
|
|
|
type prebuiltBinaryLinker struct {
|
|
|
|
*binaryDecorator
|
|
|
|
prebuiltLinker
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ prebuiltLinkerInterface = (*prebuiltBinaryLinker)(nil)
|
|
|
|
|
|
|
|
func (p *prebuiltBinaryLinker) link(ctx ModuleContext,
|
|
|
|
flags Flags, deps PathDeps, objs Objects) android.Path {
|
|
|
|
// TODO(ccross): verify shared library dependencies
|
2017-08-02 20:05:49 +02:00
|
|
|
if len(p.properties.Srcs) > 0 {
|
2018-09-05 23:20:03 +02:00
|
|
|
builderFlags := flagsToBuilderFlags(flags)
|
2017-08-09 01:20:15 +02:00
|
|
|
|
|
|
|
fileName := p.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
|
2018-09-05 23:20:03 +02:00
|
|
|
in := p.Prebuilt.SingleSourcePath(ctx)
|
|
|
|
|
2018-09-05 01:28:17 +02:00
|
|
|
p.unstrippedOutputFile = in
|
|
|
|
|
2018-09-05 23:20:03 +02:00
|
|
|
if p.needsStrip(ctx) {
|
|
|
|
stripped := android.PathForModuleOut(ctx, "stripped", fileName)
|
2019-05-31 05:53:29 +02:00
|
|
|
p.stripExecutableOrSharedLib(ctx, in, stripped, builderFlags)
|
2018-09-05 23:20:03 +02:00
|
|
|
in = stripped
|
|
|
|
}
|
2017-08-09 01:20:15 +02:00
|
|
|
|
2018-09-05 23:20:03 +02:00
|
|
|
// Copy binaries to a name matching the final installed name
|
|
|
|
outputFile := android.PathForModuleOut(ctx, fileName)
|
2017-10-24 02:16:14 +02:00
|
|
|
ctx.Build(pctx, android.BuildParams{
|
2017-08-31 21:29:17 +02:00
|
|
|
Rule: android.CpExecutable,
|
2017-08-09 01:20:15 +02:00
|
|
|
Description: "prebuilt",
|
|
|
|
Output: outputFile,
|
2018-09-05 23:20:03 +02:00
|
|
|
Input: in,
|
2017-08-09 01:20:15 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return outputFile
|
2017-03-17 21:28:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-03-28 03:09:10 +01:00
|
|
|
// cc_prebuilt_binary installs a precompiled executable in srcs property in the
|
|
|
|
// device's directory.
|
2017-06-24 00:06:31 +02:00
|
|
|
func prebuiltBinaryFactory() android.Module {
|
2017-05-17 20:30:45 +02:00
|
|
|
module, _ := NewPrebuiltBinary(android.HostAndDeviceSupported)
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
|
|
|
|
module, binary := NewBinary(hod)
|
2017-03-17 21:28:06 +01:00
|
|
|
module.compiler = nil
|
|
|
|
|
|
|
|
prebuilt := &prebuiltBinaryLinker{
|
|
|
|
binaryDecorator: binary,
|
|
|
|
}
|
|
|
|
module.linker = prebuilt
|
2016-10-07 01:12:58 +02:00
|
|
|
|
2017-08-02 20:05:49 +02:00
|
|
|
module.AddProperties(&prebuilt.properties)
|
|
|
|
|
|
|
|
android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
|
2017-05-17 20:30:45 +02:00
|
|
|
return module, binary
|
2016-10-07 01:12:58 +02:00
|
|
|
}
|