aboutsummaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2017-10-13 00:29:00 -0700
committerDan Albert <danalbert@google.com>2017-10-26 12:19:29 -0700
commitf563d25578557801a8cdacafce17534f8eb3ad90 (patch)
tree8162388f944a266fce8fcd3b336df0d95d7e07c3 /cc
parent3615dcb30cb1db4e61dea229d70a360b26849475 (diff)
downloadbuild_soong-f563d25578557801a8cdacafce17534f8eb3ad90.tar.gz
build_soong-f563d25578557801a8cdacafce17534f8eb3ad90.tar.bz2
build_soong-f563d25578557801a8cdacafce17534f8eb3ad90.zip
Add support for packaging static libs in the NDK.
Adding `static_ndk_lib: true` to a module installs the static library to the NDK sysroot. Test: Set property for libc.a, make ndk Test: Set property for libc.a, scripts/build-ndk-prebuilts.sh Bug: https://github.com/android-ndk/ndk/issues/272 Change-Id: Ib368a25705f2adb7129dac207c1b727d4ccc1eb2
Diffstat (limited to 'cc')
-rw-r--r--cc/library.go19
-rw-r--r--cc/ndk_sysroot.go6
2 files changed, 25 insertions, 0 deletions
diff --git a/cc/library.go b/cc/library.go
index 1434f2cc..25872c6c 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -70,6 +70,8 @@ type LibraryProperties struct {
Version_script *string `android:"arch_variant"`
}
}
+
+ Static_ndk_lib bool
}
type LibraryMutatedProperties struct {
@@ -83,6 +85,9 @@ type LibraryMutatedProperties struct {
VariantIsShared bool `blueprint:"mutated"`
// This variant is static
VariantIsStatic bool `blueprint:"mutated"`
+ // Location of the static library in the sysroot. Empty if the library is
+ // not included in the NDK.
+ NdkSysrootPath string `blueprint:"mutated"`
}
type FlagExporterProperties struct {
@@ -721,6 +726,20 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
}
library.baseInstaller.install(ctx, file)
}
+
+ if library.Properties.Static_ndk_lib && library.static() {
+ installPath := getNdkSysrootBase(ctx).Join(
+ ctx, "usr/lib", ctx.toolchain().ClangTriple(), file.Base())
+
+ ctx.ModuleBuild(pctx, android.ModuleBuildParams{
+ Rule: android.Cp,
+ Description: "install " + installPath.Base(),
+ Output: installPath,
+ Input: file,
+ })
+
+ library.MutatedProperties.NdkSysrootPath = installPath.String()
+ }
}
func (library *libraryDecorator) static() bool {
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 5b4cfbe8..e2139658 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -108,6 +108,12 @@ func (n *ndkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
if installer, ok := m.installer.(*stubDecorator); ok {
installPaths = append(installPaths, installer.installPath)
}
+
+ if library, ok := m.linker.(*libraryDecorator); ok {
+ if library.MutatedProperties.NdkSysrootPath != "" {
+ installPaths = append(installPaths, library.MutatedProperties.NdkSysrootPath)
+ }
+ }
}
})