Skip to content

Commit

Permalink
chore: update codegen to only run once
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
  • Loading branch information
aarnphm committed Sep 26, 2022
1 parent eb71f1a commit b12f94c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
6 changes: 0 additions & 6 deletions grpc-client/go/client
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ set -e

pushd .. >/dev/null

! [[ -d "thirdparty" ]] && mkdir thirdparty

pushd thirdparty >/dev/null
! [[ -d "protobuf" ]] && git clone --depth 1 https://github.com/protocolbuffers/protobuf.git
popd

if ! $(which protoc-gen-go-grpc &>/dev/null); then
echo "protoc-gen-go-grpc is missing. Make sure to install it and add it to your PATH."
exit 1
Expand Down
16 changes: 7 additions & 9 deletions grpc-client/php/codegen
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@

set -e

pushd .. >/dev/null

! [[ -d "thirdparty" ]] && mkdir thirdparty
pushd "$(dirname "$0")"/../.. >/dev/null

pushd thirdparty >/dev/null
! [[ -d "protobuf" ]] && git clone -b v3.19.4 https://github.com/protocolbuffers/protobuf.git
popd
pushd .. >/dev/null
# We will use BentoML tools/bazel.rc
echo "Building shared C++ gRPC..."
bazel build @com_github_grpc_grpc//:all
bazel build @com_google_protobuf//:protoc

if ! [ -f "bazel-bin/src/compiler/grpc_php_plugin" ]; then
echo "We will compile grpc_php_plugin from source."
bazel build @com_github_grpc_grpc//src/compiler:grpc_php_plugin
fi

PROTOC=$(pwd)/bazel-bin/external/com_google_protobuf/protoc
PLUGIN=protoc-gen-grpc=$(pwd)/bazel-bin/src/compiler/grpc_php_plugin
popd
popd >/dev/null

pushd .. >/dev/null

echo "Generate PHP stubs."
"$PROTOC" -I . -I ./thirdparty/protobuf/src --php_out=php --grpc_out=php --plugin="$PLUGIN" bentoml/grpc/v1alpha1/service.proto

popd
popd >/dev/null
6 changes: 0 additions & 6 deletions grpc-client/swift/client
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ set -e

pushd .. >/dev/null

! [[ -d "thirdparty" ]] && mkdir thirdparty

pushd thirdparty >/dev/null
! [[ -d "protobuf" ]] && git clone --depth 1 https://github.com/protocolbuffers/protobuf.git
popd

if ! $(which protoc-gen-grpc-swift &>/dev/null); then
echo "protoc-gen-grpc-swift is missing. Make sure to compile it first and add it to your PATH."
exit 1
Expand Down
8 changes: 8 additions & 0 deletions tools/bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,13 @@ if [ ! -x "${filename_abs}" ]; then
chmod a+x "${filename_abs}"
fi

pushd ../grpc-client >/dev/null
! [[ -d "thirdparty" ]] && mkdir -p thirdparty
pushd thirdparty >/dev/null
# We will only need the stubs, not the submodules.
! [[ -d "protobuf" ]] && git clone -b v3.19.4 --depth 1 https://github.com/protocolbuffers/protobuf.git
popd >/dev/null
popd >/dev/null

popd >/dev/null
exec "${filename_abs}" "$@"
17 changes: 13 additions & 4 deletions tools/bazel.rc
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
build --client_env=CC=clang
build --cxxopt='-std=c++14'
build --copt=-DGRPC_BAZEL_BUILD
build --action_env=GRPC_BAZEL_RUNTIME=1
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
build --define=use_fast_cpp_protos=true
build:opt --compilation_mode=opt
build:opt --copt=-Wframe-larger-than=16384

build:dbg --compilation_mode=dbg
build:dbg --copt=-Werror=return-stack-address

# Address https://github.com/bazelbuild/rules_swift/issues/776
# build --host_swiftcopt=-wmo --swiftcopt=-wmo
build --host_swiftcopt=-wmo --swiftcopt=-wmo
# Dynamic link cause issues like: `dyld: malformed mach-o: load commands size (59272) > 32768`
# https://github.com/bazelbuild/bazel/issues/9190
build:macos --dynamic_mode=off

build:windows_opt --compilation_mode=opt
build:windows_dbg --compilation_mode=dbg

0 comments on commit b12f94c

Please sign in to comment.