Skip to content

Commit b42cb3a

Browse files
committed
cross-platform: Improve clang error reporting with build.sh
Fixes chakra-core#954
1 parent cc27070 commit b42cb3a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,20 @@ if [[ ${#_VERBOSE} > 0 ]]; then
110110
echo ""
111111
fi
112112

113+
CLANG_PATH=
113114
if [[ ${#_CXX} > 0 || ${#_CC} > 0 ]]; then
115+
if [[ ${#_CXX} == 0 || ${#_CC} == 0 ]]; then
116+
echo "ERROR: '-cxx' and '-cc' options must be used together."
117+
exit 1
118+
fi
114119
echo "Custom CXX ${_CXX}"
115120
echo "Custom CC ${_CC}"
116121

117122
if [[ ! -f $_CXX || ! -f $_CC ]]; then
118123
echo "ERROR: Custom compiler not found on given path"
119124
exit 1
120125
fi
126+
CLANG_PATH=$_CXX
121127
else
122128
RET_VAL=$(SAFE_RUN 'c++ --version')
123129
if [[ ! $RET_VAL =~ "clang" ]]; then
@@ -126,16 +132,28 @@ else
126132
echo "Clang++ found at /usr/bin/clang++"
127133
_CXX=/usr/bin/clang++
128134
_CC=/usr/bin/clang
135+
CLANG_PATH=$_CXX
129136
else
130137
echo "ERROR: clang++ not found at /usr/bin/clang++"
131138
echo ""
132139
echo "You could use clang++ from a custom location."
133140
PRINT_USAGE
134141
exit 1
135142
fi
143+
else
144+
CLANG_PATH=c++
136145
fi
137146
fi
138147

148+
# check clang version (min required 3.7)
149+
VERSION=$($CLANG_PATH --version | grep "version [0-9]*\.[0-9]*" --o -i | grep "[0-9]\.[0-9]*" --o)
150+
VERSION=${VERSION/./}
151+
152+
if [[ $VERSION -lt 37 ]]; then
153+
echo "ERROR: Minimum required Clang version is 3.7"
154+
exit 1
155+
fi
156+
139157
CC_PREFIX=""
140158
if [[ ${#_CXX} > 0 ]]; then
141159
CC_PREFIX="-DCMAKE_CXX_COMPILER=$_CXX -DCMAKE_C_COMPILER=$_CC"

0 commit comments

Comments
 (0)