diff options
| author | 2015-12-17 16:39:19 -0800 | |
|---|---|---|
| committer | 2015-12-18 13:13:15 -0800 | |
| commit | 6ff513835507ac628bae455fc6765bff059c574c (patch) | |
| tree | b4d967d344fb635af870a165ef36de9ae1847945 | |
| parent | 66fe5656b4abd53249b1e1ea3952fba8bacde10c (diff) | |
Delay dependency errors to ninja time for unbundled builds
Unbundled builds may use a subset of the tree, which can bring in unused
modules but not their dependencies. Delay handling of dependency errors
for unbundled builds to ninja time, which will prevent errors if only
modules with satisified dependencies are built.
Change-Id: Ib93bae93fcfa0b55df500a30d8e35231ffb0987c
| -rw-r--r-- | cc/cc.go | 2 | ||||
| -rw-r--r-- | cmd/soong_build/main.go | 2 | ||||
| -rw-r--r-- | common/config.go | 8 | ||||
| -rw-r--r-- | common/defs.go | 7 | ||||
| -rw-r--r-- | common/module.go | 32 |
5 files changed, 50 insertions, 1 deletions
@@ -740,7 +740,7 @@ func (c *CCBase) depsToPathsFromList(ctx common.AndroidModuleContext, return } }) - if !found { + if !found && !inList(n, ctx.GetMissingDependencies()) { ctx.ModuleErrorf("unsatisified dependency on %q", n) } } diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 254f92252..1bb8fcdaf 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -44,5 +44,7 @@ func main() { // Temporary hack //ctx.SetIgnoreUnknownModuleTypes(true) + ctx.SetAllowMissingDependencies(configuration.AllowMissingDependencies()) + bootstrap.Main(ctx, configuration, configuration.ConfigFileName, configuration.ProductVariablesFileName) } diff --git a/common/config.go b/common/config.go index 971c4c117..74e066032 100644 --- a/common/config.go +++ b/common/config.go @@ -22,8 +22,12 @@ import ( "runtime" "strings" "sync" + + "github.com/google/blueprint/proptools" ) +var Bool = proptools.Bool + // The configuration file name const configFileName = "soong.config" const productVariablesFileName = "soong.variables" @@ -287,3 +291,7 @@ func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath { func (c *config) DefaultAppCertificate(ctx PathContext) SourcePath { return c.DefaultAppCertificateDir(ctx).Join(ctx, "testkey") } + +func (c *config) AllowMissingDependencies() bool { + return Bool(c.ProductVariables.Unbundled_build) +} diff --git a/common/defs.go b/common/defs.go index 9e185e44d..12500689f 100644 --- a/common/defs.go +++ b/common/defs.go @@ -59,6 +59,13 @@ var ( Description: "symlink $out", }, "fromPath") + + ErrorRule = pctx.StaticRule("Error", + blueprint.RuleParams{ + Command: `echo "$error" && false`, + Description: "error building $out", + }, + "error") ) func init() { diff --git a/common/module.go b/common/module.go index e03b006e5..a3de5f6bd 100644 --- a/common/module.go +++ b/common/module.go @@ -15,7 +15,9 @@ package common import ( + "fmt" "path/filepath" + "strings" "android/soong" "android/soong/glob" @@ -363,6 +365,7 @@ func (a *AndroidModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) { androidBaseContextImpl: a.androidBaseContextFactory(ctx), installDeps: a.computeInstallDeps(ctx), installFiles: a.installFiles, + missingDeps: ctx.GetMissingDependencies(), } if !a.Enabled() { @@ -397,9 +400,28 @@ type androidModuleContext struct { installDeps Paths installFiles Paths checkbuildFiles Paths + missingDeps []string +} + +func (a *androidModuleContext) ninjaError(outputs []string, err error) { + a.ModuleContext.Build(pctx, blueprint.BuildParams{ + Rule: ErrorRule, + Outputs: outputs, + Optional: true, + Args: map[string]string{ + "error": err.Error(), + }, + }) + return } func (a *androidModuleContext) Build(pctx blueprint.PackageContext, params blueprint.BuildParams) { + if a.missingDeps != nil { + a.ninjaError(params.Outputs, fmt.Errorf("module %s missing dependencies: %s\n", + a.ModuleName(), strings.Join(a.missingDeps, ", "))) + return + } + params.Optional = true a.ModuleContext.Build(pctx, params) } @@ -425,9 +447,19 @@ func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params bparams.Implicits = append(bparams.Implicits, params.Implicit.String()) } + if a.missingDeps != nil { + a.ninjaError(bparams.Outputs, fmt.Errorf("module %s missing dependencies: %s\n", + a.ModuleName(), strings.Join(a.missingDeps, ", "))) + return + } + a.ModuleContext.Build(pctx, bparams) } +func (a *androidModuleContext) GetMissingDependencies() []string { + return a.missingDeps +} + func (a *androidBaseContextImpl) Arch() Arch { return a.arch } |