Skip to content

Commit

Permalink
cross-platform: Improve clang error reporting with build.sh
Browse files Browse the repository at this point in the history
Fixes #954
  • Loading branch information
obastemur committed Jun 1, 2016
1 parent cc27070 commit b42cb3a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,20 @@ if [[ ${#_VERBOSE} > 0 ]]; then
echo ""
fi

CLANG_PATH=
if [[ ${#_CXX} > 0 || ${#_CC} > 0 ]]; then
if [[ ${#_CXX} == 0 || ${#_CC} == 0 ]]; then
echo "ERROR: '-cxx' and '-cc' options must be used together."
exit 1
fi
echo "Custom CXX ${_CXX}"
echo "Custom CC ${_CC}"

if [[ ! -f $_CXX || ! -f $_CC ]]; then
echo "ERROR: Custom compiler not found on given path"
exit 1
fi
CLANG_PATH=$_CXX
else
RET_VAL=$(SAFE_RUN 'c++ --version')
if [[ ! $RET_VAL =~ "clang" ]]; then
Expand All @@ -126,16 +132,28 @@ else
echo "Clang++ found at /usr/bin/clang++"
_CXX=/usr/bin/clang++
_CC=/usr/bin/clang
CLANG_PATH=$_CXX
else
echo "ERROR: clang++ not found at /usr/bin/clang++"
echo ""
echo "You could use clang++ from a custom location."
PRINT_USAGE
exit 1
fi
else
CLANG_PATH=c++
fi
fi

# check clang version (min required 3.7)
VERSION=$($CLANG_PATH --version | grep "version [0-9]*\.[0-9]*" --o -i | grep "[0-9]\.[0-9]*" --o)
VERSION=${VERSION/./}

if [[ $VERSION -lt 37 ]]; then
echo "ERROR: Minimum required Clang version is 3.7"
exit 1
fi

CC_PREFIX=""
if [[ ${#_CXX} > 0 ]]; then
CC_PREFIX="-DCMAKE_CXX_COMPILER=$_CXX -DCMAKE_C_COMPILER=$_CC"
Expand Down

0 comments on commit b42cb3a

Please sign in to comment.