Debian Codegraph @

src/php/bin/php_extension_to_php_doc.sh

raw
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
17 set -euo pipefail
18
19 if ! command -v awk > /dev/null; then
20 >&2 echo "ERROR: 'awk' not installed"
21 exit 1
22 fi
23
24 cd $(dirname $0)
25
26 COMMAND="${1:-}"
27
28 # parse class and methods
29 for FILENAME in call_credentials.c call.c channel.c channel_credentials.c \
30 server_credentials.c server.c timeval.c ; do
31 CLASS_NAME=$(awk -F _ '{for(i=1; i<=NF; i++) printf "%s", toupper(substr($i,1,1)) substr($i, 2);}' \
32 <<< "${FILENAME%.*}")
33 if [[ "$COMMAND" == "generate" ]]; then
34 echo Generating lib/Grpc/$CLASS_NAME.php ...
35 awk -f php_extension_doxygen_filter.awk ../ext/grpc/$FILENAME \
36 > ../lib/Grpc/$CLASS_NAME.php
37 elif [[ "$COMMAND" == "cleanup" ]]; then
38 rm ../lib/Grpc/$CLASS_NAME.php
39 else
40 >&2 echo "Missing or wrong command. Usage: '$(basename $0) <generate|cleanup>'"
41 exit 1
42 fi
43 done
44
45 # parse constants
46 if [[ "$COMMAND" == "generate" ]]; then
47 echo Generating lib/Grpc/Constants.php ...
48 awk -f php_extension_doxygen_filter.awk ../ext/grpc/php_grpc.c \
49 > ../lib/Grpc/Constants.php
50 elif [[ "$COMMAND" == "cleanup" ]]; then
51 rm ../lib/Grpc/Constants.php
52 fi