diff --git a/Blueprints b/Blueprints index 057d27c34..3c0755f2f 100644 --- a/Blueprints +++ b/Blueprints @@ -56,6 +56,7 @@ bootstrap_go_package { ], srcs: [ "common/arch.go", + "common/checkbuild.go", "common/defs.go", "common/glob.go", "common/module.go", diff --git a/build.ninja.in b/build.ninja.in index b3447c744..016e6252a 100644 --- a/build.ninja.in +++ b/build.ninja.in @@ -53,7 +53,7 @@ rule g.bootstrap.link # Variant: # Type: bootstrap_go_binary # Factory: blueprint/bootstrap.newGoBinaryModule -# Defined: build/soong/Blueprints:106:1 +# Defined: build/soong/Blueprints:107:1 build .bootstrap/androidmk/obj/androidmk.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/androidmk/cmd/androidmk/android.go $ @@ -79,7 +79,7 @@ default .bootstrap/bin/androidmk # Variant: # Type: bootstrap_go_package # Factory: blueprint/bootstrap.newGoPackageModule -# Defined: build/soong/Blueprints:119:1 +# Defined: build/soong/Blueprints:120:1 build .bootstrap/androidmk-parser/pkg/android/soong/androidmk/parser.a: $ g.bootstrap.gc $ @@ -274,7 +274,7 @@ default .bootstrap/bin/minibp # Variant: # Type: bootstrap_go_package # Factory: blueprint/bootstrap.newGoPackageModule -# Defined: build/soong/Blueprints:79:1 +# Defined: build/soong/Blueprints:80:1 build .bootstrap/soong-cc/pkg/android/soong/cc.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/cc/builder.go $ @@ -308,6 +308,7 @@ default .bootstrap/soong-cc/pkg/android/soong/cc.a build .bootstrap/soong-common/pkg/android/soong/common.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/common/arch.go $ + ${g.bootstrap.srcDir}/build/soong/common/checkbuild.go $ ${g.bootstrap.srcDir}/build/soong/common/defs.go $ ${g.bootstrap.srcDir}/build/soong/common/glob.go $ ${g.bootstrap.srcDir}/build/soong/common/module.go $ @@ -329,7 +330,7 @@ default .bootstrap/soong-common/pkg/android/soong/common.a # Variant: # Type: bootstrap_go_package # Factory: blueprint/bootstrap.newGoPackageModule -# Defined: build/soong/Blueprints:66:1 +# Defined: build/soong/Blueprints:67:1 build .bootstrap/soong-config/pkg/android/soong/config.a: g.bootstrap.gc $ ${g.bootstrap.srcDir}/build/soong/config/config.go | $ diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index c1999fe27..5c954a92b 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -54,6 +54,7 @@ func main() { ctx.RegisterEarlyMutator("link", cc.LinkageMutator) // Singletons + ctx.RegisterSingletonType("checkbuild", common.CheckbuildSingleton) configuration, err := config.New(srcDir) if err != nil { diff --git a/common/checkbuild.go b/common/checkbuild.go new file mode 100644 index 000000000..daa70a725 --- /dev/null +++ b/common/checkbuild.go @@ -0,0 +1,43 @@ +// Copyright 2015 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 common + +import ( + "blueprint" +) + +func CheckbuildSingleton() blueprint.Singleton { + return &checkbuildSingleton{} +} + +type checkbuildSingleton struct{} + +func (c *checkbuildSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) { + deps := []string{} + ctx.VisitAllModules(func(module blueprint.Module) { + if a, ok := module.(AndroidModule); ok { + if len(a.base().checkbuildFiles) > 0 { + deps = append(deps, ctx.ModuleName(module)+"-checkbuild") + } + } + }) + + ctx.Build(pctx, blueprint.BuildParams{ + Rule: blueprint.Phony, + Outputs: []string{"checkbuild"}, + Implicits: deps, + Optional: true, + }) +} diff --git a/common/module.go b/common/module.go index 0cbe4b07c..515327a67 100644 --- a/common/module.go +++ b/common/module.go @@ -212,18 +212,45 @@ func (a *AndroidModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) { } allInstalledFiles := []string{} + allCheckbuildFiles := []string{} ctx.VisitAllModuleVariants(func(module blueprint.Module) { if androidModule, ok := module.(AndroidModule); ok { files := androidModule.base().installFiles allInstalledFiles = append(allInstalledFiles, files...) + files = androidModule.base().checkbuildFiles + allCheckbuildFiles = append(allCheckbuildFiles, files...) } }) + deps := []string{} + if len(allInstalledFiles) > 0 { + name := ctx.ModuleName() + "-install" ctx.Build(pctx, blueprint.BuildParams{ - Rule: blueprint.Phony, - Outputs: []string{ctx.ModuleName()}, - Inputs: allInstalledFiles, + Rule: blueprint.Phony, + Outputs: []string{name}, + Implicits: allInstalledFiles, + }) + deps = append(deps, name) + } + + if len(allCheckbuildFiles) > 0 { + name := ctx.ModuleName() + "-checkbuild" + ctx.Build(pctx, blueprint.BuildParams{ + Rule: blueprint.Phony, + Outputs: []string{name}, + Implicits: allCheckbuildFiles, + Optional: true, + }) + deps = append(deps, name) + } + + if len(deps) > 0 { + ctx.Build(pctx, blueprint.BuildParams{ + Rule: blueprint.Phony, + Outputs: []string{ctx.ModuleName()}, + Implicits: deps, + Optional: true, }) } } @@ -262,6 +289,9 @@ func (a *AndroidModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) { if ctx.Failed() { return } + + a.installFiles = append(a.installFiles, androidCtx.installFiles...) + a.checkbuildFiles = append(a.checkbuildFiles, androidCtx.checkbuildFiles...) } type androidModuleContext struct { @@ -300,7 +330,6 @@ func (a *androidModuleContext) InstallFile(installPath, srcPath string) { }) a.installFiles = append(a.installFiles, fullInstallPath) - a.checkbuildFiles = append(a.checkbuildFiles, srcPath) } func (a *androidModuleContext) CheckbuildFile(srcPath string) {