mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go: inject State parameter into work.runBuild
This command modifies the call tree starting at `work.runBuild` and `work.runInstall` to inject a `State` parameter to every function that is currently using the global `modload.LoaderState` variable. By explicilty passing a `State` parameter, we can begin to eliminate the usage of the global `modload.LoaderState`. This commit is part of the overall effort to eliminate global modloader state. [git-generate] cd src/cmd/go/internal/work rf 'inject modload.LoaderState runBuild' cd .. ./rf-cleanup.zsh # cd work # rf 'inject modload.LoaderState runInstall' # cd .. # ./rf-cleanup.zsh Change-Id: I232452d877211d4ac72f42aa193b30dab9649481 Reviewed-on: https://go-review.googlesource.com/c/go/+/709990 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Michael Matloob <matloob@google.com>
This commit is contained in:
parent
d9e6f95450
commit
e94a5008f6
2 changed files with 4 additions and 4 deletions
|
|
@ -1112,12 +1112,12 @@ func (b *Builder) addInstallHeaderAction(a *Action) {
|
|||
|
||||
// buildmodeShared takes the "go build" action a1 into the building of a shared library of a1.Deps.
|
||||
// That is, the input a1 represents "go build pkgs" and the result represents "go build -buildmode=shared pkgs".
|
||||
func (b *Builder) buildmodeShared(mode, depMode BuildMode, args []string, pkgs []*load.Package, a1 *Action) *Action {
|
||||
func (b *Builder) buildmodeShared(loaderstate *modload.State, mode, depMode BuildMode, args []string, pkgs []*load.Package, a1 *Action) *Action {
|
||||
name, err := libname(args, pkgs)
|
||||
if err != nil {
|
||||
base.Fatalf("%v", err)
|
||||
}
|
||||
return b.linkSharedAction(modload.LoaderState, mode, depMode, name, a1)
|
||||
return b.linkSharedAction(loaderstate, mode, depMode, name, a1)
|
||||
}
|
||||
|
||||
// linkSharedAction takes a grouping action a1 corresponding to a list of built packages
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ func runBuild(ctx context.Context, cmd *base.Command, args []string) {
|
|||
a.Deps = append(a.Deps, b.AutoAction(modload.LoaderState, ModeBuild, depMode, p))
|
||||
}
|
||||
if cfg.BuildBuildmode == "shared" {
|
||||
a = b.buildmodeShared(ModeBuild, depMode, args, pkgs, a)
|
||||
a = b.buildmodeShared(modload.LoaderState, ModeBuild, depMode, args, pkgs, a)
|
||||
}
|
||||
b.Do(ctx, a)
|
||||
}
|
||||
|
|
@ -819,7 +819,7 @@ func InstallPackages(ctx context.Context, patterns []string, pkgs []*load.Packag
|
|||
// tools above did not apply, and a is just a simple Action
|
||||
// with a list of Deps, one per package named in pkgs,
|
||||
// the same as in runBuild.
|
||||
a = b.buildmodeShared(ModeInstall, ModeInstall, patterns, pkgs, a)
|
||||
a = b.buildmodeShared(modload.LoaderState, ModeInstall, ModeInstall, patterns, pkgs, a)
|
||||
}
|
||||
|
||||
b.Do(ctx, a)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue