-
-
Notifications
You must be signed in to change notification settings - Fork 289
Open
Description
I have a repro here. To re-produce run the contents.sh
script.
I am building the following proto:
syntax = "proto3";
package sample;
import "google/protobuf/wrappers.proto";
import "scalapb/scalapb.proto";
option java_package = "sample";
option (scalapb.options) = {
preserve_unknown_fields: false
no_default_values_in_constructor: true
};
message SomeMessage {
google.protobuf.StringValue value = 1;
}
With options
generators_opts = {
"scala": [
"grpc",
"flat_package",
"scala3_sources"
],
},
When using
generators = { "scala": "scripts.ScalaPbCodeGenerator" },
I get output like the following:
scalapb.options.scalapb.ScalapbProto
scalapb.options.scalapb.ScalapbProto.javaDescriptor
value: _root_.scala.Option[_root_.scala.Predef.String] = _root_.scala.None,
The package name doesn't respect flat_package
and the options are not respected.
However, when referencing the generator from the scalapb
repo.
generators = { "scala": "scalapb.ScalaPbCodeGenerator" },
I find
scalapb.options.ScalapbProto
scalapb.options.ScalapbProto.javaDescriptor
value: _root_.scala.Option[_root_.scala.Predef.String]
var __value: _root_.scala.Option[_root_.scala.Predef.String] = _root_.scala.None
value: _root_.scala.Option[_root_.scala.Predef.String]
If I use the scripts
generator again and do
unzip -p $(location @scala_proto_rules_scalapb_runtime) '**/*.proto' | sed 's/package scalapb/package test/g' > $@
That is, rename the package and adjust my package.
option (test.options) = {
preserve_unknown_fields: false
no_default_values_in_constructor: true
};
I get
scalapb.options.ScalapbProto
scalapb.options.ScalapbProto.javaDescriptor
value: _root_.scala.Option[_root_.scala.Predef.String] = _root_.scala.None,
var __value: _root_.scala.Option[_root_.scala.Predef.String] = _root_.scala.None
value: _root_.scala.Option[_root_.scala.Predef.String]
Now the flat_package
is respected, however the options are not caught. The descriptor-set
shouldn't care about the package name?
Scalapb doesn't seem to catch them still, indicating that the scripts
runner doesn't run options transformations?
$ protoc --decode_raw < bazel-out/k8-fastbuild/bin/proto/example-descriptor-set.proto.bin
1 {
1: "proto/example.proto"
2: "sample"
3: "google/protobuf/wrappers.proto"
3: "scalapb/scalapb.proto"
4 {
1: "SomeMessage"
2 {
1: "value"
3: 1
4: 1
5: 11
6: ".google.protobuf.StringValue"
10: "value"
}
}
8 {
1: "sample"
1020 {
9: 0
15: 1
}
}
12: "proto3"
}
Metadata
Metadata
Assignees
Labels
No labels