Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc --descriptor_set_out should include FileDescriptorProto.source_code_info like protoc --XXX_out #7623

Closed
timostamm opened this issue Jun 12, 2020 · 2 comments

Comments

@timostamm
Copy link

What version of protobuf and what language are you using?
Version: 3.12.3
Language: n/a

What operating system (Linux, Windows, ...) and version?
n/a

What runtime / compiler are you using (e.g., python version or gcc version)
n/a

What did you do?
Steps to reproduce the behavior:

  1. create comments.proto:
syntax = "proto3";
package testing;
message MessageWithComments {
    // Leading field comment.
    string foo = 1;
}
  1. Write a FileDescriptorSet for it:
$ protoc --descriptor_set_out temp comments.proto
  1. Text-format it:
protoc < temp --decode=google.protobuf.FileDescriptorSet google/protobuf/descriptor.proto

What did you expect to see

SourceCodeInfo with comments:

file {
  name: "comments.proto"
  package: "testing"
  message_type {
    name: "MessageWithComments"
    field {
      name: "foo"
      number: 1
      label: LABEL_OPTIONAL
      type: TYPE_STRING
      json_name: "foo"
    }
  }
  source_code_info {
    …
    location {
      path: 4
      path: 0
      path: 2
      path: 0
      span: 4
      span: 4
      span: 19
      leading_comments: " Leading field comment.\n"
    }
    …
  }
  syntax: "proto3"
}

What did you see instead?

$ protoc < temp --decode=google.protobuf.FileDescriptorSet google/protobuf/descriptor.proto
file {
  name: "comments.proto"
  package: "testing"
  message_type {
    name: "MessageWithComments"
    field {
      name: "foo"
      number: 1
      label: LABEL_OPTIONAL
      type: TYPE_STRING
      json_name: "foo"
    }
  }
  syntax: "proto3"
}

Anything else we should know about your project / environment

Writing a protoc plugin, wanted to use --descriptor_set_out to generate data for unit tests.

@thomasvl
Copy link
Contributor

Drive by, from protoc --help

  --include_source_info       When using --descriptor_set_out, do not strip
                              SourceCodeInfo from the FileDescriptorProto.
                              This results in vastly larger descriptors that
                              include information about the original
                              location of each decl in the source file as
                              well as surrounding comments.

@timostamm
Copy link
Author

Apparently I did not RTFM.

Thank you for the nudge @thomasvl , much appreciated.

