airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject airavata git commit: AIRAVATA-2432 Add --native-thrift to stub gen script
Date Wed, 07 Jun 2017 21:18:49 GMT
Repository: airavata
Updated Branches:
  refs/heads/thrift-docker 8341d4976 -> 0a59ba002


AIRAVATA-2432 Add --native-thrift to stub gen script


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/0a59ba00
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/0a59ba00
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/0a59ba00

Branch: refs/heads/thrift-docker
Commit: 0a59ba00228e9f5b77823585e21a5e342aab6512
Parents: 8341d49
Author: Marcus Christie <machristie@apache.org>
Authored: Wed Jun 7 17:17:41 2017 -0400
Committer: Marcus Christie <machristie@apache.org>
Committed: Wed Jun 7 17:17:41 2017 -0400

----------------------------------------------------------------------
 .../generate-thrift-stubs.sh                    | 90 +++++++++++++-------
 .../service-cpis/generate-service-cpi-stubs.sh  | 64 +++++++++-----
 2 files changed, 99 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/0a59ba00/thrift-interface-descriptions/generate-thrift-stubs.sh
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/generate-thrift-stubs.sh b/thrift-interface-descriptions/generate-thrift-stubs.sh
index 3723059..ef3076c 100755
--- a/thrift-interface-descriptions/generate-thrift-stubs.sh
+++ b/thrift-interface-descriptions/generate-thrift-stubs.sh
@@ -23,7 +23,7 @@
 #    and Data Model java beans in java, C++, PHP and Python.
 
 show_usage() {
-	echo -e "Usage: $0 [Languague to generate stubs]"
+	echo -e "Usage: $0 [--native-thrift] [Language to generate stubs]"
 	echo ""
 	echo "options:"
 	echo -e "\tjava Generate/Update Java Stubs"
@@ -32,6 +32,7 @@ show_usage() {
 	echo -e "\tpython Generate/Update Python Stubs."
 	echo -e "\tall Generate/Update all stubs (Java, PHP, C++, Python)."
 	echo -e "\t-h[elp] Print the usage options of this script"
+	echo -e "\t--native-thrift Use natively installed thrift instead of Docker image"
 }
 
 if [ $# -lt 1 ]
@@ -48,39 +49,54 @@ fi
 
 REQUIRED_THRIFT_VERSION='0.9.3'
 THRIFT_DOCKER_IMAGE='thrift'
-THRIFT_EXEC="docker run --rm -v $PWD:/data $THRIFT_DOCKER_IMAGE:$REQUIRED_THRIFT_VERSION
thrift"
-
-VERSION=$($THRIFT_EXEC -version 2>/dev/null | grep -F "${REQUIRED_THRIFT_VERSION}" | 
wc -l)
-if [ "$VERSION" -ne 1 ] ; then
-    echo -e "ERROR:\t Apache Thrift version ${REQUIRED_THRIFT_VERSION} is required."
-    echo -e "It is either not installed or is not in the path"
-    exit 1
-fi
+THRIFT_NATIVE="false"
+
+setup() {
+    if [[ $THRIFT_NATIVE == "true" ]]; then
+        if hash thrift &> /dev/null; then
+          THRIFT_EXEC=$(which thrift)
+        else
+          THRIFT_EXEC=/usr/local/bin/thrift
+        fi
+        BASEDIR=""
+    else
+        THRIFT_EXEC="docker run --rm -v $PWD:/data $THRIFT_DOCKER_IMAGE:$REQUIRED_THRIFT_VERSION
thrift"
+        BASEDIR="/data/"
+    fi
+
+    VERSION=$($THRIFT_EXEC -version 2>/dev/null | grep -F "${REQUIRED_THRIFT_VERSION}"
|  wc -l)
+    if [ "$VERSION" -ne 1 ] ; then
+        echo -e "ERROR:\t Apache Thrift version ${REQUIRED_THRIFT_VERSION} is required."
+        echo -e "It is either not installed or is not in the path"
+        exit 1
+    fi
+
+    # Global Constants used across the script
+    AIRAVATA_API_IDL_DIR='airavata-apis'
+    BASE_TARGET_DIR='target'
+
+    # Thrift files
+    AIRAVATA_API_THRIFT_FILE="${BASEDIR}airavata-apis/airavata_api.thrift"
+    DATAMODEL_THRIFT_FILE="${BASEDIR}data-models/airavata_data_models.thrift"
+    APP_CATALOG_THRIFT_FILE="${BASEDIR}data-models/app-catalog-models/app_catalog_models.thrift"
+    RESOURCE_CATALOG_THRIFT_FILE="${BASEDIR}data-models/resource-catalog-models/resource_catalog_models.thrift"
+    WORKFLOW_THRIFT_FILE="${BASEDIR}data-models/workflow-models/workflow_data_model.thrift"
+    PROFILE_SERVICE_THRIFT_FILE="${BASEDIR}service-cpis/profile-service/profile-service-cpi.thrift"
+
+    DATAMODEL_SRC_DIR='../airavata-api/airavata-data-models/src/main/java'
+    JAVA_API_SDK_DIR='../airavata-api/airavata-api-stubs/src/main/java'
+    PHP_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib'
+    CPP_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/'
+    PYTHON_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/'
+
+    # Initialize the thrift arguments.
+    #  Since most of the Airavata API and Data Models have includes, use recursive option
by default.
+    #  Generate all the files in target directory
+    THRIFT_ARGS="-r -o ${BASEDIR}${BASE_TARGET_DIR}"
+    # Ensure the required target directories exists, if not create.
+    mkdir -p ${BASE_TARGET_DIR}
+}
 
-# Global Constants used across the script
-AIRAVATA_API_IDL_DIR='airavata-apis'
-BASE_TARGET_DIR='target'
-
-# Thrift files
-AIRAVATA_API_THRIFT_FILE='/data/airavata-apis/airavata_api.thrift'
-DATAMODEL_THRIFT_FILE='/data/data-models/airavata_data_models.thrift'
-APP_CATALOG_THRIFT_FILE='/data/data-models/app-catalog-models/app_catalog_models.thrift'
-RESOURCE_CATALOG_THRIFT_FILE='/data/data-models/resource-catalog-models/resource_catalog_models.thrift'
-WORKFLOW_THRIFT_FILE='/data/data-models/workflow-models/workflow_data_model.thrift'
-PROFILE_SERVICE_THRIFT_FILE='/data/service-cpis/profile-service/profile-service-cpi.thrift'
-
-DATAMODEL_SRC_DIR='../airavata-api/airavata-data-models/src/main/java'
-JAVA_API_SDK_DIR='../airavata-api/airavata-api-stubs/src/main/java'
-PHP_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-php-sdk/src/main/resources/lib'
-CPP_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-cpp-sdk/src/main/resources/lib/airavata/'
-PYTHON_SDK_DIR='../airavata-api/airavata-client-sdks/airavata-python-sdk/src/main/resources/lib/'
-
-# Initialize the thrift arguments.
-#  Since most of the Airavata API and Data Models have includes, use recursive option by
default.
-#  Generate all the files in target directory
-THRIFT_ARGS="-r -o /data/${BASE_TARGET_DIR}"
-# Ensure the required target directories exists, if not create.
-mkdir -p ${BASE_TARGET_DIR}
 
 # The Function fail prints error messages on failure and quits the script.
 fail() {
@@ -280,23 +296,31 @@ for arg in "$@"
 do
     case "$arg" in
     all)    echo "Generate all stubs (Java, PHP, C++, Python) Stubs"
+            setup
             generate_java_stubs
             generate_php_stubs
             generate_cpp_stubs
             generate_python_stubs
             ;;
     java)   echo "Generating Java Stubs"
+            setup
             generate_java_stubs
             ;;
     php)    echo "Generate PHP Stubs"
