diff options
author | Dan Albert <danalbert@google.com> | 2017-12-13 15:05:04 -0800 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2017-12-14 14:13:56 -0800 |
commit | 6ab43d85972044dd3a395b1dfb71ed4c51b2474c (patch) | |
tree | 000acb658348a7cff5229dc74f59637ba0894c89 /cc/ndk_sysroot.go | |
parent | 281f22b3f296674e147acffd7083d4d11f73cf0d (diff) | |
download | build_soong-6ab43d85972044dd3a395b1dfb71ed4c51b2474c.tar.gz build_soong-6ab43d85972044dd3a395b1dfb71ed4c51b2474c.tar.bz2 build_soong-6ab43d85972044dd3a395b1dfb71ed4c51b2474c.zip |
Allow NDK static libraries to use the NDK sysroot.
Building a static library for the NDK only requires that the NDK
headers be available. Currently, A module with both
`static_ndk_lib: true` and `sdk_version: something` will have a cyclic
dependency since it both needs the NDK and is in the NDK. Create two
NDK timestamp files: one for the isolated parts of the NDK (headers
and stub libraries), and another for the full sysroot with the static
libraries.
Test: set static_ndk_lib on compiler-rt-extras, make ndk
Bug: None
Change-Id: Iab50ffa0e4cbf4cd164f376e15281030c7aad984
Diffstat (limited to 'cc/ndk_sysroot.go')
-rw-r--r-- | cc/ndk_sysroot.go | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go index 4324458e..c7ba5886 100644 --- a/cc/ndk_sysroot.go +++ b/cc/ndk_sysroot.go @@ -74,7 +74,16 @@ func getNdkSysrootBase(ctx android.PathContext) android.OutputPath { return getNdkInstallBase(ctx).Join(ctx, "sysroot") } -func getNdkSysrootTimestampFile(ctx android.PathContext) android.WritablePath { +// The base timestamp file depends on the NDK headers and stub shared libraries, +// but not the static libraries. This distinction is needed because the static +// libraries themselves might need to depend on the base sysroot. +func getNdkBaseTimestampFile(ctx android.PathContext) android.WritablePath { + return android.PathForOutput(ctx, "ndk_base.timestamp") +} + +// The full timestamp file depends on the base timestamp *and* the static +// libraries. +func getNdkFullTimestampFile(ctx android.PathContext) android.WritablePath { return android.PathForOutput(ctx, "ndk.timestamp") } @@ -85,6 +94,7 @@ func NdkSingleton() android.Singleton { type ndkSingleton struct{} func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) { + var staticLibInstallPaths android.Paths var installPaths android.Paths var licensePaths android.Paths ctx.VisitAllModules(func(module android.Module) { @@ -109,7 +119,8 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) { if library, ok := m.linker.(*libraryDecorator); ok { if library.ndkSysrootPath != nil { - installPaths = append(installPaths, library.ndkSysrootPath) + staticLibInstallPaths = append( + staticLibInstallPaths, library.ndkSysrootPath) } } } @@ -123,13 +134,21 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) { Inputs: licensePaths, }) - depPaths := append(installPaths, combinedLicense) + baseDepPaths := append(installPaths, combinedLicense) // There's a dummy "ndk" rule defined in ndk/Android.mk that depends on // this. `m ndk` will build the sysroots. ctx.Build(pctx, android.BuildParams{ Rule: android.Touch, - Output: getNdkSysrootTimestampFile(ctx), - Implicits: depPaths, + Output: getNdkBaseTimestampFile(ctx), + Implicits: baseDepPaths, + }) + + fullDepPaths := append(staticLibInstallPaths, getNdkBaseTimestampFile(ctx)) + + ctx.Build(pctx, android.BuildParams{ + Rule: android.Touch, + Output: getNdkFullTimestampFile(ctx), + Implicits: fullDepPaths, }) } |