Skip to content

Commit

Permalink
Switch to Protobuf 21.12 (#27)
Browse files Browse the repository at this point in the history
Inlining the protobufs in
#25
unblocked migrating to newer version of Protobuf
as the proto compiler (protoc) error'd.
  • Loading branch information
jchaffraix-slack authored Apr 26, 2024
1 parent 864f0fb commit 8d6a459
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
6 changes: 5 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ sh_library(
name = "gen_lib",
srcs = ["gen.sh"],
data = [
# We should switch to well_known_type_protos after moving to 22.X
# but we also need a dependency on descriptor_proto_srcs here.
# We cannot on 21.12 as there were some inconsistencies with the rules:
# https://github.com/protocolbuffers/protobuf/issues/11430
"@com_google_protobuf//:well_known_protos",
"@com_google_protobuf//:conformance_proto",
"@com_google_protobuf//conformance:conformance_proto",
"@com_google_protobuf//:test_messages_proto3_proto",
"@com_google_protobuf//:test_messages_proto2_proto",
"@com_google_protobuf//:protoc",
Expand Down
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ go_rules_dependencies()

go_register_toolchains(version = "1.20.5")

PBV = "3.20.3"
PBV = "21.12"

http_archive(
name = "com_google_protobuf",
sha256 = "04e1ed9664d1325b43723b6a62a4a41bf6b2b90ac72b5daee288365aad0ea47d",
sha256 = "6a31b662deaeb0ac35e6287bda2f3369b19836e6c9f8828d4da444346f420298",
strip_prefix = "protobuf-" + PBV,
urls = ["https://github.com/protocolbuffers/protobuf/archive/v" + PBV + ".zip"],
urls = ["https://github.com/protocolbuffers/protobuf/archive/refs/tags/v" + PBV + ".zip"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
10 changes: 8 additions & 2 deletions gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,25 @@ PROTOC=`readlink $PROTOC`
echo protoc path: $PROTOC
$PROTOC --version

# For some reason, test_messages_proto{2,3}.proto are in virtual_imports,
# despite an explicit dependency on those in the BUILD file :'-(
# TODO: We should figure out a better way of handling this.
cp external/com_google_protobuf/_virtual_imports/test_messages_proto2_proto/google/protobuf/test_messages_proto2.proto external/com_google_protobuf/src/google/protobuf/test_messages_proto2.proto
cp external/com_google_protobuf/_virtual_imports/test_messages_proto3_proto/google/protobuf/test_messages_proto3.proto external/com_google_protobuf/src/google/protobuf/test_messages_proto3.proto

PBS=`find . -name '*.proto' | grep -v _virtual_imports`

ARGS="-I external/com_google_protobuf/src -I ./"

echo
echo generating hacklang...
for SRC in $PBS
do
echo source: $SRC
ARGS="-I external/com_google_protobuf/src -I ./"
$PROTOC $ARGS --plugin=$GENHACK --hack_out="plugin=grpc,allow_proto2_dangerous:$TMP" --experimental_allow_proto3_optional $SRC
echo
done

ARGS="-I external/com_google_protobuf/src -I ./"
$PROTOC $ARGS --encode=foo.bar.example1 ./test/example1.proto < ./test/example1.pb.txt > $TMP/test/example1.pb.bin
$PROTOC $ARGS --encode=baz.optional_proto3 ./test/optional_proto3.proto < ./test/empty_optional_proto3.pb.txt > $TMP/test/empty_optional_proto3.pb.bin
$PROTOC $ARGS --encode=baz.optional_proto3 ./test/optional_proto3.proto < ./test/default_optional_proto3.pb.txt > $TMP/test/default_optional_proto3.pb.bin
Expand Down
Loading

0 comments on commit 8d6a459

Please sign in to comment.