This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for running one off protobuf compiles
Add support for running a single one off protobuf compile run of all proto files of an input directory, using the renamed protobuf-compiler image (previously protobuf-watcher).
- Loading branch information
Showing
4 changed files
with
86 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
INPUT_DIRECTORY="" | ||
OUTPUT_DIRECTORY="" | ||
ROOT_NS_DIRECTORY="" | ||
|
||
print_help() { | ||
echo "Usage: $0 -i INPUT_DIRECTORY -o OUTPUT_DIRECTORY [-n ROOT_NS_DIRECTORY]" | ||
exit 2 | ||
} | ||
|
||
while getopts "i:o:n:" c; do | ||
case $c in | ||
i) INPUT_DIRECTORY=$OPTARG ;; | ||
o) OUTPUT_DIRECTORY=$OPTARG ;; | ||
n) ROOT_NS_DIRECTORY=$OPTARG ;; | ||
*) print_help ;; | ||
esac | ||
done | ||
|
||
# Generate temp path for file generation | ||
TMP_OUTPUT_DIRECTORY=$(mktemp -d) | ||
|
||
# Generate files | ||
find "$INPUT_DIRECTORY" -name "*.proto" -type f -prune -printf 'Building %p\n' -exec protoc \ | ||
--proto_path="$INPUT_DIRECTORY" \ | ||
--php_out="$TMP_OUTPUT_DIRECTORY" \ | ||
--grpc_out="$TMP_OUTPUT_DIRECTORY" \ | ||
--plugin=protoc-gen-grpc=/usr/bin/grpc_php_plugin \ | ||
{} \; | ||
|
||
# Relocate files, accounting for root namespace | ||
rsync -a "$TMP_OUTPUT_DIRECTORY/$ROOT_NS_DIRECTORY" "$OUTPUT_DIRECTORY" | ||
|
||
# Delete any temp files left behind | ||
rm -rf "$TMP_OUTPUT_DIRECTORY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters