2016-07-30 03:48:20 +08: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 (
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This file handles installing files into their final location
|
|
|
|
|
|
|
|
type InstallerProperties struct {
|
|
|
|
// install to a subdirectory of the default install path for the module
|
2017-11-08 02:57:05 +08:00
|
|
|
Relative_install_path *string `android:"arch_variant"`
|
2016-07-30 03:48:20 +08:00
|
|
|
}
|
|
|
|
|
2016-07-30 08:28:03 +08:00
|
|
|
type installLocation int
|
|
|
|
|
|
|
|
const (
|
2017-03-30 13:00:18 +08:00
|
|
|
InstallInSystem installLocation = 0
|
|
|
|
InstallInData = iota
|
|
|
|
InstallInSanitizerDir = iota
|
2016-07-30 08:28:03 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewBaseInstaller(dir, dir64 string, location installLocation) *baseInstaller {
|
|
|
|
return &baseInstaller{
|
|
|
|
dir: dir,
|
|
|
|
dir64: dir64,
|
|
|
|
location: location,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-30 03:48:20 +08:00
|
|
|
type baseInstaller struct {
|
|
|
|
Properties InstallerProperties
|
|
|
|
|
2016-07-30 08:28:03 +08:00
|
|
|
dir string
|
|
|
|
dir64 string
|
2017-06-23 18:24:43 +08:00
|
|
|
subDir string
|
2016-09-14 03:26:16 +08:00
|
|
|
relative string
|
2016-07-30 08:28:03 +08:00
|
|
|
location installLocation
|
2016-07-30 03:48:20 +08:00
|
|
|
|
|
|
|
path android.OutputPath
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ installer = (*baseInstaller)(nil)
|
|
|
|
|
2016-08-02 04:20:05 +08:00
|
|
|
func (installer *baseInstaller) installerProps() []interface{} {
|
2016-07-30 03:48:20 +08:00
|
|
|
return []interface{}{&installer.Properties}
|
|
|
|
}
|
|
|
|
|
2016-12-08 05:37:42 +08:00
|
|
|
func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath {
|
2017-06-23 18:24:43 +08:00
|
|
|
dir := installer.dir
|
2016-07-30 03:48:20 +08:00
|
|
|
if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
|
2017-06-23 18:24:43 +08:00
|
|
|
dir = installer.dir64
|
2016-07-30 03:48:20 +08:00
|
|
|
}
|
2019-09-19 05:12:18 +08:00
|
|
|
if !ctx.Host() && !ctx.Arch().Native {
|
|
|
|
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
|
|
|
}
|
2019-07-11 16:23:53 +08:00
|
|
|
if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
|
|
|
|
dir = filepath.Join(dir, ctx.Target().NativeBridgeRelativePath)
|
|
|
|
}
|
2017-09-28 08:01:44 +08:00
|
|
|
if installer.location == InstallInData && ctx.useVndk() {
|
2017-06-23 18:24:43 +08:00
|
|
|
dir = filepath.Join(dir, "vendor")
|
Split /system and /vendor modules, allow multi-installation
Nothing changes if BOARD_VNDK_VERSION isn't set.
When the VNDK is enabled (BOARD_VNDK_VERSION in Make), this will split
/system and /vendor modules into two different variant spaces that can't
link to each other. There are a few interfaces between the two variant
spaces:
The `llndk_library` stubs will be available in the /vendor variant, but
won't be installed, so at runtime the /system variant will be used.
Setting `vendor_available: true` will split a module into both variants.
The /system (or "core") variant will compile just like today. The
/vendor ("vendor") variant will compile against everything else in the
vendor space (so LL-NDK instead of libc/liblog/etc). There will be two
copies of these libraries installed onto the final device.
Since the available runtime interfaces for vendor modules may be
reduced, and your dependencies may not expose their private interfaces,
we allow the vendor variants to reduce their compilation set, and export
a different set of headers:
cc_library {
name: "libfoo",
srcs: ["common.cpp", "private_impl.cpp"],
export_include_dirs: ["include"],
target: {
vendor: {
export_include_dirs: ["include_vndk"],
exclude_srcs: ["private_impl.cpp"],
srcs: ["vendor_only.cpp"],
},
},
}
So the "core" variant would compile with both "common.cpp" and
"private_impl.cpp", and export "include".
The "vendor" variant would compile "common.cpp" and "vendor_only.cpp",
and export "include_vndk".
Bug: 36426473
Bug: 36079834
Test: out/soong/build.ninja, out/soong/Android- only changes due to _core addition and
.llndk -> .vendor
Test: attempt to compile with BOARD_VNDK_VERSION:=current
Change-Id: Idef28764043bf6c33dc0d2e7e2026c38867ff769
2017-04-07 03:43:22 +08:00
|
|
|
}
|
2017-11-08 02:57:05 +08:00
|
|
|
return android.PathForModuleInstall(ctx, dir, installer.subDir,
|
2019-02-01 11:03:59 +08:00
|
|
|
installer.relativeInstallPath(), installer.relative)
|
2016-12-08 05:37:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
|
2017-09-01 03:29:17 +08:00
|
|
|
installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
|
2016-07-30 03:48:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (installer *baseInstaller) inData() bool {
|
2016-07-30 08:28:03 +08:00
|
|
|
return installer.location == InstallInData
|
2016-07-30 03:48:20 +08:00
|
|
|
}
|
2016-09-29 07:18:03 +08:00
|
|
|
|
2017-03-30 13:00:18 +08:00
|
|
|
func (installer *baseInstaller) inSanitizerDir() bool {
|
|
|
|
return installer.location == InstallInSanitizerDir
|
|
|
|
}
|
|
|
|
|
2016-09-29 07:18:03 +08:00
|
|
|
func (installer *baseInstaller) hostToolPath() android.OptionalPath {
|
|
|
|
return android.OptionalPath{}
|
|
|
|
}
|
2019-02-01 11:03:59 +08:00
|
|
|
|
|
|
|
func (installer *baseInstaller) relativeInstallPath() string {
|
|
|
|
return String(installer.Properties.Relative_install_path)
|
|
|
|
}
|