@@ -24,7 +24,7 @@ const (
24
24
25
25
func main () {
26
26
log .SetFlags (log .Lshortfile )
27
- buildMode , tags := parseFlags ()
27
+ buildMode , tags , output := parseFlags ()
28
28
cwd , err := os .Getwd ()
29
29
if err != nil {
30
30
log .Fatal ("could not get working directory:" , err )
@@ -43,7 +43,7 @@ func main() {
43
43
const (
44
44
goBin = "go"
45
45
goBuild = "build"
46
- maxArgs = 4
46
+ maxArgs = 5
47
47
)
48
48
goArgs := make ([]string , 1 , maxArgs )
49
49
goArgs [0 ] = goBuild
@@ -61,6 +61,9 @@ func main() {
61
61
if tags != "" {
62
62
goArgs = append (goArgs , "-tags=" + tags )
63
63
}
64
+ if output != "" {
65
+ goArgs = append (goArgs , "-o=" + output )
66
+ }
64
67
goArgs = append (goArgs , pkgFSPath )
65
68
cmd := exec .Command (goBin , goArgs ... )
66
69
cmd .Stdin = os .Stdin
@@ -76,7 +79,7 @@ func main() {
76
79
}
77
80
}
78
81
79
- func parseFlags () (buildMode , string ) {
82
+ func parseFlags () (mode buildMode , tags string , output string ) {
80
83
const (
81
84
regularUsage = "standard go build with no compiler or linker flags when building"
82
85
releaseUsage = "remove extra debugging data when building"
@@ -86,7 +89,6 @@ func parseFlags() (buildMode, string) {
86
89
var (
87
90
cmdName = commandName ()
88
91
flagSet = flag .NewFlagSet (cmdName , flag .ExitOnError )
89
- mode = release
90
92
modeUsage = fmt .Sprintf (
91
93
"%s\t - %s" +
92
94
"\n %s\t - %s" +
@@ -97,12 +99,12 @@ func parseFlags() (buildMode, string) {
97
99
debug .String (), debugUsage ,
98
100
)
99
101
)
102
+ mode = release
100
103
flagSet .Func (modeName , modeUsage , func (arg string ) (err error ) {
101
104
mode , err = generic .ParseEnum (regular , debug , arg )
102
105
return
103
106
})
104
107
flagSet .Lookup (modeName ).DefValue = mode .String ()
105
- var tags string
106
108
const (
107
109
tagName = "tags"
108
110
tagsUsage = "a comma-separated list of build tags" +
@@ -111,6 +113,12 @@ func parseFlags() (buildMode, string) {
111
113
"\n noipfs - build without IPFS guest support"
112
114
)
113
115
flagSet .StringVar (& tags , tagName , "" , tagsUsage )
116
+ const (
117
+ outputName = "o"
118
+ outputUsage = "write the resulting executable" +
119
+ " to the named output file or directory"
120
+ )
121
+ flagSet .StringVar (& output , outputName , "" , outputUsage )
114
122
if err := flagSet .Parse (os .Args [1 :]); err != nil {
115
123
log .Fatal (err )
116
124
}
@@ -123,7 +131,7 @@ func parseFlags() (buildMode, string) {
123
131
output .String (),
124
132
)
125
133
}
126
- return mode , tags
134
+ return
127
135
}
128
136
129
137
func commandName () string {
0 commit comments