45
45
cmd .Flag .Bool ("no-warn" , false , "suppress warning messages, which may be expected" )
46
46
cmd .Flag .Bool ("no-make" , false , "do not generate a Makefile, e.g., when called from Makefile" )
47
47
cmd .Flag .Bool ("dynamic-link" , false , "whether to link output shared library dynamically to Python" )
48
+ cmd .Flag .String ("build-tags" , "" , "build tags to be passed to `go build`" )
48
49
return cmd
49
50
}
50
51
@@ -66,6 +67,7 @@ func gopyRunCmdBuild(cmdr *commander.Command, args []string) error {
66
67
cfg .NoWarn = cmdr .Flag .Lookup ("no-warn" ).Value .Get ().(bool )
67
68
cfg .NoMake = cmdr .Flag .Lookup ("no-make" ).Value .Get ().(bool )
68
69
cfg .DynamicLinking = cmdr .Flag .Lookup ("dynamic-link" ).Value .Get ().(bool )
70
+ cfg .BuildTags = cmdr .Flag .Lookup ("build-tags" ).Value .Get ().(string )
69
71
70
72
bind .NoWarn = cfg .NoWarn
71
73
bind .NoMake = cfg .NoMake
@@ -129,7 +131,12 @@ func runBuild(mode bind.BuildMode, cfg *BuildCfg) error {
129
131
cmd = exec .Command (cfg .VM , "build.py" )
130
132
cmd .Run () // will fail, we don't care about errors
131
133
132
- args := []string {"build" , "-mod=mod" , "-buildmode=c-shared" , "-o" , buildname + libExt , "." }
134
+ args := []string {"build" , "-mod=mod" , "-buildmode=c-shared" }
135
+ if cfg .BuildTags != "" {
136
+ args = append (args , "-tags" , cfg .BuildTags )
137
+ }
138
+ args = append (args , "-o" , buildname + libExt , "." )
139
+
133
140
fmt .Printf ("go %v\n " , strings .Join (args , " " ))
134
141
cmd = exec .Command ("go" , args ... )
135
142
cmdout , err = cmd .CombinedOutput ()
@@ -149,7 +156,11 @@ func runBuild(mode bind.BuildMode, cfg *BuildCfg) error {
149
156
err = os .Remove (cfg .Name + "_go" + libExt )
150
157
151
158
fmt .Printf ("go build -o py%s\n " , cfg .Name )
152
- cmd = exec .Command ("go" , "build" , "-mod=mod" , "-o" , "py" + cfg .Name )
159
+ cmd = exec .Command ("go" , "build" , "-mod=mod" )
160
+ if cfg .BuildTags != "" {
161
+ args = append (args , "-tags" , cfg .BuildTags )
162
+ }
163
+ args = append (args , "-o" , "py" + cfg .Name )
153
164
cmdout , err = cmd .CombinedOutput ()
154
165
if err != nil {
155
166
fmt .Printf ("cmd had error: %v output:\n %v\n " , err , string (cmdout ))
@@ -170,6 +181,9 @@ func runBuild(mode bind.BuildMode, cfg *BuildCfg) error {
170
181
// build the go shared library upfront to generate the header
171
182
// needed by our generated cpython code
172
183
args := []string {"build" , "-mod=mod" , "-buildmode=c-shared" }
184
+ if cfg .BuildTags != "" {
185
+ args = append (args , "-tags" , cfg .BuildTags )
186
+ }
173
187
if ! cfg .Symbols {
174
188
// These flags will omit the various symbol tables, thereby
175
189
// reducing the final size of the binary. From https://golang.org/cmd/link/
0 commit comments