aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsir...@apache.org
Subject aurora git commit: Improve `thriftw` robustness.
Date Tue, 17 Jan 2017 21:20:18 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 6eda8c8af -> 4e92be4cd


Improve `thriftw` robustness.

Now the selected thrift is checked both for the proper version and
support of the gen langs Aurora requires. In addition, all thrifts on
the `PATH` are and an existing locally built thrift is always verified
to protect Aurora thrift requirement changes (if we ever add a gen lang
again).

Bugs closed: AURORA-1875

Reviewed at https://reviews.apache.org/r/55536/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/4e92be4c
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/4e92be4c
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/4e92be4c

Branch: refs/heads/master
Commit: 4e92be4cdc67c899c25e1b6157915b1f21d49f65
Parents: 6eda8c8
Author: John Sirois <jsirois@apache.org>
Authored: Tue Jan 17 14:20:15 2017 -0700
Committer: John Sirois <john.sirois@gmail.com>
Committed: Tue Jan 17 14:20:15 2017 -0700

----------------------------------------------------------------------
 build-support/thrift/thriftw | 54 ++++++++++++++++++++++++++++++---------
 1 file changed, 42 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/4e92be4c/build-support/thrift/thriftw
----------------------------------------------------------------------
diff --git a/build-support/thrift/thriftw b/build-support/thrift/thriftw
index 1185298..278576f 100755
--- a/build-support/thrift/thriftw
+++ b/build-support/thrift/thriftw
@@ -27,22 +27,52 @@ shift
 
 HERE=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
 
-if which thrift >/dev/null 2>&1; then
-  if [[ $(thrift --version) = "Thrift version $expected_version" ]]; then
-    if [[ "$@" == "--which" ]]; then
-      exec which thrift
-    else
-      exec thrift "$@"
+function check_thrift_version() {
+  local readonly thrift="$1"
+
+  [[ $("${thrift}" --version) = "Thrift version ${expected_version}" ]]
+}
+
+function check_thrift_gen_lang() {
+  local readonly thrift="$1"
+  local readonly gen_identifier="$2"
+
+  "${thrift}" -help 2>&1 | grep -q "${gen_identifier}:"
+}
+
+function compatible_thrift() {
+  local readonly thrift="$1"
+
+  [[ -x "${thrift}" ]] && \
+  check_thrift_version "${thrift}" && \
+  check_thrift_gen_lang "${thrift}" "java (Java)" && \
+  check_thrift_gen_lang "${thrift}" "py (Python)"
+}
+
+function compatible_system_thrift() {
+  which -a thrift | while read thrift; do
+    if compatible_thrift "${thrift}"; then
+       echo "${thrift}"
+       return
+    fi
+  done
+}
+
+thrift="$(compatible_system_thrift)"
+if [[ -z "${thrift}" ]]; then
+  thrift="${HERE}/thrift-${expected_version}/compiler/cpp/thrift"
+  if ! compatible_thrift "${thrift}"; then
+    make -C "${HERE}" clean
+    make -C "${HERE}"
+    if ! compatible_thrift "${thrift}"; then
+      echo "Failed to find or build a thrift binary compatible with Aurora requirements!"
+      exit 1
     fi
   fi
 fi
 
-thrift="$HERE"/thrift-$expected_version/compiler/cpp/thrift
-if [[ ! -x "$thrift" ]]; then
-  make -C "$HERE"
-fi
 if [[ "$@" == "--which" ]]; then
-  echo "$thrift"
+  echo "${thrift}"
 else
-  exec "$thrift" "$@"
+  exec "${thrift}" "$@"
 fi


Mime
View raw message