dongta5621 2017-11-23 08:49
浏览 989
已采纳

如果您很懒,添加新的Bazel github外部存储库的快速方法?

I'm using Bazel and gazelle to manage my Go project's BUILD.bazel files.

I'd like to be consistent across languages and avoid Go's specific vendoring tool.

I disabled vendoring for gazelle. It generates the BUILD entries wonderfully for those repositories, but I'm stuck with writing the WORKSPACE incantations for git_repository or http_archive myself. This of course can get tedious if a project I'm using has a lot of external dependencies.

Is there a more convenient way to do it? Could gazelle support updating the WORKSPACE file?

Thanks.

  • 写回答

1条回答 默认 最新

  • doulu3399 2017-11-23 08:57
    关注

    Answering my own question: it looks like the Bazel team wants do add support for this to Gazelle but until that's done we could use the wtool:

    $ go get -u github.com/bazelbuild/rules_go/go/tools/wtool
    $ github.com/gordonklaus/portaudio
    
    This will update the WORKSPACE file accordingly. The command doesn't even have to be run from the repository root - which is nice.
    

    Here's my the diff for my WORKSPACE after running the command above:

    $ git diff WORKSPACE 
    diff --git a/WORKSPACE b/WORKSPACE
    index 3b15779..c170b60 100644
    --- a/WORKSPACE
    +++ b/WORKSPACE
    @@ -50,3 +50,8 @@ go_repository(
         importpath = "google.golang.org/api",
     )
    
    +go_repository(
    +    name = "com_github_gordonklaus_portaudio",
    +    commit = "e66c30a9c4ca11f93538cf8c004831bfb76f3838",
    +    importpath = "github.com/gordonklaus/portaudio",
    +)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

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