You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemall.apache.org by ya...@apache.org on 2017/01/25 03:20:51 UTC

incubator-hivemall git commit: Close #24: Print explicit error messages in building xgboost with clang

Repository: incubator-hivemall
Updated Branches:
  refs/heads/master d95f1e79d -> 6e6b184a5


Close #24: Print explicit error messages in building xgboost with clang


Project: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/commit/6e6b184a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/tree/6e6b184a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hivemall/diff/6e6b184a

Branch: refs/heads/master
Commit: 6e6b184a5387b0a94a362e49e520fccb0ab35cae
Parents: d95f1e7
Author: Takeshi YAMAMURO <li...@gmail.com>
Authored: Tue Jan 24 18:20:29 2017 +0900
Committer: Takeshi YAMAMURO <li...@gmail.com>
Committed: Tue Jan 24 18:20:29 2017 +0900

----------------------------------------------------------------------
 bin/build_xgboost.sh | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hivemall/blob/6e6b184a/bin/build_xgboost.sh
----------------------------------------------------------------------
diff --git a/bin/build_xgboost.sh b/bin/build_xgboost.sh
index 29069b9..6d384b5 100755
--- a/bin/build_xgboost.sh
+++ b/bin/build_xgboost.sh
@@ -18,8 +18,30 @@
 # under the License.
 #
 
-set -e
-set -o pipefail
+# xgboost requires g++-4.6 or higher (https://github.com/dmlc/xgboost/blob/master/doc/build.md),
+# so we need to first check if the requirement is satisfied.
+COMPILER_REQUIRED_VERSION="4.6"
+COMPILER_VERSION=`g++ --version 2> /dev/null`
+
+# Check if GNU g++ installed
+if [ $? = 127 ]; then
+  echo "First, you need to install g++"
+  exit 1
+elif [[ "$COMPILER_VERSION" = *LLVM* ]]; then
+  echo "You must use GNU g++, but the detected compiler was clang++"
+  exit 1
+fi
+
+COMPILER_VERSION_NUMBER=`echo $COMPILER_VERSION | grep ^g++ | \
+  awk 'match($0, /[0-9]+\.[0-9]+\.[0-9]+/) {print substr($0, RSTART, RLENGTH)}'`
+
+# See simple version normalization: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
+function version { echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
+if [ $(version $COMPILER_VERSION_NUMBER) -lt $(version $COMPILER_REQUIRED_VERSION) ]; then
+  echo "You must compile xgboost with GNU g++-$COMPILER_REQUIRED_VERSION or higher," \
+    "but the detected compiler was g++-$COMPILER_VERSION_NUMBER"
+  exit 1
+fi
 
 # Target commit hash value
 XGBOOST_HASHVAL='7ab15a0b31c870c7779691639f521df3ccd4a56e'