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

scalapb option with retain_source_code_info doesn't work #1472

Open
haneul opened this issue Feb 11, 2023 · 1 comment
Open

scalapb option with retain_source_code_info doesn't work #1472

haneul opened this issue Feb 11, 2023 · 1 comment

Comments

@haneul
Copy link

haneul commented Feb 11, 2023

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 1162eea

Not sure what exactly caused the issue though.

@simuons
Copy link
Collaborator

simuons commented Mar 21, 2023

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.

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