+            setup
             generate_php_stubs
             ;;
     cpp)    echo "Generate C++ Stubs"
+            setup
             generate_cpp_stubs
             ;;
     python)    echo "Generate Python Stubs"
+            setup
             generate_python_stubs
             ;;
+    --native-thrift)
+            THRIFT_NATIVE="true"
+            ;;
     *)      echo "Invalid or unsupported option"
     	    show_usage
 	        exit 1

http://git-wip-us.apache.org/repos/asf/airavata/blob/0a59ba00/thrift-interface-descriptions/service-cpis/generate-service-cpi-stubs.sh
----------------------------------------------------------------------
diff --git a/thrift-interface-descriptions/service-cpis/generate-service-cpi-stubs.sh b/thrift-interface-descriptions/service-cpis/generate-service-cpi-stubs.sh
index 574bddd..43ff703 100755
--- a/thrift-interface-descriptions/service-cpis/generate-service-cpi-stubs.sh
+++ b/thrift-interface-descriptions/service-cpis/generate-service-cpi-stubs.sh
@@ -18,12 +18,13 @@
 # This script will generate/regenerate the thrift stubs for Airavata Services: Profile Service.
 
 show_usage() {
-	echo -e "Usage: $0 [Component to generate stubs]"
+	echo -e "Usage: $0 [--native-thrift] [Component to generate stubs]"
 	echo ""
 	echo "options:"
 	echo -e "\tps Generate/Update Profile Service Stubs"
 	echo -e "\tall Generate/Update all stubs (Profile Service)."
 	echo -e "\t-h[elp] Print the usage options of this script"
+	echo -e "\t--native-thrift Use natively installed thrift instead of Docker image"
 }
 
 if [ $# -lt 1 ]
@@ -40,27 +41,41 @@ fi
 
 REQUIRED_THRIFT_VERSION='0.9.3'
 THRIFT_DOCKER_IMAGE='thrift'
-THRIFT_EXEC="docker run --rm -v $PWD/..:/data $THRIFT_DOCKER_IMAGE:$REQUIRED_THRIFT_VERSION
thrift"
-
-VERSION=$($THRIFT_EXEC -version 2>/dev/null | grep -F "${REQUIRED_THRIFT_VERSION}" | 
wc -l)
-if [ "$VERSION" -ne 1 ] ; then
-    echo -e "ERROR:\t Apache Thrift version ${REQUIRED_THRIFT_VERSION} is required."
-    echo -e "It is either not installed or is not in the path"
-    exit 1
-fi
-
-# Global Constants used across the script
-BASE_TARGET_DIR='target'
-
-PROFILE_SERVICE_THRIFT_FILE='/data/service-cpis/profile-service/profile-service-cpi.thrift'
-PROFILE_SERVICE_SRC_DIR='../../airavata-services/profile-service/profile-service-stubs/src/main/java'
-
-# Initialize the thrift arguments.
-#  Since most of the Airavata API and Data Models have includes, use recursive option by
default.
-#  Generate all the files in target directory
-THRIFT_ARGS="-r -o /data/service-cpis/${BASE_TARGET_DIR}"
-# Ensure the required target directories exists, if not create.
-mkdir -p ${BASE_TARGET_DIR}
+THRIFT_NATIVE="false"
+
+setup() {
+    if [[ $THRIFT_NATIVE == "true" ]]; then
+        if hash thrift &> /dev/null; then
+          THRIFT_EXEC=$(which thrift)
+        else
+          THRIFT_EXEC=/usr/local/bin/thrift
+        fi
+        BASEDIR=""
+    else
+        THRIFT_EXEC="docker run --rm -v $PWD/..:/data $THRIFT_DOCKER_IMAGE:$REQUIRED_THRIFT_VERSION
thrift"
+        BASEDIR="/data/service-cpis/"
+    fi
+
+    VERSION=$($THRIFT_EXEC -version 2>/dev/null | grep -F "${REQUIRED_THRIFT_VERSION}"
|  wc -l)
+    if [ "$VERSION" -ne 1 ] ; then
+        echo -e "ERROR:\t Apache Thrift version ${REQUIRED_THRIFT_VERSION} is required."
+        echo -e "It is either not installed or is not in the path"
+        exit 1
+    fi
+
+    # Global Constants used across the script
+    BASE_TARGET_DIR='target'
+
+    PROFILE_SERVICE_THRIFT_FILE="${BASEDIR}profile-service/profile-service-cpi.thrift"
+    PROFILE_SERVICE_SRC_DIR='../../airavata-services/profile-service/profile-service-stubs/src/main/java'
+
+    # Initialize the thrift arguments.
+    #  Since most of the Airavata API and Data Models have includes, use recursive option
by default.
+    #  Generate all the files in target directory
+    THRIFT_ARGS="-r -o ${BASEDIR}${BASE_TARGET_DIR}"
+    # Ensure the required target directories exists, if not create.
+    mkdir -p ${BASE_TARGET_DIR}
+}
 
 # The Funcation fail prints error messages on failure and quits the script.
 fail() {
@@ -154,11 +169,16 @@ for arg in "$@"
 do
     case "$arg" in
     all)    echo "Generate all (profile service) Stubs"
+            setup
             generate_thrift_stubs ${PROFILE_SERVICE_THRIFT_FILE} ${PROFILE_SERVICE_SRC_DIR}
             ;;
     ps)   echo "Generating Profile Service Stubs"
+            setup
             generate_thrift_stubs ${PROFILE_SERVICE_THRIFT_FILE} ${PROFILE_SERVICE_SRC_DIR}
             ;;
+    --native-thrift)
+            THRIFT_NATIVE="true"
+            ;;
     *)      echo "Invalid or unsupported option"
     	    show_usage
 	        exit 1


Mime
View raw message