Protobuf vendoring and generated code
Protocol Buffers (protobuf) source is available at:
https://github.com/protocolbuffers/protobuf
This code is covered under the BSD license (see LICENSE). Documentation is available at https://developers.google.com/protocol-buffers/.
The tree's current version of the protobuf library is 35.0.
We do not include the protobuf tests or the protoc compiler.
Upgrading the protobuf library
WARNING: The vendoring process may download and execute untrusted code from the protobuf repository. Only vendor releases from trusted sources and review the vendored content carefully.
-
Decide the protobuf release version you want to vendor (for example,
v35.0). -
From the Gecko top source directory, use the standard moz.yaml vendoring workflow to re-vendor protobuf. Options are documented in
toolkit/components/protobuf/moz.yaml. See also the Firefox build docs for common vendoring operations: [Common vendoring operations] (https://firefox-source-docs.mozilla.org/mozbuild/vendor/index.html#common-vendoring-operations)Run:
mach vendor toolkit/components/protobuf/moz.yaml -r v35.0 --patch-mode none
and then apply local patches:
mach vendor toolkit/components/protobuf/moz.yaml --patch-mode only
Where -r v35.0 specifies the protobuf version.
Vendoring automatically regenerates all .pb.cc and .pb.h files specified
in scripts/generate_files.py.
- Update the moz.build to export the new set of headers and add any new .cc
files to the unified sources and remove old ones. Note that we only
need:
- files contained in the
libprotobuf_lite_srcstarget (file_lists.cmake) - the header files they need
- gzip streams (for devtools)
- files contained in the
Adding or updating generated C++ files
When a .proto source file is added, moved, or otherwise changed, update
scripts/generate_files.py so the generated C++ files are produced in the
correct location with the right include paths.
-
Edit
scripts/generate_files.pyand add or adjust arun_protoc(...)entry for the affected.protofile(s). Setcpp_outto the directory where the generated files should live, andincludesto directories that contain the.protosources (paths are relative to the top source dir). -
Regenerate the files using:
mach python toolkit/components/protobuf/scripts/generate_files.py
- If new generated files appear in a directory that is not already listing
them, update the corresponding
moz.buildin that directory to include the new files.