rules_scala
rules_scala copied to clipboard
scalapb option with retain_source_code_info doesn't work
We used an old version of rules_scala for a while, and recently tried to upgrade but found that scalapb option retain_source_code_info doesn't work as expected.
Added an example into https://github.com/haneul/scalapbtest The current master HEAD doesn't contain code info in the generated code. While it works with https://github.com/haneul/scalapbtest/tree/cd723982dae484796e31bbd9237e6cd8cd4fbd9c
syntax = "proto3";
import "scalapb/scalapb.proto";
option (scalapb.options) = {
retain_source_code_info: true
};
enum TestEnum {
// test1
TEST1=0;
// test2
Test2=1;
}
// hello world
message TestEnumReq {
// enumfield
TestEnum field = 1;
// this is account
string account = 2;
}
Looking into the generated TestEnum.scala working version:
object TestEnum extends _root_.scalapb.GeneratedEnumCompanion[TestEnum] {
implicit def enumCompanion: _root_.scalapb.GeneratedEnumCompanion[TestEnum] = this
/** test1
*/
@SerialVersionUID(0L)
case object TEST1 extends TestEnum {
val value = 0
val index = 0
val name = "TEST1"
override def isTest1: _root_.scala.Boolean = true
}
non-working version:
object TestEnum extends _root_.scalapb.GeneratedEnumCompanion[TestEnum] {
implicit def enumCompanion: _root_.scalapb.GeneratedEnumCompanion[TestEnum] = this
@SerialVersionUID(0L)
case object TEST1 extends TestEnum {
val value = 0
val index = 0
val name = "TEST1"
override def isTest1: _root_.scala.Boolean = true
}
Looking into history of rules_scala, the behavior changed after https://github.com/bazelbuild/rules_scala/commit/1162eea0115816239b67fb003d09ecc2eba3b3fc
Not sure what exactly caused the issue though.
Hi, @haneul,
this happens because descriptor_set_out (the output of proto_library) does not include source info. To change that you have to add build --protocopt=--include_source_info to your .bazelrc then scalapb should see source info.
Let me know if that helps.