rules_proto is using 3.13 but I'm building with 4.

160 views
Skip to first unread message

Martin Blais

unread,
Dec 9, 2020, 2:51:32 AM12/9/20
to proto-bazel-discuss
Hi,
I'm a little confused regarding how to use this.

I'm importing this module in order to - I think - get proto_library rules in Bazel.
I'm also - in my project - defining a "@com_google_protobuf" namespace that contains the version of protobuf I'm using for my project (4.0.0rc2), and use its own protobuf.bzl Bazel to build it.  (Why that project itself doesn't provide Bazel rules to build protos is 

I've just noticed that this rules_proto defines a different protobuf under https://github.com/bazelbuild/rules_proto/blob/master/proto/private/dependencies.bzl#L25, as of v3.13, under namespace "@com_github_protocolbuffers_protobuf". I noticed this because checking the version of protoc that's invoked, I see it's not the same version as that which I'm building with.

Do I need rules_proto? Well, if I said no, protobuffers/protobuf/protobuf.bzl imports it anyhow. How does that jive with the fact that protobuf at version vY imports rules proto, which builds a protoc at version vX, where vX != vY?  Is that not a problem?

And if it is, is it recommended I fork this to place the same version of the library I'm otherwise using?

How is it SUPPOSED to work?




Martin Blais

unread,
Dec 9, 2020, 3:01:13 AM12/9/20
to proto-bazel-discuss
Is it sufficient to just redefine my own proto repository as "@com_github_protocolbuffers_protobuf", and making sure to call rules_proto_dependencies() after I define it, to get a consistent version?
(If so, this may be worthwhile documenting.)

Martin Blais

unread,
Dec 9, 2020, 3:16:27 AM12/9/20
to proto-bazel-discuss
I think I just found something:

        http_archive(
            name = "rules_proto",
..
            repo_mapping = {"@com_github_protocolbuffers_protobuf": "@com_google_protobuf"}
        )

In other words, if I tell @rules_proto about the repository in the name it's expecting, it'll override that (via maybe()).
Except it doesn't appear to work, I'm still getting a 3.13 protoc.
Hmmm



--
You received this message because you are subscribed to the Google Groups "proto-bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to proto-bazel-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/proto-bazel-discuss/e1d69b2d-1a96-4537-9223-10903e8b7020n%40googlegroups.com.

Martin Blais

unread,
Dec 12, 2020, 9:31:36 AM12/12/20
to proto-bazel-discuss
On Wednesday, December 9, 2020 at 3:16:27 AM UTC-5 Martin Blais wrote:
I think I just found something:

        http_archive(
            name = "rules_proto",
..
            repo_mapping = {"@com_github_protocolbuffers_protobuf": "@com_google_protobuf"}
        )

In other words, if I tell @rules_proto about the repository in the name it's expecting, it'll override that (via maybe()).
Except it doesn't appear to work, I'm still getting a 3.13 protoc.
Hmmm

No! Actually this *does* work.
There's another reason I was seeing the old version number. I modified the source code of my custom proto repo and it's reflected in the output. Also, using this with a released proto version also shows the correct version. I check like this:
./bazel-bin/external/com_google_protobuf/protoc --version

Thank you,
Reply all
Reply to author
Forward
0 new messages