Commit 0cb7fed1 authored by lichenchong's avatar lichenchong
Browse files

Clean up syncProtoFromRepoBuild.sh

parent db8e6217
Loading
Loading
Loading
Loading
+37 −29
Original line number Diff line number Diff line
@@ -3,31 +3,27 @@ BASE_DIR=`dirname "$0"`/..
BASE_DIR=`cd "$BASE_DIR"; pwd`
#echo "BASE_DIR=$BASE_DIR"

PROTO_REPO_URL=https://github.com/Seagate/Kinetic-Protocol.git
PROTO_DIR=$BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/
PROTO_FILE=$BASE_DIR/kinetic-common/src/main/java/com/seagate/kinetic/proto/kinetic.proto
CLONE_DIR=$BASE_DIR/bin/Kinetic-ProtocoL
PROTO_COMPILE_DIR=$BASE_DIR/kinetic-common/src/main/java/

if [ -f "$PROTO_FILE" ]; then
    echo "$PROTO_FILE exists, does not sync and build, exit."
    exit 0
fi

function syncFromProtoRepo(){
    if [ -d "$CLONE_DIR" ]; then
        rm -rf "$CLONE_DIR"
    fi

    if [ $# -eq 0 ]; then
        echo "Clone protocol file from github:"
    git clone https://github.com/Seagate/Kinetic-Protocol.git $CLONE_DIR
        git clone $PROTO_REPO_URL $CLONE_DIR
    fi

    if [ $# -eq 1 ]; then
        echo "Clone protocol file $1 from github:"
    git clone https://github.com/Seagate/Kinetic-Protocol.git $CLONE_DIR
        git clone $PROTO_REPO_URL $CLONE_DIR
        cd $CLONE_DIR
        git checkout $1
    echo "$1"
    fi

    cp $CLONE_DIR/kinetic.proto $PROTO_FILE
@@ -35,7 +31,9 @@ cp $CLONE_DIR/kinetic.proto $PROTO_FILE
    rm -rf "$CLONE_DIR"

    echo "Sync protocol file finished."
}

function compileProto(){
    echo "Compile protocol file: $PROTO_FILE."
    protoc --proto_path=$PROTO_DIR --java_out=$PROTO_COMPILE_DIR $PROTO_FILE

@@ -46,5 +44,15 @@ echo "Compile protocol file: $PROTO_DIR/kineticIo.proto."
    protoc --proto_path=$PROTO_DIR --java_out=$PROTO_COMPILE_DIR $PROTO_DIR/kineticIo.proto

    echo "Compile finished."
}

if [ -f "$PROTO_FILE" ]; then
    echo "$PROTO_FILE exists, does not sync from repo."
else
    echo "$PROTO_FILE does not exists, sync from repo"
    syncFromProtoRepo
fi

compileProto

exit 0
 No newline at end of file