Commit e33751fb authored by Mislav Marohnić's avatar Mislav Marohnić
Browse files

Improve detecting LLVM 3.5 from Homebrew

The main "llvm" Homebrew package is occasionally getting updated and is
not guaranteed to be version 3.5. Right now it's 3.6, but that depends
on the version of Homebrew that someone has installed.

This lists through all installed Homebrew packages named "llvm*" and
tests each `llvm-config --version` for "3.5*" until it finds one.
parent e932d471
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -812,12 +812,13 @@ require_llvm() {
  local llvm_version="$1"
  if [ "$(uname -s)" = "Darwin" ] && [ "$(osx_version)" -ge 1010 ]; then
    if [[ "$RUBY_CONFIGURE_OPTS" != *--llvm-* ]]; then
      if [ "$llvm_version" = "3.2" ]; then
      case "$llvm_version" in
      3.2 )
        package_option ruby configure --prebuilt-name="llvm-3.2-x86_64-apple-darwin13.tar.bz2"
      else
        local llvm_prefix="$(brew --prefix llvm 2>/dev/null || true)"
        local llvm_config="${llvm_prefix}/bin/llvm-config"
        if [ -x "$llvm_config" ]; then
        ;;
      3.5 )
        local llvm_config="$(locate_llvm "$llvm_version")"
        if [ -n "$llvm_config" ]; then
          package_option ruby configure --llvm-config="$llvm_config"
        else
          { echo
@@ -833,9 +834,24 @@ require_llvm() {
          } >&3
          return 1
        fi
        ;;
      esac
    fi
  fi
}

locate_llvm() {
  local llvm_version="$1"
  local package llvm_config
  shopt -s nullglob
  for package in `brew list 2>/dev/null | grep "^llvm"`; do
    llvm_config="$(echo "$(brew --prefix "$package")/bin/llvm-config"*)"
    if [ -n "$llvm_config" ] && [[ "$("$llvm_config" --version)" = "$llvm_version"* ]]; then
      echo "$llvm_config"
      break
    fi
  done
  shopt -u nullglob
}

needs_yaml() {