build: Add an option to specify output dir for crosscompiling all (#8109)

When GOBIN is set, 'go install' cannot install cross-compilied binaries.
To satisfy cross-compilation, it's necessary to add the '-o' to build
target, otherwise 'go build' will discarding the resulting objects when
compiling multiple packages.

Signed-off-by: bekcpear <i@bitbili.net>
This commit is contained in:
Ryan Qian 2022-01-13 16:57:23 +08:00 committed by GitHub
parent 1242ac74ab
commit 40bb52fdd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -47,6 +47,7 @@ var (
cc string
run string
benchRun string
buildOut string
debugBinary bool
coverage bool
long bool
@ -374,6 +375,7 @@ func parseFlags() {
flag.StringVar(&run, "run", "", "Specify which tests to run")
flag.StringVar(&benchRun, "bench", "", "Specify which benchmarks to run")
flag.BoolVar(&withNextGenGUI, "with-next-gen-gui", withNextGenGUI, "Also build 'newgui'")
flag.StringVar(&buildOut, "build-out", "", "Set the '-o' value for 'go build'")
flag.Parse()
}
@ -506,6 +508,9 @@ func build(target target, tags []string) {
}
args := []string{"build", "-v"}
if buildOut != "" {
args = append(args, "-o", buildOut)
}
args = appendParameters(args, tags, target.buildPkgs...)
runPrint(goCmd, args...)
}