Skip to content

Commit

Permalink
add quick build as primary build method
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed May 14, 2022
1 parent 5c2338c commit ce16d1a
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,14 @@ func (bin *Binary) WriteBuild(writer io.Writer) error {
return err
}

err = bin.buildBinary(dir)
err = bin.quickBuildBinary(dir)
if err != nil {
return err
log.Println("Failed to quick build, attempting manual build")
err = bin.buildBinary(dir)
if err != nil {
log.Println("Failed to manual build as fell")
return err
}
}

f, err := os.Open(bin.Dest)
Expand Down Expand Up @@ -163,6 +168,24 @@ func (bin *Binary) runModTidy(dir string) error {
return command(cmd)
}

func (bin *Binary) quickBuildBinary(dir string) error {
dst, err := tempFilename()

if err != nil {
return err
}

bin.Dest = dst
cmd := exec.Command("go", "build", "-o", bin.Dest, bin.Module)
cmd.Env = environ()
cmd.Env = append(cmd.Env, "CGO_ENABLED=0")
cmd.Env = append(cmd.Env, "GOOS="+bin.OS)
cmd.Env = append(cmd.Env, "GOARCH="+bin.Arch)
cmd.Dir = dir
return command(cmd)

}

func (bin *Binary) buildBinary(dir string) error {
dst, err := tempFilename()

Expand Down

0 comments on commit ce16d1a

Please sign in to comment.