New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 622680 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Xoogler
Closed: Jun 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature



Sign in to add a comment

Plugin support for protobuf compiler (protoc) targets.

Project Member Reported by kraynov@chromium.org, Jun 23 2016

Issue description

*** NOT A BUG ***

Protobuf compiler (protoc) has plugin support to generate stubs in other languages. Details: https://developers.google.com/protocol-buffers/docs/reference/other

The initial purpose of this stuff in Chromium is Tracing V2 (bit.ly/TracingV2) objective. Custom 'append-only' protobuf writer in Tracing V2 is optimised for constant memory footprint and speed in order to eliminate variable memory overhead and meet performance constraints at some critical paths. This goal is achieved by sacrificing with serialized data size and bounding capabilities in a basic subset of proto language.

Another developer (xyzzyz@chromium.org) intend to use a protoc plugin which generates gRPC stubs.

Technically there is already GN build file for 'proto_library'. The CL crrev.com/2082693002/ just extends those GN/gyp files in order to support passing additional plugin to protoc.

Usage example:
proto_library("tracing_proto") {
  visibility = [ "//components/tracing/*" ]

  sources = [
     "foo.proto",
     "bar.proto",
  ]

  proto_out_dir = "components/tracing/proto"
  generator_plugin = "proto_zero_plugin"  # Executable name of the plugin
  generator_plugin_suffix = ".zeropb"     # Suffix prior .cc and .h
  generate_cc = false                     # Don't generate built-in cpp_out

  deps = [
    # Build plugin executable
    "//components/tracing/proto_zero_plugin:proto_zero_plugin($host_toolchain)",
  ]
}
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jul 6 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b241e6e5fa05e90eaa4199d4bc497869e3cf08e1

commit b241e6e5fa05e90eaa4199d4bc497869e3cf08e1
Author: kraynov <kraynov@chromium.org>
Date: Wed Jul 06 23:38:58 2016

Plugin support for protobuf compiler (protoc) targets.

Until now the protobuf generator targets in the build files
did hard-code the unconditional generation of C++ and python
stubs. There are two new upcoming use cases, that are,
bit.ly/TracingV2 (see BUG) and gRPC, where we need to generate
C++ stubs using a custom protoc plugin.
This CL introduces the plumbing necessary to the GYP/GN
build files to be able to pass an arbitrary plugin to
the protoc invocation. See crrev.com/2083373002 as an example of
how this will be used in upcoming CLs.

BUG= 622680 

Review-Url: https://codereview.chromium.org/2082693002
Cr-Commit-Position: refs/heads/master@{#403981}

[modify] https://crrev.com/b241e6e5fa05e90eaa4199d4bc497869e3cf08e1/build/protoc.gypi
[modify] https://crrev.com/b241e6e5fa05e90eaa4199d4bc497869e3cf08e1/third_party/protobuf/proto_library.gni

Change crrev.com/2202233002 is intended to avoid writing complex boilerplates.

For example:

proto_library("proto_zero_testing_messages") {
  ...
  generator_plugin_label = "tools/proto_zero_plugin:proto_zero_plugin"
  generator_plugin_suffix = ".pbzero"
  generate_cc = false
  generate_python = false

  plugin_host_label = generator_plugin_label + "($host_toolchain)"
  generator_plugin =
      rebase_path(get_label_info(plugin_host_label, "root_out_dir") + "/" +
                      get_label_info(plugin_host_label, "name"),
                  root_build_dir)
  if (is_win) {
    generator_plugin += ".exe"
  }

  deps = [
    plugin_host_label,
  ]
}

Can be simplified to:

proto_library("proto_zero_testing_messages") {
  ...
  generator_plugin_label = "tools/proto_zero_plugin:proto_zero_plugin"
  generator_plugin_suffix = ".pbzero"
  generate_cc = false
  generate_python = false
}
Project Member

Comment 3 by bugdroid1@chromium.org, Aug 3 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b01034d7a9d4377f8d2e244a3e14d334435de67d

commit b01034d7a9d4377f8d2e244a3e14d334435de67d
Author: kraynov <kraynov@chromium.org>
Date: Wed Aug 03 10:48:03 2016

Path evaluation to protobuf plugin.

Protobuf compiler (protoc) plugin is basically an executable.
Path for executables can vary if building for diffent platforms.
This change allows to skip writing complex boilerplate each time.

BUG= 622680 

Review-Url: https://codereview.chromium.org/2202233002
Cr-Commit-Position: refs/heads/master@{#409481}

[modify] https://crrev.com/b01034d7a9d4377f8d2e244a3e14d334435de67d/components/tracing/BUILD.gn
[modify] https://crrev.com/b01034d7a9d4377f8d2e244a3e14d334435de67d/third_party/protobuf/proto_library.gni

Sign in to add a comment