| 21 | ) |
| 22 | |
| 23 | func gopyMakeCmdBuild() *commander.Command { |
| 24 | cmd := &commander.Command{ |
| 25 | Run: gopyRunCmdBuild, |
| 26 | UsageLine: "build <go-package-name> [other-go-package...]", |
| 27 | Short: "generate and compile (C)Python language bindings for Go", |
| 28 | Long: ` |
| 29 | build generates and compiles (C)Python language bindings for Go package(s). |
| 30 | |
| 31 | ex: |
| 32 | $ gopy build [options] <go-package-name> [other-go-package...] |
| 33 | $ gopy build github.com/go-python/gopy/_examples/hi |
| 34 | `, |
| 35 | Flag: *flag.NewFlagSet("gopy-build", flag.ExitOnError), |
| 36 | } |
| 37 | |
| 38 | cmd.Flag.String("vm", "python", "path to python interpreter") |
| 39 | cmd.Flag.String("output", "", "output directory for bindings") |
| 40 | cmd.Flag.String("name", "", "name of output package (otherwise name of first package is used)") |
| 41 | cmd.Flag.String("main", "", "code string to run in the go main() function in the cgo library") |
| 42 | cmd.Flag.String("package-prefix", ".", "custom package prefix used when generating import "+ |
| 43 | "statements for generated package") |
| 44 | cmd.Flag.Bool("rename", false, "rename Go symbols to python PEP snake_case") |
| 45 | cmd.Flag.Bool("symbols", true, "include symbols in output") |
| 46 | cmd.Flag.Bool("no-warn", false, "suppress warning messages, which may be expected") |
| 47 | cmd.Flag.Bool("no-make", false, "do not generate a Makefile, e.g., when called from Makefile") |
| 48 | cmd.Flag.Bool("dynamic-link", false, "whether to link output shared library dynamically to Python") |
| 49 | cmd.Flag.String("build-tags", "", "build tags to be passed to `go build`") |
| 50 | return cmd |
| 51 | } |
| 52 | |
| 53 | func gopyRunCmdBuild(cmdr *commander.Command, args []string) error { |
| 54 | if len(args) == 0 { |