2016-07-29 21:48:20 +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 (
|
|
|
|
"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
|
2016-09-13 21:26:16 +02:00
|
|
|
Relative_install_path string `android:"arch_variant"`
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type installLocation int
|
|
|
|
|
|
|
|
const (
|
2017-03-30 07:00:18 +02:00
|
|
|
InstallInSystem installLocation = 0
|
|
|
|
InstallInData = iota
|
|
|
|
InstallInSanitizerDir = iota
|
2016-07-30 02:28:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewBaseInstaller(dir, dir64 string, location installLocation) *baseInstaller {
|
|
|
|
return &baseInstaller{
|
|
|
|
dir: dir,
|
|
|
|
dir64: dir64,
|
|
|
|
location: location,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
type baseInstaller struct {
|
|
|
|
Properties InstallerProperties
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
dir string
|
|
|
|
dir64 string
|
2017-06-23 12:24:43 +02:00
|
|
|
subDir string
|
2016-09-13 21:26:16 +02:00
|
|
|
relative string
|
2016-07-30 02:28:03 +02:00
|
|
|
location installLocation
|
2016-07-29 21:48:20 +02:00
|
|
|
|
|
|
|
path android.OutputPath
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ installer = (*baseInstaller)(nil)
|
|
|
|
|
2016-08-01 22:20:05 +02:00
|
|
|
func (installer *baseInstaller) installerProps() []interface{} {
|
2016-07-29 21:48:20 +02:00
|
|
|
return []interface{}{&installer.Properties}
|
|
|
|
}
|
|
|
|
|
2016-12-07 22:37:42 +01:00
|
|
|
func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath {
|
2017-06-23 12:24:43 +02:00
|
|
|
dir := installer.dir
|
2016-07-29 21:48:20 +02:00
|
|
|
if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
|
2017-06-23 12:24:43 +02:00
|
|
|
dir = installer.dir64
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
if !ctx.Host() && !ctx.Arch().Native {
|
2017-06-23 12:24:43 +02:00
|
|
|
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
2017-09-28 02:01:44 +02:00
|
|
|
if installer.location == InstallInData && ctx.useVndk() {
|
2017-06-23 12:24:43 +02: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-06 21:43:22 +02:00
|
|
|
}
|
2017-06-23 12:24:43 +02:00
|
|
|
return android.PathForModuleInstall(ctx, dir, installer.subDir, installer.Properties.Relative_install_path, installer.relative)
|
2016-12-07 22:37:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (installer *baseInstaller) install(ctx ModuleContext, file android.Path) {
|
2017-08-31 21:29:17 +02:00
|
|
|
installer.path = ctx.InstallFile(installer.installDir(ctx), file.Base(), file)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (installer *baseInstaller) inData() bool {
|
2016-07-30 02:28:03 +02:00
|
|
|
return installer.location == InstallInData
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
2016-09-29 01:18:03 +02:00
|
|
|
|
2017-03-30 07:00:18 +02:00
|
|
|
func (installer *baseInstaller) inSanitizerDir() bool {
|
|
|
|
return installer.location == InstallInSanitizerDir
|
|
|
|
}
|
|
|
|
|
2016-09-29 01:18:03 +02:00
|
|
|
func (installer *baseInstaller) hostToolPath() android.OptionalPath {
|
|
|
|
return android.OptionalPath{}
|
|
|
|
}
|