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:
@@ -47,6 +47,7 @@ var (
|
|||||||
cc string
|
cc string
|
||||||
run string
|
run string
|
||||||
benchRun string
|
benchRun string
|
||||||
|
buildOut string
|
||||||
debugBinary bool
|
debugBinary bool
|
||||||
coverage bool
|
coverage bool
|
||||||
long bool
|
long bool
|
||||||
@@ -374,6 +375,7 @@ func parseFlags() {
|
|||||||
flag.StringVar(&run, "run", "", "Specify which tests to run")
|
flag.StringVar(&run, "run", "", "Specify which tests to run")
|
||||||
flag.StringVar(&benchRun, "bench", "", "Specify which benchmarks to run")
|
flag.StringVar(&benchRun, "bench", "", "Specify which benchmarks to run")
|
||||||
flag.BoolVar(&withNextGenGUI, "with-next-gen-gui", withNextGenGUI, "Also build 'newgui'")
|
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()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,6 +508,9 @@ func build(target target, tags []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
args := []string{"build", "-v"}
|
args := []string{"build", "-v"}
|
||||||
|
if buildOut != "" {
|
||||||
|
args = append(args, "-o", buildOut)
|
||||||
|
}
|
||||||
args = appendParameters(args, tags, target.buildPkgs...)
|
args = appendParameters(args, tags, target.buildPkgs...)
|
||||||
runPrint(goCmd, args...)
|
runPrint(goCmd, args...)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user