forked from gomatcha/matcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
140 lines (126 loc) · 4.64 KB
/
main.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Package matcha provides the implementation for the matcha command line tool.
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"gomatcha.io/matcha/cmd"
)
func main() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
var RootCmd = &cobra.Command{
Use: "matcha",
Short: "Matcha is a tool for building iOS apps in Go",
Long: `Matcha is a tool for building iOS apps in Go.
Complete documentation is available at https://gomatcha.io`,
}
var (
buildN bool // -n
buildX bool // -x
buildV bool // -v
buildWork bool // -work
buildGcflags string // -gcflags
buildLdflags string // -ldflags
buildO string // -o
buildBinary bool // -binary
buildTargets string // --targets
)
func init() {
flags := InitCmd.Flags()
flags.BoolVar(&buildN, "n", false, "print the commands but do not run them.")
flags.BoolVar(&buildX, "x", false, "print the commands.")
flags.BoolVar(&buildV, "v", false, "print the names of packages as they are compiled.")
flags.BoolVar(&buildWork, "work", false, "print the name of the temporary work directory and do not delete it when exiting.")
flags.StringVar(&buildGcflags, "gcflags", "", "arguments to pass on each go tool compile invocation.")
flags.StringVar(&buildLdflags, "ldflags", "", "arguments to pass on each go tool link invocation.")
RootCmd.AddCommand(InitCmd)
}
var InitCmd = &cobra.Command{
Use: "init",
Short: "Install the mobile compiler toolchain",
Long: ``,
Run: func(command *cobra.Command, args []string) {
flags := &cmd.Flags{
BuildN: buildN,
BuildX: buildX,
BuildV: buildV,
BuildWork: buildWork,
BuildGcflags: buildGcflags,
BuildLdflags: buildLdflags,
BuildTargets: buildTargets,
}
if err := cmd.Init(flags); err != nil {
fmt.Println(err)
}
},
}
func init() {
flags := BuildCmd.Flags()
flags.BoolVar(&buildN, "n", false, "print the commands but do not run them.")
flags.BoolVar(&buildX, "x", false, "print the commands.")
flags.BoolVar(&buildV, "v", false, "print the names of packages as they are compiled.")
flags.BoolVar(&buildWork, "work", false, "print the name of the temporary work directory and do not delete it when exiting.")
flags.StringVar(&buildGcflags, "gcflags", "", "arguments to pass on each go tool compile invocation.")
flags.StringVar(&buildLdflags, "ldflags", "", "arguments to pass on each go tool link invocation.")
flags.StringVar(&buildTargets, "targets", "", "space separated os/arch. Valid values are: android, ios, android/arm, android/arm64, android/386, android/amd64, ios/arm, ios/arm64, ios/386, ios/amd64.")
RootCmd.AddCommand(BuildCmd)
}
var BuildCmd = &cobra.Command{
Use: "build",
Short: "Builds the Matcha static library",
Long: ``,
Run: func(command *cobra.Command, args []string) {
flags := &cmd.Flags{
BuildN: buildN,
BuildX: buildX,
BuildV: buildV,
BuildWork: buildWork,
BuildGcflags: buildGcflags,
BuildLdflags: buildLdflags,
BuildTargets: buildTargets,
}
if err := cmd.Build(flags, args); err != nil {
fmt.Println(err)
}
},
}
/*
func init() {
flags := InstallCmd.Flags()
flags.BoolVar(&buildN, "n", false, "print the commands but do not run them.")
flags.BoolVar(&buildX, "x", false, "print the commands.")
flags.BoolVar(&buildV, "v", false, "print the names of packages as they are compiled.")
flags.BoolVar(&buildBinary, "b", false, "builds only the binary.")
flags.BoolVar(&buildWork, "work", false, "print the name of the temporary work directory and do not delete it when exiting.")
flags.StringVar(&buildGcflags, "gcflags", "", "arguments to pass on each go tool compile invocation.")
flags.StringVar(&buildLdflags, "ldflags", "", "arguments to pass on each go tool link invocation.")
flags.StringVar(&buildO, "output", "", "forces build to write the resulting object to the named output file.")
flags.StringVar(&buildTargets, "targets", "", "space separated os/arch. Valid values are: android, darwin, android/arm, android/arm64, android/386, android/amd64, darwin/arm, darwin/arm64, darwin/386, darwin/amd64.")
RootCmd.AddCommand(InstallCmd)
}
var InstallCmd = &cobra.Command{
Use: "install",
Short: "Builds the Matcha static library and copies iOS frameworks to a directory",
Long: ``,
Run: func(command *cobra.Command, args []string) {
flags := &cmd.Flags{
BuildN: buildN,
BuildX: buildX,
BuildV: buildV,
BuildWork: buildWork,
BuildGcflags: buildGcflags,
BuildLdflags: buildLdflags,
BuildO: buildO,
BuildBinary: buildBinary,
BuildTargets: buildTargets,
}
if err := cmd.Bind(flags, args); err != nil {
fmt.Println(err)
}
},
}
*/