Wrap PackageContext and SingletonContext

Wrap blueprint.PackageContext so that the *Func methods can provide
an android.Config instead of an interface{}.  The modified signatures
means that every method in ModuleContext and SingletonContext
that takes a blueprint.PackageContext now needs to be wrapped to
take an android.PackageContext.

SingletonContext wasn't previously wrapped at all, but as long
as it is, wrap everything like ModuleContext does.  This requires
updating every Singleton to use the android-specific methods.

Test: builds, all Soong tests pass
Change-Id: I4f22085ebca7def6c5cde49e8210b59d994ba625
This commit is contained in:
Colin Cross
2017-11-28 17:34:01 -08:00
parent f2a56f0e0d
commit 0875c52de7
21 changed files with 479 additions and 243 deletions

View File

@@ -53,8 +53,6 @@ package cc
// TODO(danalbert): Write `ndk_static_library` rule.
import (
"github.com/google/blueprint"
"android/soong/android"
)
@@ -76,32 +74,32 @@ func getNdkSysrootBase(ctx android.PathContext) android.OutputPath {
return getNdkInstallBase(ctx).Join(ctx, "sysroot")
}
func getNdkSysrootTimestampFile(ctx android.PathContext) android.Path {
func getNdkSysrootTimestampFile(ctx android.PathContext) android.WritablePath {
return android.PathForOutput(ctx, "ndk.timestamp")
}
func NdkSingleton() blueprint.Singleton {
func NdkSingleton() android.Singleton {
return &ndkSingleton{}
}
type ndkSingleton struct{}
func (n *ndkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
installPaths := []string{}
licensePaths := []string{}
ctx.VisitAllModules(func(module blueprint.Module) {
func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var installPaths android.Paths
var licensePaths android.Paths
ctx.VisitAllModules(func(module android.Module) {
if m, ok := module.(android.Module); ok && !m.Enabled() {
return
}
if m, ok := module.(*headerModule); ok {
installPaths = append(installPaths, m.installPaths...)
licensePaths = append(licensePaths, m.licensePath.String())
licensePaths = append(licensePaths, m.licensePath)
}
if m, ok := module.(*preprocessedHeaderModule); ok {
installPaths = append(installPaths, m.installPaths...)
licensePaths = append(licensePaths, m.licensePath.String())
licensePaths = append(licensePaths, m.licensePath)
}
if m, ok := module.(*Module); ok {
@@ -110,30 +108,28 @@ func (n *ndkSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
}
if library, ok := m.linker.(*libraryDecorator); ok {
if library.MutatedProperties.NdkSysrootPath != "" {
installPaths = append(installPaths, library.MutatedProperties.NdkSysrootPath)
if library.ndkSysrootPath != nil {
installPaths = append(installPaths, library.ndkSysrootPath)
}
}
}
})
combinedLicense := getNdkInstallBase(ctx).Join(ctx, "NOTICE")
ctx.Build(pctx, blueprint.BuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: android.Cat,
Description: "combine licenses",
Outputs: []string{combinedLicense.String()},
Output: combinedLicense,
Inputs: licensePaths,
Optional: true,
})
depPaths := append(installPaths, combinedLicense.String())
depPaths := 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, blueprint.BuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: android.Touch,
Outputs: []string{getNdkSysrootTimestampFile(ctx).String()},
Output: getNdkSysrootTimestampFile(ctx),
Implicits: depPaths,
Optional: true,
})
}