1#!/bin/sh 2# Copyright 2015 gRPC authors. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16set -e 17cd $(dirname $0)/../../.. 18 19# protoc and grpc_*_plugin binaries can be obtained by running 20# $ bazel build @com_google_protobuf//:protoc //src/compiler:all 21PROTOC=bazel-bin/external/com_google_protobuf/protoc 22PLUGIN=protoc-gen-grpc=bazel-bin/src/compiler/grpc_php_plugin 23 24$PROTOC --proto_path=src/proto/math \ 25 --php_out=src/php/tests/generated_code \ 26 --grpc_out=src/php/tests/generated_code \ 27 --plugin=$PLUGIN \ 28 src/proto/math/math.proto 29 30# replace the Empty message with EmptyMessage 31# because Empty is a PHP reserved word 32output_file=$(mktemp) 33sed 's/message Empty/message EmptyMessage/g' \ 34 src/proto/grpc/testing/empty.proto > $output_file 35mv $output_file ./src/proto/grpc/testing/empty.proto 36sed 's/grpc\.testing\.Empty/grpc\.testing\.EmptyMessage/g' \ 37 src/proto/grpc/testing/test.proto > $output_file 38mv $output_file ./src/proto/grpc/testing/test.proto 39 40# interop test protos 41$PROTOC --proto_path=. \ 42 --php_out=src/php/tests/interop \ 43 --grpc_out=src/php/tests/interop \ 44 --plugin=$PLUGIN \ 45 src/proto/grpc/testing/messages.proto \ 46 src/proto/grpc/testing/empty.proto \ 47 src/proto/grpc/testing/test.proto 48 49# change it back 50sed 's/message EmptyMessage/message Empty/g' \ 51 src/proto/grpc/testing/empty.proto > $output_file 52mv $output_file ./src/proto/grpc/testing/empty.proto 53sed 's/grpc\.testing\.EmptyMessage/grpc\.testing\.Empty/g' \ 54 src/proto/grpc/testing/test.proto > $output_file 55mv $output_file ./src/proto/grpc/testing/test.proto 56 57# Hack for xDS interop: need this to be a separate file in the correct namespace. 58# To be removed when grpc_php_plugin generates service stubs. 59echo '<?php 60// DO NOT EDIT 61namespace Grpc\Testing; 62class LoadBalancerStatsServiceStub { 63} 64' > ./src/php/tests/interop/Grpc/Testing/LoadBalancerStatsServiceStub.php 65