blob: e86ca07a687c1ed3d5e36d2987bedc8a8c5cbec8 [file] [log] [blame]
Joshua Haberman8b870752021-05-04 10:19:22 -07001#!/bin/bash
2
3set -e
4
5cd `dirname $0`
6
Joshua Haberman45e97072021-05-12 10:42:16 -07007./prepare_c_extension.sh
8
9if ../src/protoc --help > /dev/null; then
10 PROTOC=src/protoc
11else
12 (cd .. && bazel build -c opt :protoc)
13 PROTOC=bazel-bin/protoc
14fi
15
16
17if [[ -d tmp && -z $(find tests/proto ../$PROTOC -newer tmp) ]]; then
Joshua Haberman8b870752021-05-04 10:19:22 -070018 # 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
Joshua Haberman45e97072021-05-12 10:42:16 -070029cd ..
30find php/tests/proto -type f -name "*.proto"| xargs $PROTOC --php_out=php/tmp -Isrc -Iphp/tests
Joshua Haberman8b870752021-05-04 10:19:22 -070031
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"
Joshua Haberman45e97072021-05-12 10:42:16 -070035 $PROTOC --php_out=aggregate_metadata=foo#bar:php/tmp -Isrc -Iphp/tests $AGGREGATED_FILES
Joshua Haberman8b870752021-05-04 10:19:22 -070036fi
37
38echo "Generated test protos from tests/proto -> tmp"