Skip to content

Commit

Permalink
feat(make): Use different make binaries for different distributions
Browse files Browse the repository at this point in the history
Signed-off-by: Cezar Craciunoiu <[email protected]>
  • Loading branch information
craciunoiuc committed Aug 25, 2023
1 parent 0223d4d commit 4ff3fce
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions make/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ import (
"context"
"fmt"
"reflect"
"runtime"
"strings"

"github.com/cli/safeexec"

"kraftkit.sh/exec"
)

const DefaultBinaryName = "make"
const (
DefaultBinaryName = "make"
DefaultDarwinBinaryName = "gmake"
DefaultWindowsBinaryName = "nmake"
)

type export struct {
export string
Expand Down Expand Up @@ -93,7 +100,21 @@ func NewFromInterface(args interface{}, mopts ...MakeOption) (*Make, error) {
}

if len(make.opts.bin) == 0 {
make.opts.bin = DefaultBinaryName
switch runtime.GOOS {
case "darwin":
// Check if gmake is installed
// If not, fall back to make
_, err := safeexec.LookPath(DefaultDarwinBinaryName)
if err != nil {
make.opts.bin = DefaultBinaryName
} else {
make.opts.bin = DefaultDarwinBinaryName
}
case "windows":
make.opts.bin = DefaultWindowsBinaryName
default:
make.opts.bin = DefaultBinaryName
}
}

var processes []*exec.Process
Expand Down

0 comments on commit 4ff3fce

Please sign in to comment.