1#!/bin/bash 2 3# Copyright 2020 gRPC authors. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17set -euo pipefail 18 19if ! command -v gawk > /dev/null; then 20 >&2 echo "ERROR: 'gawk' not installed" 21 exit 1 22fi 23 24cd $(dirname $0) 25 26COMMAND="${1:-}" 27 28# parse class and methods 29for FILENAME in call_credentials.c call.c channel.c channel_credentials.c \ 30 server_credentials.c server.c timeval.c ; do 31 CLASS_NAME=$(sed -r 's/(^|_)(\w)/\U\2/g' <<< "${FILENAME%.*}") 32 if [[ "$COMMAND" == "generate" ]]; then 33 echo Generating lib/Grpc/$CLASS_NAME.php ... 34 gawk -f php_extension_doxygen_filter.awk ../ext/grpc/$FILENAME \ 35 > ../lib/Grpc/$CLASS_NAME.php 36 elif [[ "$COMMAND" == "cleanup" ]]; then 37 rm ../lib/Grpc/$CLASS_NAME.php 38 else 39 >&2 echo "Missing or wrong command. Usage: '$(basename $0) <generate|cleanup>'" 40 exit 1 41 fi 42done 43 44# parse constants 45if [[ "$COMMAND" == "generate" ]]; then 46 echo Generating lib/Grpc/Constants.php ... 47 gawk -f php_extension_doxygen_filter.awk ../ext/grpc/php_grpc.c \ 48 > ../lib/Grpc/Constants.php 49elif [[ "$COMMAND" == "cleanup" ]]; then 50 rm ../lib/Grpc/Constants.php 51fi 52