【问题标题】:Bazel run specify multiline commandBazel 运行指定多行命令
【发布时间】:2020-04-18 12:30:52
【问题描述】:

您好,我正在为我的项目使用bazel

我在 Linux 中总是使用反斜杠 (\) 来指定长命令。

我尝试了同样的 bazel,但没有成功

bazel build //mypackage:query_count -- \
--input="/path/to/input.json" \
--output="/path/to/output/json"

当我删除反斜杠并将它们保持在一行时,构建成功

bazel build //mypackage:query_count -- --input="/path/to/input.json" --output="/path/to/output/json"

有谁知道我做错了什么,查看错误,看起来 bazel 将 --input="/path/to/input.json" 视为单独的目标?

【问题讨论】:

  • 确保您的任何"\" 字符后面没有空格?祝你好运。

标签: linux build command-line-interface bazel


【解决方案1】:

--input="/path/to/input.json"--output="/path/to/output/json" 不是 bazel build 的标志(用于构建可执行文件)。我相信您将它们用作底层可执行文件 //mypackage:query_count 的运行时标志。

你可能想在这里使用bazel run

bazel run //mypackage:query_count -- \
  --input="/path/to/input.json" \
  --output="/path/to/output/json"

【讨论】:

    【解决方案2】:

    -- 之后的所有内容都被解释为目标模式:

    https://docs.bazel.build/versions/master/command-line-reference.html

    bazel [<startup options>] <command> [<args>] -- [<target patterns>]
    

    尽管正如 Jin 上面所说,--input--output 不是 bazel 的命令行标志,因此不清楚您要做什么(除非您只是将它们用作标志的虚拟占位符名称) .

    -- 对于bazel run 的行为不同:bazel 将-- 之后的所有内容解释为要运行的二进制文件的参数,请参阅https://docs.bazel.build/versions/master/user-manual.html#run

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      • 1970-01-01
      • 2019-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多