如何获取 Bazel 执行的命令 [英] How do I get the commands executed by Bazel
问题描述
我想知道是否有办法让 Bazel 列出、输出、显示等所有可以从命令行执行的命令,这些命令在清理后的构建期间运行.我不在乎输出是在屏幕上还是在文件中等等.如有必要,我会将其按摩成可用的形式.
I was wondering if there is a way to get Bazel to list, output, display, etc., all of the commands that can be executed from a command line that are run during a build after a clean. I do not care if the output is to the screen, in a file, etc. I will massage it into a usable form if necessary.
我在运行 Bazel 期间捕获了屏幕输出,这让我知道正在做什么,但是它没有给我一个可以在命令行上执行的命令.该命令必须包含所有命令选项,而不是显示变量.
I have captured the screen output during a run of Bazel which gives me an idea of what is being done, however it does not give me a command I can execute on the command line. The command would have to include all of the command options and not display variables.
如果这是不可能的,因为 Bazel 是开源的,在代码中是/是代表要运行的命令的行,以便我可以修改 Bazel 以输出可执行命令.
If this is not possible, since Bazel is open source, where in the code is/are the lines that represent the commands to be run so that I can modify Bazel to output the executable commands.
我知道 Bazel 中的查询命令,并使用它生成依赖关系图.如果这可以作为查询命令完成,那就更好了.
I am aware of the query command within Bazel, and used it generate the dependency diagram. If this could be done as a query command it would be even better.
TLDR;
我的目标是在 Windows 上使用 Bazel 构建 TensorFlow.是的,我知道所有不这样做的问题和原因,并且已经通过虚拟机或 Docker 在 Windows 上成功安装了 TensorFlow.我确实从 Cygwin 开始尝试在 Windows 上构建 Bazel,但这开始失控,因为我习惯于使用软件包进行安装,而 Cygwin 不适合使用软件包,所以我开始尝试手动构建 Bazel这变成了一个泥潭.因此,我现在尝试通过复制 Bazel 在 Linux 上构建 TensorFlow 所做的工作,在 Windows 上手动构建 TensorFlow.
My goal is to build TensorFlow using Bazel on Windows. Yes I know of all of the problems and reasons NOT to do it and have successfully installed TensorFlow on Windows via a Virtual Machine or Docker. I did take a shot at building Bazel on Windows starting with Cygwin, but that started to get out of hand as I am use to installing with packages and Cygwin doesn't play nice with packages, so then I started trying to build Bazel by hand and that was turning into a quagmire. So I am now trying to just build TensorFlow by hand on Windows by duplicating what Bazel would do to build TensorFlow on Linux.
推荐答案
你是对的,可以使用-s
(--subcommands
)选项:
You are correct, you can use the -s
(--subcommands
) option:
bazel build -s //foo
参见 https://docs.bazel.build/版本/master/user-manual.html#flag--subcommands.
对于您的用例,您可能希望将输出重定向到文件,然后将任何库/二进制路径全局替换为 Windows 等效项.
For your use case, you'd probably want to redirect the output to a file and then global replace any library/binary paths to the Windows equivalents.
您可能想要跟踪 https://github.com/bazelbuild/bazel/issues/276(Windows 支持),虽然可能需要一段时间.
You might want to track https://github.com/bazelbuild/bazel/issues/276 (Windows support), although it'll probably be a while.
这篇关于如何获取 Bazel 执行的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!