在自定义规则中禁用沙箱

时间:2018-04-25 15:23:31

标签: sandbox bazel rule

如何在自定义Bazel规则中禁用沙盒?

我希望在此规则的每个实例化中都禁用沙盒始终,而无需用户执行任何操作。

1 个答案:

答案 0 :(得分:1)

在规则实现中创建操作时,请包含execution_requirements dict参数,其中包含no-sandbox项,其值为1。这会强制操作永远不会在沙箱中运行。

def _impl(ctx):
  ctx.actions.run_shell(
    outputs = [ctx.outputs.executable],
    command = "..",
    execution_requirements = {
      "no-sandbox": "1",
      "no-cache": "1",
      "no-remote": "1",
      "local": "1",
    },
  )

有关这些标记/要求的详情,请参阅documentation for common build attributes上的tags属性。

相关问题