-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.go
51 lines (44 loc) · 1.16 KB
/
build.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
package main
import (
"flag"
"log"
"os"
"os/exec"
"path/filepath"
)
var releaseFlag bool
var platformFlag string
func init() {
flag.BoolVar(&releaseFlag, "release", false, "Compile the build in release mode.")
flag.StringVar(&platformFlag, "platform", "desktop", "Target platform (desktop, android).")
flag.Parse()
}
func runAt(dir string, command string, args ...string) {
cmd := exec.Command(command, args...)
cmd.Dir = dir
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stdout
log.Println(cmd.String())
if err := cmd.Run(); err != nil {
log.Fatalln(err)
}
}
func run(command string, args ...string) {
runAt("", command, args...)
}
func main() {
const kExeName = "meowyplayer.exe"
if platformFlag == "desktop" {
if releaseFlag {
run("fyne", "package", "--src", "source", "--exe", kExeName, "--release") //-o has missing icon bug
run("mv", filepath.Join("source", kExeName), ".")
} else {
runAt("source", "go", "build", "-o", filepath.Join("..", kExeName), "main.go")
run("./meowyplayer")
}
} else {
runAt("source", "fyne", "package", "--os", platformFlag, "--release")
run("mv", filepath.Join("source", kExeName), ".")
}
}