generate-protobuf.sh 953 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. set -euo pipefail
  3. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
  4. ROOT="$DIR/../"
  5. PROTOC=protoc
  6. INPUT_DIR="${ROOT}app/src/protobuf/"
  7. INPUT_FILE="${INPUT_DIR}call-signaling.proto"
  8. OUTPUT_DIR="${ROOT}app/src/main/java/"
  9. # Function to check whether a command exists or not
  10. command_exists() { command -v "$1" >/dev/null 2>&1 ; }
  11. # Ensure that protoc is installed
  12. if ! command_exists $PROTOC; then
  13. echo "ERROR: Protobuf compiler \"$PROTOC\" not found in your PATH"
  14. exit 1
  15. fi
  16. # Ensure that protobuf file exists
  17. if [ ! -f "$INPUT_FILE" ]; then
  18. echo "ERROR: Protobuf file $INPUT_FILE not found."
  19. echo "Did you clone the git submodule?"
  20. echo ""
  21. echo " $ git submodule update --init"
  22. exit 2
  23. fi
  24. echo "Config:"
  25. echo " Input dir: $INPUT_DIR"
  26. echo " Output dir: $OUTPUT_DIR"
  27. echo "Running $PROTOC..."
  28. $PROTOC \
  29. -I=$INPUT_DIR \
  30. --java_out=lite:$OUTPUT_DIR \
  31. $INPUT_FILE
  32. echo "Done!"