How do I get the commands executed by Bazel

2020-02-10 02:30发布

问题:

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.

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.

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.

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;

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.

回答1:

You are correct, you can use the -s (--subcommands) option:

bazel build -s //foo

See https://docs.bazel.build/versions/master/user-manual.html#flag--subcommands.

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.

You might want to track https://github.com/bazelbuild/bazel/issues/276 (Windows support), although it'll probably be a while.



标签: command bazel