rickystewart added a commit to rickystewart/cockroach that referenced this issue Aug 12, 2021
This flag [instructs Bazel](bazelbuild/rules_proto#56 (comment))
to set a [command-line flag](protocolbuffers/protobuf#7623 (comment))
when invoking `protoc` that causes the generated proto descriptor sets
to contain extra info:

```
  --include_source_info       When using --descriptor_set_out, do not strip
                              SourceCodeInfo from the FileDescriptorProto.
                              This results in vastly larger descriptors that
                              include information about the original
                              location of each decl in the source file as
                              well as surrounding comments.
```

Setting this solves two problems:

1. We need the descriptor sets to have comments for cockroachdb#65814.
2. Without this change, generated `.pb.go` files from the sandbox won't
   contain comments. This makes the files more difficult to read and
   dirties the files in your checkout if you copy those `.pb.go` files
   to your workspace.

Also delete an unnecessary `--symlink_prefix=_bazel/` from the `test`
configuration (it's inherited from the `build` configuration so it's
redundant).

Release note: None
craig bot pushed a commit to cockroachdb/cockroach that referenced this issue Aug 12, 2021
68102: storage/storageccl: Add an option to break export mid key r=pbardea,sumeerbhola a=aliher1911

Previously when exporting ranges with very large number of versions
export could hit the situation where single key export would exceed
maximum export byte limit. To resolve this, safety threshold has to
be raised which could cause nodes going out of memory.

To address this, this patch adds an ability to stop and resume on
the arbitrary key timestamp so that it could be stopped mid key and
resumed later.

Release note: None

Fixes #68231

68390: ui: rebuild the databases pages r=matthewtodd a=matthewtodd

Previously, the databases pages featured an older, outdated design. This
change aligns their UX with that of the other modern pages in the DB
console, statements, transactions, and sessions.

This is a first pass at the job. We will return to layer on more
features, including search, and more data, including node & region
information.

Addresses #65737.

Before | After
--- | ---
<img width="1372" alt="Screen Shot 2021-08-05 at 4 54 31 PM" src="https://user-images.githubusercontent.com/5261/128420405-7a096c2f-32a1-42d9-a8f0-186f699fb612.png"> | <img width="1372" alt="Screen Shot 2021-08-03 at 2 50 12 PM" src="https://user-images.githubusercontent.com/5261/128070069-28d0f461-69dd-47cb-a04b-bc6cd0126ca4.png">
<img width="1372" alt="Screen Shot 2021-08-05 at 4 54 57 PM" src="https://user-images.githubusercontent.com/5261/128420491-71d03570-1c0d-413b-ab40-09b45cf614ee.png"> | <img width="1372" alt="Screen Shot 2021-08-03 at 2 50 21 PM" src="https://user-images.githubusercontent.com/5261/128070090-bd62d125-a1b2-4c83-b0a5-33d0723849eb.png">
<img width="1372" alt="Screen Shot 2021-08-05 at 5 03 37 PM" src="https://user-images.githubusercontent.com/5261/128420959-338ea79b-abf0-4773-91bf-cecac64fec5f.png"> | (This overview of database grants no longer exists.)
(This rolled-up view of table grants did not previously exist.) | <img width="1372" alt="Screen Shot 2021-08-03 at 2 50 27 PM" src="https://user-images.githubusercontent.com/5261/128070100-1305c94f-c017-40a5-ba2d-f19fd61bdecf.png">
<img width="1372" alt="Screen Shot 2021-08-05 at 4 55 21 PM" src="https://user-images.githubusercontent.com/5261/128420596-2d9f04ad-718c-4dce-b045-b5647f718339.png"> | <img width="1372" alt="Screen Shot 2021-08-03 at 2 50 35 PM" src="https://user-images.githubusercontent.com/5261/128070103-831fd5c3-38da-4864-9d82-9091f3209606.png">
<img width="1372" alt="Screen Shot 2021-08-05 at 4 55 28 PM" src="https://user-images.githubusercontent.com/5261/128420658-4042c631-b283-4b0c-ac4a-3235bd3bcf39.png"> | <img width="1372" alt="Screen Shot 2021-08-03 at 2 50 41 PM" src="https://user-images.githubusercontent.com/5261/128070113-73528f2c-56bf-4fcf-a8d8-fcc3f100695f.png">

Release note (ui change): The databases pages in the DB console were
updated to bring them into alignment with our modern UX.

68619: storage: add file storing min version needed for backwards compatibility r=jbowens a=andyyang890

A new STORAGE_MIN_VERSION file containing the minimum version that the
storage engine needs to maintain backwards compatibility with will be
added to the directory for each storage engine. This will be used in
the encryption-at-rest registry migration.

Release note: None

68621: dev: implement `dev generate docs` r=rail a=rickystewart

Do some refactoring so that we don't have to repeat code in a bunch of
places. The implementation is pretty straightforward and just involves
building the docs then copying them over to the workspace.

Closes #68563.

Release note: None

68663: dev: hoist generated code out of sandbox into workspace r=rail a=rickystewart

(Only the most recent commit applies for this review.)

One might be expected that this command be implemented as
`dev generate protobuf` or `dev generate execgen` or similar, but that's
not really practical for a couple reasons:

1. Building all the protobuf in-tree isn't really possible on its own:
   see #58018 (comment).
2. For non-proto generated code, one can imagine that we do a bunch of
   `bazel query`s to list all the generated files in tree and to find
   which files are generated. Given that there are hundreds of generated
   files in tree, and a single `bazel query` can take ~1s, this is not
   tractable.

The implementation here is ad-hoc and a bit hacky. Basically we search
`bazel-bin` for files ending in `.go` and apply some heuristics to
figure out whether they should be copied and where those files should
go.

This is gated behind a feature flag for now because actually copying
these files into the workspace right now dirties a ton of files. (The
diffs are benign -- mostly comments.) We can flip this option to be on
by default when it's safe (probably after the `Makefile` is deleted).

Closes #68565.

Release note: None

68806: bazel: set `--include_source_info` when generating protobuf code r=rail a=rickystewart

This flag [instructs Bazel](bazelbuild/rules_proto#56 (comment))
to set a [command-line flag](protocolbuffers/protobuf#7623 (comment))
when invoking `protoc` that causes the generated proto descriptor sets
to contain extra info:

```
  --include_source_info       When using --descriptor_set_out, do not strip
                              SourceCodeInfo from the FileDescriptorProto.
                              This results in vastly larger descriptors that
                              include information about the original
                              location of each decl in the source file as
                              well as surrounding comments.
```

Setting this solves two problems:

1. We need the descriptor sets to have comments for #65814.
2. Without this change, generated `.pb.go` files from the sandbox won't
   contain comments. This makes the files more difficult to read and
   dirties the files in your checkout if you copy those `.pb.go` files
   to your workspace.

Also delete an unnecessary `--symlink_prefix=_bazel/` from the `test`
configuration (it's inherited from the `build` configuration so it's
redundant).

Release note: None

Co-authored-by: Oleg Afanasyev <[email protected]>
Co-authored-by: Matthew Todd <[email protected]>
Co-authored-by: Andy Yang <[email protected]>
Co-authored-by: Ricky Stewart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants