-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdarwinBuild.go
67 lines (62 loc) · 1.23 KB
/
darwinBuild.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package go_chrome_build
import (
"bytes"
"errors"
"fmt"
"go/build"
"log"
"os"
"os/exec"
)
func darwinPackDarwin() {
fmt.Println("拼命开发中...")
}
func darwinPackWindows(architecture ...string) {
architectureName := "amd64" // 386
if len(architecture) != 0 {
if architecture[0] == "amd64" {
} else if architecture[0] == "386" {
architectureName = "386"
} else {
panic("architecture error")
}
}
//conf := getConfig()
gp := os.Getenv("GOPATH")
if len(gp) == 0 {
gp = build.Default.GOPATH
}
args := []string{
"build",
"-ldflags",
"-H windowsgui",
//"-o",
//fmt.Sprintf("./output/%s.exe", conf.Name),
}
fmt.Println("Build Windows " + architectureName)
var cmd = exec.Command("go", args...)
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Env = os.Environ()
cmd.Dir = GetWorkingDirPath()
cmd.Stdout = &out
cmd.Stderr = &stderr
cmd.Env = append(cmd.Env,
"CGO_ENABLED=0",
"GOOS=windows",
"GOARCH="+architectureName,
"GOPATH="+gp,
//"GOARCH=",
)
err := cmd.Run()
log.Println(cmd.Args)
if err != nil {
msg := fmt.Sprint(err) + ": " + stderr.String()
err = errors.New(msg)
EchoError(err.Error())
}
log.Println(out.String())
}
func darwinPackLinux() {
fmt.Println("拼命开发中...")
}