dongqingchan2385 2018-05-24 23:44
浏览 487

Bazel在处理protobuf文件时有一个错误。 我该如何临时解决?

I'm having an issue building my code base with Bazel, Go and Protobuf. The Protobuf files aren't mapped right by Bazel Gezelle when generated. I think it's a known bug. I've opened up my own ticket. If this is the problem, I don't expect it to be resolved anytime soon. It was tagged as a P2 and has been open since October. I'm looking for a solution to the problem in the mean time.

We use a custom Protobuf plugin when buliding our protobuf files. My thought process is to generate the protobuf files by hand and have Bazel ignore the protobuf files, just using the already generated code.

Does this sound like something that would work? How would I do this? Can I have Gezelle ignore the Protobuf files for me?

Thank you for your time

  • 写回答

1条回答 默认 最新

  • dsa80833 2018-05-25 14:15
    关注

    Copying my reply on bazelbuild/bazel-gazelle#209 for anyone running into the same issue.


    Yep, bazelbuild/bazel#3867 is the issue.

    Whenever you build a proto_library with Bazel (for in any language, not just Go), Bazel thinks the imports are relative to a repository root (either in your local repository or in any of your external repositories). I'm guessing brand.proto is importing github.com/xxx/jscode/jsge/pkg/paging/proto/page.proto. Since the file you want to import is actually jsge/pkg/paging/proto/page.proto, protoc won't find it when invoked by Bazel.

    Since this is an issue with proto_library, there's not much Gazelle or rules_go can do about it. If bazelbuild/bazel#3867 is implemented, you'll be able to adjust proto_library import paths. Until then, you won't be able to build proto_library rules without modifying them.

    Unfortunately, the best advice I can offer at the moment is to check in pre-generated .pb.go files and include those in your go_library rules. If you add a comment # gazelle:proto disable in your root build file, it will ignore .proto files and will include .pb.go files.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题