Move bpglob out of ToolDir
ToolDir is going to become unstable when switching between KatiEnabled and Soong-only builds while the duplication between out/soong/host and out/host is resolved. bpglob gets executed very early during bootstrap, before the primary builder has run to update the paths to match the current configuration. Move it into SoongOutDir() so that its path is more stable. The copy of bpglob in ToolDir is still used when bpglob is used by the primary builder through bootstrap.GlobFile. Bug: 204136549 Test: m nothing Change-Id: Ida51997b6408d7c265f3ba343278e5e2968467d3
This commit is contained in:
parent
0e306e7a89
commit
37d151ff95
2 changed files with 27 additions and 7 deletions
|
@ -149,6 +149,13 @@ var (
|
||||||
},
|
},
|
||||||
"depfile")
|
"depfile")
|
||||||
|
|
||||||
|
noop = pctx.StaticRule("noop",
|
||||||
|
blueprint.RuleParams{
|
||||||
|
Command: "true",
|
||||||
|
Description: "noop",
|
||||||
|
Restat: true,
|
||||||
|
})
|
||||||
|
|
||||||
_ = pctx.VariableFunc("ToolDir", func(config interface{}) (string, error) {
|
_ = pctx.VariableFunc("ToolDir", func(config interface{}) (string, error) {
|
||||||
return config.(BootstrapConfig).HostToolDir(), nil
|
return config.(BootstrapConfig).HostToolDir(), nil
|
||||||
})
|
})
|
||||||
|
@ -709,6 +716,13 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
||||||
Inputs: blueprintGoPackages,
|
Inputs: blueprintGoPackages,
|
||||||
Optional: true,
|
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
|
// packageRoot returns the module-specific package root directory path. This
|
||||||
|
|
|
@ -44,22 +44,26 @@ import (
|
||||||
// in a build failure with a "missing and no known rule to make it" error.
|
// in a build failure with a "missing and no known rule to make it" error.
|
||||||
|
|
||||||
var (
|
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
|
// 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
|
// and writes it to $out if it has changed, and writes the directories to $out.d
|
||||||
GlobRule = pctx.StaticRule("GlobRule",
|
GlobRule = pctx.StaticRule("GlobRule",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: fmt.Sprintf(`%s -o $out -v %d $args`,
|
Command: fmt.Sprintf(`$globCmd -o $out -v %d $args`,
|
||||||
globCmd, pathtools.BPGlobArgumentVersion),
|
pathtools.BPGlobArgumentVersion),
|
||||||
CommandDeps: []string{globCmd},
|
CommandDeps: []string{"$globCmd"},
|
||||||
Description: "glob",
|
Description: "glob",
|
||||||
|
|
||||||
Restat: true,
|
Restat: true,
|
||||||
Deps: blueprint.DepsGCC,
|
Deps: blueprint.DepsGCC,
|
||||||
Depfile: "$out.d",
|
Depfile: "$out.d",
|
||||||
},
|
},
|
||||||
"args")
|
"args", "globCmd")
|
||||||
)
|
)
|
||||||
|
|
||||||
// GlobFileContext is the subset of ModuleContext and SingletonContext needed by GlobFile
|
// 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,
|
Rule: GlobRule,
|
||||||
Outputs: []string{fileListFile},
|
Outputs: []string{fileListFile},
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"args": args,
|
"args": args,
|
||||||
|
"globCmd": "$primaryBuilderGlobCmd",
|
||||||
},
|
},
|
||||||
Description: "glob " + pattern,
|
Description: "glob " + pattern,
|
||||||
})
|
})
|
||||||
|
@ -112,7 +117,8 @@ func multipleGlobFilesRule(ctx GlobFileContext, fileListFile string, shard int,
|
||||||
Rule: GlobRule,
|
Rule: GlobRule,
|
||||||
Outputs: []string{fileListFile},
|
Outputs: []string{fileListFile},
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"args": args.String(),
|
"args": args.String(),
|
||||||
|
"globCmd": "$bootstrapGlobCmd",
|
||||||
},
|
},
|
||||||
Description: fmt.Sprintf("regenerate globs shard %d of %d", shard, numGlobBuckets),
|
Description: fmt.Sprintf("regenerate globs shard %d of %d", shard, numGlobBuckets),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue