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 Jenkins+k8s部署slave节点offline
  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题