From 40bb52fdd86ac96c1a5cfbf4c962b40981154aa7 Mon Sep 17 00:00:00 2001 From: Ryan Qian Date: Thu, 13 Jan 2022 16:57:23 +0800 Subject: [PATCH] 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 --- build.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.go b/build.go index c2e105939..7888c834d 100644 --- a/build.go +++ b/build.go @@ -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...) }