Skip to content

Commit ec41e19

Browse files
Used os::log functions better in protobuf script
Previously it was pretty difficult to determine if the script was exiting with a failure or not as the same error message was printed in either case and the error message was not given a log level. These changes should make it a lot easier to determine if the script failed and why and also let a user know about `$PROTO_OPTIONAL` when it fails if they wish to skip the script. Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 97275c6 commit ec41e19

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

hack/update-generated-protobuf.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#!/bin/bash
22
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
33

4-
if ! os::util::find::system_binary 'protoc' || [[ "$(protoc --version)" != "libprotoc 3.0."* ]]; then
5-
echo "Generating protobuf requires protoc 3.0.x. Please download and"
6-
echo "install the platform appropriate Protobuf package for your OS: "
7-
echo
8-
echo " https://github.com/google/protobuf/releases"
9-
echo
10-
if [[ "${PROTO_OPTIONAL:-}" == "1" ]]; then
11-
exit 0
12-
fi
13-
exit 1
4+
if [[ "${PROTO_OPTIONAL:-}" == "1" ]]; then
5+
os::log::warn "Skipping protobuf generation as \$PROTO_OPTIONAL is set."
6+
exit 0
7+
fi
8+
9+
os::util::ensure::system_binary_exists 'protoc'
10+
if [[ "$(protoc --version)" != "libprotoc 3.0."* ]]; then
11+
os::log::fatal "Generating protobuf requires protoc 3.0.x. Please download and
12+
install the platform appropriate Protobuf package for your OS:
13+
14+
https://github.com/google/protobuf/releases
15+
16+
To skip protobuf generation, set \$PROTO_OPTIONAL."
1417
fi
1518

1619
os::util::ensure::system_binary_exists 'goimports'

0 commit comments

Comments
 (0)