Move bpglob out of ToolDir am: 37d151ff95 am: 64310fcea0 am: 669e58631f

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/1875757

Change-Id: Ifcb5664949a90efbf36a4a28415803ca727a56b1
This commit is contained in:
Colin Cross 2021-11-02 21:46:08 +00:00 committed by Automerger Merge Worker
commit 5832ba46d5
2 changed files with 27 additions and 7 deletions

View file

@ -149,6 +149,13 @@ var (
},
"depfile")
noop = pctx.StaticRule("noop",
blueprint.RuleParams{
Command: "true",
Description: "noop",
Restat: true,
})
_ = pctx.VariableFunc("ToolDir", func(config interface{}) (string, error) {
return config.(BootstrapConfig).HostToolDir(), nil
})
@ -709,6 +716,13 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
Inputs: blueprintGoPackages,
Optional: true,
})
// out/soong/bpglob is built by microfactory before any ninja runs, write a rule that
// convinces ninja that it has been built to avoid tripping Soong's dangling rules check.
ctx.Build(pctx, blueprint.BuildParams{
Rule: noop,
Outputs: []string{"$bootstrapGlobCmd"},
})
}
// packageRoot returns the module-specific package root directory path. This

View file

@ -44,22 +44,26 @@ import (
// in a build failure with a "missing and no known rule to make it" error.
var (
globCmd = filepath.Join("$ToolDir", "bpglob")
_ = pctx.VariableFunc("bootstrapGlobCmd", func(config interface{}) (string, error) {
return filepath.Join(config.(BootstrapConfig).SoongOutDir(), "bpglob"), nil
})
_ = pctx.StaticVariable("primaryBuilderGlobCmd", filepath.Join("$ToolDir", "bpglob"))
// globRule rule traverses directories to produce a list of files that match $glob
// and writes it to $out if it has changed, and writes the directories to $out.d
GlobRule = pctx.StaticRule("GlobRule",
blueprint.RuleParams{
Command: fmt.Sprintf(`%s -o $out -v %d $args`,
globCmd, pathtools.BPGlobArgumentVersion),
CommandDeps: []string{globCmd},
Command: fmt.Sprintf(`$globCmd -o $out -v %d $args`,
pathtools.BPGlobArgumentVersion),
CommandDeps: []string{"$globCmd"},
Description: "glob",
Restat: true,
Deps: blueprint.DepsGCC,
Depfile: "$out.d",
},
"args")
"args", "globCmd")
)
// GlobFileContext is the subset of ModuleContext and SingletonContext needed by GlobFile
@ -81,7 +85,8 @@ func GlobFile(ctx GlobFileContext, pattern string, excludes []string, fileListFi
Rule: GlobRule,
Outputs: []string{fileListFile},
Args: map[string]string{
"args": args,
"args": args,
"globCmd": "$primaryBuilderGlobCmd",
},
Description: "glob " + pattern,
})
@ -112,7 +117,8 @@ func multipleGlobFilesRule(ctx GlobFileContext, fileListFile string, shard int,
Rule: GlobRule,
Outputs: []string{fileListFile},
Args: map[string]string{
"args": args.String(),
"args": args.String(),
"globCmd": "$bootstrapGlobCmd",
},
Description: fmt.Sprintf("regenerate globs shard %d of %d", shard, numGlobBuckets),
})