Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
* bazelbuild/bazel#3867 is fixed, so
  instructions for vendored proto files need to be updated.
* proto_library is now provided by rules_proto, not built-in.
  • Loading branch information
garymm committed Nov 24, 2022
1 parent 8a94066 commit 5fe7705
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions proto/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Go Protocol buffers
.. _Bourne shell tokenization: https://docs.bazel.build/versions/master/be/common-definitions.html#sh-tokenization
.. _gogoprotobuf: https://github.com/gogo/protobuf
.. _compiler.bzl: compiler.bzl
.. _bazelbuild/bazel#3867: https://github.com/bazelbuild/bazel/issues/3867
.. _rules_proto: https://github.com/bazelbuild/rules_proto

.. role:: param(kbd)
.. role:: type(emphasis)
Expand All @@ -33,7 +33,7 @@ Overview
Protocol buffers are built with the three rules below. ``go_proto_library`` and
``go_proto_compiler`` may be loaded from ``@io_bazel_rules_go//proto:def.bzl``.

* `proto_library`_: This is a Bazel built-in rule. It lists a set of .proto
* `proto_library`_: This is provided by rules_proto_. It lists a set of .proto
files in its ``srcs`` attribute and lists other ``proto_library`` dependencies
in its ``deps`` attribute. ``proto_library`` rules may be referenced by
language-specific code generation rules like ``java_proto_library`` and
Expand Down Expand Up @@ -140,15 +140,13 @@ have protos, you'll also need to add
A note on vendored .proto files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Bazel can only handle imports in .proto files that are relative to a repository
By default, Bazel assumes imports in .proto files are relative to a repository
root directory. This means, for example, if you import ``"foo/bar/baz.proto"``,
that file must be in the directory ``foo/bar``, not
``vendor/example.com/repo/foo/bar``.

If you have proto files that don't conform to this convention, follow the
instructions for using pre-generated .pb.go files above.

The Bazel tracking issue for supporting this is `bazelbuild/bazel#3867`_.
To deal with this, use the `strip_import_prefix` option in the proto_library_
for the vendored file.

API
---
Expand Down Expand Up @@ -365,7 +363,7 @@ go_proto_compiler
``go_proto_compiler`` describes a plugin for protoc, the proto compiler.
Different plugins will generate different Go code from the same protos.
Compilers may be chosen through the ``compilers`` attribute of
``go_proto_library``.
``go_proto_library``.

Several instances of this rule are listed in `Predefined plugins`_. You will
only need to use this rule directly if you need a plugin which is not there.
Expand Down Expand Up @@ -456,7 +454,7 @@ use protoc), you can write a new rule that produces this.
``GoProtoCompiler`` is loaded from ``@io_bazel_rules_go//proto:def.bzl``.

``GoProtoCompiler`` has the fields described below. Additional fields may be
added to pass information to the ``compile`` function. This interface is
added to pass information to the ``compile`` function. This interface is
*not final* and may change in the future.

+-----------------------------+-------------------------------------------------+
Expand Down

0 comments on commit 5fe7705

Please sign in to comment.