diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-09-01 09:15:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-01 09:15:22 -0700 |
commit | a37ec7adfbf0832c08839751f1ce7bbe5de4de05 (patch) | |
tree | 52b167c5f57587cb84fbb6c9c2d05b554b4fe0aa /src/pal/tools | |
parent | 5952512f68e10241ab1cc31d55dc91f42cf37ac2 (diff) | |
download | coreclr-a37ec7adfbf0832c08839751f1ce7bbe5de4de05.tar.gz coreclr-a37ec7adfbf0832c08839751f1ce7bbe5de4de05.tar.bz2 coreclr-a37ec7adfbf0832c08839751f1ce7bbe5de4de05.zip |
Revert "Avoid using 'which' for verifying prereqs"
Diffstat (limited to 'src/pal/tools')
-rwxr-xr-x | src/pal/tools/gen-buildsys-clang.sh | 92 |
1 files changed, 45 insertions, 47 deletions
diff --git a/src/pal/tools/gen-buildsys-clang.sh b/src/pal/tools/gen-buildsys-clang.sh index 9871d7c033..b7945f3091 100755 --- a/src/pal/tools/gen-buildsys-clang.sh +++ b/src/pal/tools/gen-buildsys-clang.sh @@ -3,31 +3,35 @@ # This file invokes cmake and generates the build system for Clang. # -if [ $# -lt 4 -o $# -gt 8 ]; then - echo "Usage..." - echo "gen-buildsys-clang.sh <path to top level CMakeLists.txt> <ClangMajorVersion> <ClangMinorVersion> <Architecture> [build flavor] [coverage] [ninja] [cmakeargs]" - echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP" - echo "Specify the clang version to use, split into major and minor version" - echo "Specify the target architecture." - echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG." - echo "Optionally specify 'coverage' to enable code coverage build." - echo "Target ninja instead of make. ninja must be on the PATH." - echo "Pass additional arguments to CMake call." - exit 1 +if [ $# -lt 4 -o $# -gt 8 ] +then + echo "Usage..." + echo "gen-buildsys-clang.sh <path to top level CMakeLists.txt> <ClangMajorVersion> <ClangMinorVersion> <Architecture> [build flavor] [coverage] [ninja] [cmakeargs]" + echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP" + echo "Specify the clang version to use, split into major and minor version" + echo "Specify the target architecture." + echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG." + echo "Optionally specify 'coverage' to enable code coverage build." + echo "Target ninja instead of make. ninja must be on the PATH." + echo "Pass additional arguments to CMake call." + exit 1 fi # Set up the environment to be used for building with clang. -if hash "clang-$2.$3" 2>/dev/null; then - export CC="clang-$2.$3" - export CXX="clang++-$2.$3" -elif hash "clang$2$3" 2>/dev/null; then - export CC="clang$2$3" - export CXX="clang++$2$3" -elif hash clang 2>/dev/null; then - export CC="clang" - export CXX="clang++" +if which "clang-$2.$3" > /dev/null 2>&1 + then + export CC="$(which clang-$2.$3)" + export CXX="$(which clang++-$2.$3)" +elif which "clang$2$3" > /dev/null 2>&1 + then + export CC="$(which clang$2$3)" + export CXX="$(which clang++$2$3)" +elif which clang > /dev/null 2>&1 + then + export CC="$(which clang)" + export CXX="$(which clang++)" else - echo "Unable to find Clang compiler" + echo "Unable to find Clang Compiler" exit 1 fi @@ -64,22 +68,19 @@ done OS=`uname` # Locate llvm -# -# This can be a little complicated, because the common use case of Ubuntu with +# This can be a little complicated, because the common use-case of Ubuntu with # llvm-3.5 installed uses a rather unusual llvm installation with the version -# number postfixed (e.g. llvm-ar-3.5), so we check for that first. -# -# On FreeBSD, the version number is appended to the name without the dot and -# the dash (e.g. llvm-ar35). -# -# OS X doesn't use the llvm- prefix. +# number postfixed (i.e. llvm-ar-3.5), so we check for that first. +# On FreeBSD the version number is appended without point and dash (i.e. +# llvm-ar35). +# Additionally, OSX doesn't use the llvm- prefix. if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $OS = "SunOS" ]; then - llvm_prefix="llvm-" + llvm_prefix="llvm-" elif [ $OS = "Darwin" ]; then - llvm_prefix="" + llvm_prefix="" else - echo "Unable to determine build platform" - exit 1 + echo "Unable to determine build platform" + exit 1 fi desired_llvm_major_version=$2 @@ -93,29 +94,26 @@ elif [ $OS = "NetBSD" ]; then elif [ $OS = "SunOS" ]; then desired_llvm_version="" else - desired_llvm_version="-$desired_llvm_major_version.$desired_llvm_minor_version" + desired_llvm_version="-$desired_llvm_major_version.$desired_llvm_minor_version" fi - -locate_llvm_exec() -{ - if hash "$llvm_prefix$1$desired_llvm_version" 2>/dev/null; then - echo "$(command -v $llvm_prefix$1$desired_llvm_version)" - elif hash "$llvm_prefix$1" 2>/dev/null; then - echo "$(command -v $llvm_prefix$1)" - else - exit 1 - fi +locate_llvm_exec() { + if which "$llvm_prefix$1$desired_llvm_version" > /dev/null 2>&1 + then + echo "$(which $llvm_prefix$1$desired_llvm_version)" + elif which "$llvm_prefix$1" > /dev/null 2>&1 + then + echo "$(which $llvm_prefix$1)" + else + exit 1 + fi } llvm_ar="$(locate_llvm_exec ar)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-ar"; exit 1; } - llvm_link="$(locate_llvm_exec link)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-link"; exit 1; } - llvm_nm="$(locate_llvm_exec nm)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-nm"; exit 1; } - if [ $OS = "Linux" -o $OS = "FreeBSD" -o $OS = "OpenBSD" -o $OS = "NetBSD" -o $OS = "SunOS" ]; then llvm_objdump="$(locate_llvm_exec objdump)" [[ $? -eq 0 ]] || { echo "Unable to locate llvm-objdump"; exit 1; } |