protocolbuffers / protobuf

Protocol Buffers / protobuf

Protocol Buffers - Google’s data interchange format Copyright 2008 Google LLC Overview Protocol Buffers (a.k.a., protobuf) are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data. You can learn more about it in protobuf’s documentation. Protocol Buffers 是 Google 的数据交换格式,版权所有 2008 Google LLC。概述:Protocol Buffers(又称 protobuf)是 Google 开发的一种语言无关、平台无关、可扩展的机制,用于序列化结构化数据。您可以在 protobuf 的文档中了解更多信息。

This README file contains protobuf installation instructions. To install protobuf, you need to install the protocol compiler (used to compile .proto files) and the protobuf runtime for your chosen programming language. 本 README 文件包含 protobuf 的安装说明。要安装 protobuf,您需要安装协议编译器(用于编译 .proto 文件)以及您所选编程语言对应的 protobuf 运行时。

Working With Protobuf Source Code Most users will find working from supported releases to be the easiest path. If you choose to work from the head revision of the main branch your build will occasionally be broken by source-incompatible changes and insufficiently-tested (and therefore broken) behavior. If you are using C++ or otherwise need to build protobuf from source as a part of your project, you should pin to a release commit on a release branch. This is because even release branches can experience some instability in between release commits. 使用 Protobuf 源代码:大多数用户会发现使用已发布的版本是最简单的途径。如果您选择使用主分支(main branch)的最新修订版,您的构建可能会因为源码不兼容的变更或未经充分测试(因此可能损坏)的行为而偶尔失败。如果您正在使用 C++ 或需要在项目中从源码构建 protobuf,建议锁定在发布分支的某个发布提交(release commit)上。这是因为即使是发布分支,在两次发布提交之间也可能存在一定的不稳定性。

Bazel with Bzlmod Protobuf supports Bzlmod with Bazel 8 +. Users should specify a dependency on protobuf in their MODULE.bazel file as follows. Bazel 与 Bzlmod:Protobuf 支持在 Bazel 8+ 版本中使用 Bzlmod。用户应在 MODULE.bazel 文件中按如下方式指定对 protobuf 的依赖: bazel_dep(name = "protobuf", version = <VERSION>)

Users can optionally override the repo name, such as for compatibility with WORKSPACE. 用户可以选择覆盖仓库名称,例如为了与 WORKSPACE 兼容: bazel_dep(name = "protobuf", version = <VERSION>, repo_name = "com_google_protobuf")

Bazel with WORKSPACE Users can also add the following to their legacy WORKSPACE file. Note that with the release of 30.x there are a few more load statements to properly set up rules_java and rules_python. Bazel 与 WORKSPACE:用户也可以将以下内容添加到传统的 WORKSPACE 文件中。请注意,随着 30.x 版本的发布,需要增加一些 load 语句来正确配置 rules_java 和 rules_python。

Protobuf Compiler Installation The protobuf compiler is written in C++. If you are using C++, please follow the C++ Installation Instructions to install protoc along with the C++ runtime. For non-C++ users, the simplest way to install the protocol compiler is to download a pre-built binary from our GitHub release page. In the downloads section of each release, you can find pre-built binaries in zip packages: protoc-$VERSION-$PLATFORM.zip. It contains the protoc binary as well as a set of standard .proto files distributed along with protobuf. Protobuf 编译器安装:protobuf 编译器是用 C++ 编写的。如果您使用 C++,请遵循 C++ 安装说明来安装 protoc 以及 C++ 运行时。对于非 C++ 用户,安装协议编译器最简单的方法是从我们的 GitHub 发布页面下载预编译的二进制文件。在每个版本的下载部分,您可以找到 zip 包格式的预编译二进制文件:protoc-$VERSION-$PLATFORM.zip。它包含了 protoc 二进制文件以及随 protobuf 分发的一套标准 .proto 文件。

If you are looking for an old version that is not available in the release page, check out the Maven repository. These pre-built binaries are only provided for released versions. If you want to use the github main version at HEAD, or you need to modify protobuf code, or you are using C++, it’s recommended to build your own protoc binary from source. If you would like to build protoc binary from source, see the C++ Installation Instructions. 如果您正在寻找发布页面中没有的旧版本,请查看 Maven 仓库。这些预编译的二进制文件仅针对已发布版本提供。如果您想使用 GitHub 主分支的最新版本(HEAD),或者需要修改 protobuf 代码,又或者您正在使用 C++,建议从源码构建自己的 protoc 二进制文件。如果您想从源码构建 protoc,请参阅 C++ 安装说明。

Protobuf Runtime Installation Protobuf supports several different programming languages. For each programming language, you can find instructions in the corresponding source directory about how to install protobuf runtime for that specific language. Protobuf 运行时安装:Protobuf 支持多种编程语言。对于每种编程语言,您都可以在相应的源码目录中找到关于如何安装该语言特定 protobuf 运行时的说明。

Quick Start The best way to learn how to use protobuf is to follow the tutorials in our developer guide. If you want to learn from code examples, take a look at the examples in the examples directory. 快速入门:学习如何使用 protobuf 的最佳方式是遵循我们开发者指南中的教程。如果您想通过代码示例学习,请查看 examples 目录中的示例。

Documentation The complete documentation is available at the Protocol Buffers doc site. 文档:完整的文档可在 Protocol Buffers 文档网站上获取。

Support Policy Read about our version support policy to stay current on support timeframes for the language libraries. 支持策略:阅读我们的版本支持策略,以了解各语言库的支持时限。

Developer Community To be alerted to upcoming changes in Protocol Buffers and connect with protobuf developers and users, join the Google Group. 开发者社区:要获取 Protocol Buffers 即将到来的变更通知并与 protobuf 开发者及用户交流,请加入 Google Group。