From 18dbefd34099a883c8f89b38d5e8a762443785a0 Mon Sep 17 00:00:00 2001 From: lwch Date: Tue, 2 Nov 2021 19:12:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81build=5Fall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/build/build_all.go | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/contrib/build/build_all.go b/contrib/build/build_all.go index c0af3c6..941c5c7 100644 --- a/contrib/build/build_all.go +++ b/contrib/build/build_all.go @@ -175,33 +175,24 @@ func build(t target) { fmt.Sprintf("GOARCH=%s", t.arch)) runtime.Assert(cmd.Run()) - logging.Info("build client(no vnc)...") - cmd = exec.Command("go", "build", "-o", path.Join(buildDir, "np-cli"+t.ext), - "-ldflags", ldflags, - path.Join("code", "client", "main.go"), - path.Join("code", "client", "connect.go")) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Env = append(os.Environ(), + logging.Info("build client...") + env := append(os.Environ(), fmt.Sprintf("GOOS=%s", t.os), fmt.Sprintf("GOARCH=%s", t.arch), fmt.Sprintf("CC=%s", t.cc), fmt.Sprintf("CXX=%s", t.cxx)) - runtime.Assert(cmd.Run()) - - logging.Info("build client(vnc)...") - cmd = exec.Command("go", "build", "-o", path.Join(buildDir, "np-cli"+".vnc"+t.ext), - "-ldflags", ldflags, - "-tags", "vnc", + args := []string{"build", "-o", path.Join(buildDir, "np-cli"+t.ext), "-ldflags", ldflags} + if t.os == "windows" && (t.arch == "amd64" || t.arch == "386") { + args = append(args, "-tags", "vnc") + env = append(env, "CGO_ENABLED=1") + } + args = append(args, path.Join("code", "client", "main.go"), path.Join("code", "client", "connect.go")) + cmd = exec.Command("go", args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - cmd.Env = append(os.Environ(), - fmt.Sprintf("GOOS=%s", t.os), - fmt.Sprintf("GOARCH=%s", t.arch), - fmt.Sprintf("CC=%s", t.cc), - fmt.Sprintf("CXX=%s", t.cxx)) + cmd.Env = env runtime.Assert(cmd.Run()) logging.Info("packing...")