Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ type builder struct {
binary string
errors string
useGodep bool
useGb bool
}

func NewBuilder(dir string, bin string, useGodep bool) Builder {
func NewBuilder(dir string, bin string, useGodep bool, useGb bool) Builder {
if len(bin) == 0 {
bin = "bin"
}
Expand All @@ -32,7 +33,7 @@ func NewBuilder(dir string, bin string, useGodep bool) Builder {
}
}

return &builder{dir: dir, binary: bin, useGodep: useGodep}
return &builder{dir: dir, binary: bin, useGodep: useGodep, useGb: useGb}
}

func (b *builder) Binary() string {
Expand All @@ -47,6 +48,8 @@ func (b *builder) Build() error {
var command *exec.Cmd
if b.useGodep {
command = exec.Command("godep", "go", "build", "-o", b.binary)
} else if b.useGb {
command = exec.Command("gb", "build")
} else {
command = exec.Command("go", "build", "-o", b.binary)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func Test_Builder_Build_Success(t *testing.T) {
bin += ".exe"
}

builder := gin.NewBuilder(wd, bin, false)
builder := gin.NewBuilder(wd, bin, false, false)
err := builder.Build()
expect(t, err, nil)

Expand Down
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func main() {
cli.StringFlag{
Name: "bin,b",
Value: "gin-bin",
Usage: "name of generated binary file",
Usage: "name of generated binary file. If using gb, absolute path to binary file.",
},
cli.StringFlag{
Name: "path,t",
Expand All @@ -58,6 +58,10 @@ func main() {
Name: "godep,g",
Usage: "use godep when building",
},
cli.BoolFlag{
Name: "usegb,gb",
Usage: "use gb when building",
},
}
app.Commands = []cli.Command{
{
Expand Down Expand Up @@ -93,8 +97,14 @@ func MainAction(c *cli.Context) {
logger.Fatal(err)
}

builder := gin.NewBuilder(c.GlobalString("path"), c.GlobalString("bin"), c.GlobalBool("godep"))
runner := gin.NewRunner(filepath.Join(wd, builder.Binary()), c.Args()...)
builder := gin.NewBuilder(c.GlobalString("path"), c.GlobalString("bin"), c.GlobalBool("godep"), c.GlobalBool("gb"))

binFilepath := filepath.Join(wd, builder.Binary())
if c.GlobalBool("gb") {
binFilepath = builder.Binary()
}
runner := gin.NewRunner(binFilepath, c.Args()...)

runner.SetWriter(os.Stdout)
proxy := gin.NewProxy(builder, runner)

Expand Down