Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bazel一次构建多个目标_Bazel_Bazel Rules - Fatal编程技术网

Bazel一次构建多个目标

Bazel一次构建多个目标,bazel,bazel-rules,Bazel,Bazel Rules,我想要一个能够同时构建多个目标的Bazel规则。基本上是这样的: build_all( name = "build_all", targets = [ "//services/service1:build", "//services/service2:build", "//services/service3:build", ] ) 所以我就跑 bazel build //:build_all 使用一个简单的命令构建我的所有服务(对于测试也是如此)。但我找不

我想要一个能够同时构建多个目标的Bazel规则。基本上是这样的:

build_all(
  name = "build_all",
  targets = [
    "//services/service1:build",
    "//services/service2:build",
    "//services/service3:build",
  ]
)
所以我就跑

bazel build //:build_all
使用一个简单的命令构建我的所有服务(对于测试也是如此)。但我找不到任何当前的解决方案

有没有办法做到这一点?

这似乎是一个现成的规则,可能会被滥用:

filegroup(
  name = "build_all",
  srcs = [
    "//services/service1:build",
    "//services/service2:build",
    "//services/service3:build",
  ]
)

否则,它允许您为一组文件(标签)指定一个集合名称,以便方便地传递,但似乎与命令行上使用的摘要目标一样有效。

因为我试图部署多个Kubernetes配置,最终使用的配置如下所示:

load("@io_bazel_rules_k8s//k8s:objects.bzl", "k8s_objects")

k8s_objects(
   name = "deployments",
   objects = [
      "//services/service1:build",
      "//services/service2:build",
      "//services/service3:build",
   ]
)

如果您只需要构建目标的一个子集,其他答案可能更好,但您也可以尝试
bazel build:all
bazel test:all

我在谷歌上搜索并找到了这个。也许这会有帮助:是的,我几分钟前就尝试过,但它似乎只适用于“可运行”的目标。测试和构建给了我一个错误。但也许你可以证明我错了:)你应该将你的服务设置为build_all的依赖项。通常,“数据”是最灵活的属性。但也要知道bazel build/。。。将构建一切,bazel构建//服务/。。。将在服务下构建所有内容。当py_二进制规则列在src中时,这对我不起作用。当它们的源被更新时,它不会以静默方式重建它们。然后我需要返回并直接在py_二进制规则上调用bazel build。