-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefreebsd.go
51 lines (42 loc) · 1.07 KB
/
makefreebsd.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
//go:build ignore
// +build ignore
package main
import (
"log"
"os"
"os/exec"
"strings"
)
func main() {
cmd := exec.Command("go", "test")
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
if err := cmd.Run(); err != nil {
log.Fatalf("error $v\n", err)
}
version := getGitVersion()
// GOOS=freebsd GOARCH=amd64
cgi := []string{}
cgi = append(cgi, "build", "-o", "dicewords.cgi")
cgi = append(cgi, "-ldflags", "-X github.com/timothyham/dicewords.VersionString="+version)
cgi = append(cgi, "github.com/timothyham/dicewords/cmd/dicewords-cgi")
cmd = exec.Command("go", cgi...)
cmd.Env = append(os.Environ(),
"GOOS=freebsd", "GOARCH=amd64",
)
if out, err := cmd.CombinedOutput(); err != nil {
log.Fatalf("error %v: %v\n", err, string(out))
}
}
func getGitVersion() string {
_, err := exec.LookPath("git")
if err != nil {
return "git binary not found during build"
}
cmd := exec.Command("git", "rev-parse", "--short", "HEAD")
out, err := cmd.Output()
if err != nil {
log.Fatalf("Couldn't get git version: %v", err)
}
return strings.TrimSpace(string(out))
}