diff options
author | Ayke van Laethem <[email protected]> | 2019-05-21 15:12:33 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-05-24 19:53:43 +0200 |
commit | 5a7bab8808b5dd75dc6e988501ba735b5b5198eb (patch) | |
tree | 4a32a28f30dfd06db875e9d3ce1c271d415cc6c4 | |
parent | 3a73e6455741390ed772ee7ad2a99cf3b95a5157 (diff) | |
download | tinygo-5a7bab8808b5dd75dc6e988501ba735b5b5198eb.tar.gz tinygo-5a7bab8808b5dd75dc6e988501ba735b5b5198eb.zip |
main: add the absolute path to clang-8 on macOS
This avoids the need to correctly set $PATH if LLVM 8 has been installed
using Homebrew.
-rw-r--r-- | commands.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/commands.go b/commands.go index 5f7ff8c1e..523b8a748 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...) |