aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2016-09-22 21:31:39 -0700
committerGravatar Yuchen Zeng <zyc@google.com>2016-09-22 21:31:39 -0700
commit2383a4129da6641e3fb0d9f7c4d1059d43851b8c (patch)
treef6161e912334f590b131cad6bd63ac92ec2fe377
parent27e96f9beb04084686b179ee65503d6a7f8ad1b7 (diff)
Check protoc and grpc_cpp_plugin
-rwxr-xr-xtools/codegen/extensions/gen_reflection_proto.sh29
1 files changed, 24 insertions, 5 deletions
diff --git a/tools/codegen/extensions/gen_reflection_proto.sh b/tools/codegen/extensions/gen_reflection_proto.sh
index d55272803f..db997556ec 100755
--- a/tools/codegen/extensions/gen_reflection_proto.sh
+++ b/tools/codegen/extensions/gen_reflection_proto.sh
@@ -29,20 +29,39 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+set -e
+cd $(dirname $0)/../../..
+
PROTO_DIR="src/proto/grpc/reflection/v1alpha"
PROTO_FILE="reflection"
HEADER_DIR="include/grpc++/ext"
SRC_DIR="src/cpp/ext"
INCLUDE_DIR="grpc++/ext"
TMP_DIR="tmp"
-GRPC_PLUGIN="bins/opt/grpc_cpp_plugin"
-PROTOC="bins/opt/protobuf/protoc"
-set -e
+if hash grpc_cpp_plugin 2>/dev/null; then
+ GRPC_PLUGIN=$(which grpc_cpp_plugin)
+else
+ if [ -f bins/opt/grpc_cpp_plugin ]; then
+ GRPC_PLUGIN="bins/opt/grpc_cpp_plugin"
+ else
+ echo "gRPC protoc plugin not found"
+ exit 1
+ fi
+fi
-TMP_DIR=${TMP_DIR}_${PROTO_FILE}
+if hash protoc 2>/dev/null; then
+ PROTOC=$(which protoc)
+else
+ if [ -f bins/opt/protobuf/protoc ]; then
+ PROTOC="bins/opt/protobuf/protoc"
+ else
+ echo "protoc not found"
+ exit 1
+ fi
+fi
-cd $(dirname $0)/../../..
+TMP_DIR=${TMP_DIR}_${PROTO_FILE}
[ ! -d $HEADER_DIR ] && mkdir -p $HEADER_DIR || :
[ ! -d $SRC_DIR ] && mkdir -p $SRC_DIR || :