bufbuild / protocompile

A parsing/linking engine for protobuf; the guts for a pure Go replacement of protoc.
Apache License 2.0
227 stars 18 forks source link

Add final checks that were added to protoc between v27.0-rc3 and final v27.0 #309

Closed jhump closed 4 months ago

jhump commented 4 months ago

There were three changes in the final v27.0 that were not previously implemented in this compiler:

  1. A new feature_support field on EnumValueOptions to allow defining the lifetime of a feature value. This is similar to the field of the same name and type on FieldOptions, but it controls the actual enum values and in which editions they are valid. (This resolves https://github.com/protocolbuffers/protobuf/issues/16369#issuecomment-2096547617.)
  2. A new check that a feature is not used from the same file in which it's defined. (This resolves https://github.com/protocolbuffers/protobuf/issues/16756.)
  3. A change to google/protobuf/descriptor.proto to add extension declarations for known custom features. (This resolves https://github.com/protocolbuffers/protobuf/issues/16757.)

    Unfortunately, this one isn't quite part of this PR because this configuration is not actually in the descriptorpb package. Why not? Because extension declarations are defined as source-only options, which means they aren't preserved at runtime, which means they are not present in the embedded descriptor in the latest descriptorpb package. I will address this in a subsequent PR by making the sources for these files available to compiler users. It will need to be in a separate package that so it doesn't get linked into user programs by default. For example, the buf CLI won't need it because it has its own mechanism of supplying the sources for these files.

This PR updates to use the latest (final) v27.0 release and also updates the protobuf-go dependency to include the v27.0 version of the descriptorpb package (first two commits). It then implements the same checks as the first two bullets mentioned above, each in its own commit.