【问题标题】:Bazel not adding BUILD file to external dependencyBazel没有将BUILD文件添加到外部依赖项
【发布时间】:2021-10-16 22:48:37
【问题描述】:

我有一个工作区,我在其中使用 Gazelle 生成我的 BUILD 文件,由于某种原因,com_github_ipfs_go_merkledag 依赖项在尝试解决它的 github.com/gogo/protobuf/gogoproto 依赖项时会破坏构建。设置和运行如下。

工作区:

# Declare indirect dependencies and init toolchains.
go_rules_dependencies()

go_register_toolchains(version = "1.16")

go_embed_data_dependencies()

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

gazelle_dependencies()

命令:

bazel run //:gazelle
bazel run //:gazelle -- update-repos -from_file=go.mod
bazel build //...

输出:

...
no such package '@com_github_ipfs_go_merkledag//github.com/gogo/protobuf/gogoproto':
BUILD file not found in directory 'github.com/gogo/protobuf/gogoproto' of external repository @com_github_ipfs_go_merkledag. 
Add a BUILD file to a directory to mark it as a package. and referenced by '@com_github_ipfs_go_merkledag//pb:merkledag_pb_go_proto'
...

不确定解决方案是什么?

【问题讨论】:

    标签: go bazel


    【解决方案1】:

    将构建指令添加到 go_repository 以忽略

    go_repository(
        name = "com_github_ipfs_go_merkledag",
        importpath = "github.com/ipfs/go-merkledag",
        sum = "h1:ixNu/5MJSaT/Qs073T0/HsWKwnOoBgqSq1g+GaJIen0=",
        version = "v0.4.0",
        build_directives = [
            "gazelle:proto disable",
        ],
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-22
      • 2018-09-14
      • 2013-08-07
      • 2014-03-04
      • 1970-01-01
      相关资源
      最近更新 更多