@@ -22,7 +22,10 @@ source module ci/cloudbuild/builds/lib/git.sh
2222
2323bazel_output_base=" $( bazel info output_base) "
2424
25- io::run find " ${bazel_output_base} " -name " api-index-v1.json"
25+ # As we support both WORKSPACE and MODULE modes for bazel, we need to determine
26+ # the path to these dependencies dynamically.
27+ read -r protobuf_proto_path < <( find " ${bazel_output_base} /external" -name " empty.proto" | sed -nE ' s/(.+\/src)\/google\/protobuf\/empty.proto/\1/p' )
28+ read -r googleapis_proto_path < <( find " ${bazel_output_base} /external" -name " api-index-v1.json" | sed -nE ' s/(.+)\/api-index-v1.json/\1/p' )
2629
2730if [ -z " ${UPDATED_DISCOVERY_DOCUMENT} " ]; then
2831 io::log_h2 " Removing previously generated golden files"
3639io::log_h2 " Running the generator to update the golden files"
3740bazel run --action_env=GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes \
3841 //generator:google-cloud-cpp-codegen -- \
39- --protobuf_proto_path=" ${bazel_output_base} /external/protobuf~/src " \
40- --googleapis_proto_path=" ${bazel_output_base} /external/googleapis~ " \
42+ --protobuf_proto_path=" ${protobuf_proto_path} " \
43+ --googleapis_proto_path=" ${googleapis_proto_path} " \
4144 --golden_proto_path=" ${PWD} " \
4245 --output_path=" ${PWD} " \
4346 --update_ci=false \
@@ -49,8 +52,8 @@ if [ -z "${GENERATE_GOLDEN_ONLY}" ]; then
4952 io::log_h2 " Running the generator to emit protos from discovery docs"
5053 bazel run --action_env=GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes \
5154 //generator:google-cloud-cpp-codegen -- \
52- --protobuf_proto_path=" ${bazel_output_base} " /external/protobuf~/src \
53- --googleapis_proto_path=" ${bazel_output_base} " /external/googleapis~ \
55+ --protobuf_proto_path=" ${protobuf_proto_path} " \
56+ --googleapis_proto_path=" ${googleapis_proto_path} " \
5457 --discovery_proto_path=" ${PWD} /protos" \
5558 --output_path=" ${PROJECT_ROOT} /protos" \
5659 --export_output_path=" ${PROJECT_ROOT} " \
@@ -81,8 +84,8 @@ if [ -z "${GENERATE_GOLDEN_ONLY}" ]; then
8184 io::log_h2 " Running the generator to update the generated libraries"
8285 bazel run --action_env=GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes \
8386 //generator:google-cloud-cpp-codegen -- \
84- --protobuf_proto_path=" ${bazel_output_base} " /external/protobuf~/src \
85- --googleapis_proto_path=" ${bazel_output_base} " /external/googleapis~ \
87+ --protobuf_proto_path=" ${protobuf_proto_path} " \
88+ --googleapis_proto_path=" ${googleapis_proto_path} " \
8689 --discovery_proto_path=" ${PWD} /protos" \
8790 --output_path=" ${PROJECT_ROOT} " \
8891 --check_comment_substitutions=true \
0 commit comments