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