diff --git a/commands.go b/commands.go index 5f7ff8c1..523b8a74 100644 --- a/commands.go +++ b/commands.go @@ -4,6 +4,7 @@ import ( "errors" "os" "os/exec" + "runtime" "strings" ) @@ -15,6 +16,16 @@ var commands = map[string][]string{ "wasm-ld": {"wasm-ld-8", "wasm-ld"}, } +func init() { + // Add the path to a Homebrew-installed LLVM 8 for ease of use (no need to + // manually set $PATH). + if runtime.GOOS == "darwin" { + commands["clang"] = append(commands["clang"], "/usr/local/opt/llvm/bin/clang-8") + commands["ld.lld"] = append(commands["ld.lld"], "/usr/local/opt/llvm/bin/ld.lld") + commands["wasm-ld"] = append(commands["wasm-ld"], "/usr/local/opt/llvm/bin/wasm-ld") + } +} + func execCommand(cmdNames []string, args ...string) error { for _, cmdName := range cmdNames { cmd := exec.Command(cmdName, args...)