#!/bin/bash

# this build file uses protoc to build all protocol buffers
# http://code.google.com/p/protobuf/downloads/list


TARGET_CPP="$TARGET/cpp"
TARGET_JAVA="$TARGET/java"

mkdir -p "$TARGET_CPP"
mkdir -p "$TARGET_JAVA"

# if you don't want to put protoc on the command line,
# then set a PROTOC environment variable
if [ -z $PROTOC] ; then
    PROTOC="protoc"
fi

command -v $PROTOC >/dev/null 2>&1 || { echo >&2 "protoc is required but not installed.  Aborting"; exit 1; }

# die on error at this point
set -e

echo "building cpp protocol buffers"
$PROTOC $PROTO_FILES --cpp_out=$TARGET_CPP --proto_path=$SRC
echo "building java protocol buffers"
$PROTOC $PROTO_FILES --java_out=$TARGET_JAVA --proto_path=$SRC
