1#!/bin/bash 2 3set -ex 4 5cd `dirname $0` 6 7if ../src/protoc --help > /dev/null; then 8 PROTOC=src/protoc 9else 10 # Bazel seems to be creating a problematic symlink in 11 # _build/out/external/com_google_protobuf, so we remove the _build directory 12 # before building protoc. 13 (cd .. && bazel build -c opt :protoc) 14 PROTOC=bazel-bin/protoc 15fi 16 17if [[ -d tmp && -z $(find tests/proto ../$PROTOC -newer tmp) ]]; then 18 # Generated protos are already present and up to date, so we can skip protoc. 19 # 20 # Protoc is very fast, but sometimes it is not available (like if we haven't 21 # built it in Docker). Skipping it helps us proceed in this case. 22 echo "Test protos are up-to-date, skipping protoc." 23 exit 0 24fi 25 26rm -rf tmp 27mkdir -p tmp 28 29cd .. 30find php/tests/proto -type f -name "*.proto"| xargs $PROTOC --php_out=php/tmp -Isrc -Iphp/tests 31 32if [ "$1" = "--aggregate_metadata" ]; then 33 # Overwrite some of the files to use aggregation. 34 AGGREGATED_FILES="tests/proto/test.proto tests/proto/test_include.proto tests/proto/test_import_descriptor_proto.proto" 35 $PROTOC --php_out=aggregate_metadata=foo#bar:php/tmp -Isrc -Iphp/tests $AGGREGATED_FILES 36fi 37 38echo "Generated test protos from tests/proto -> tmp" 39