Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the commands executed by Bazel

Tags:

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.

like image 991
Guy Coder Avatar asked Nov 29 '15 14:11

Guy Coder


People also ask

How do I run Bazel commands?

To run Bazel, go to your base workspace directory or any of its subdirectories and type bazel . % bazel help [Bazel release bazel-<version>] Usage: bazel <command> <options> ... Available commands: analyze-profile Analyzes build profile data. aquery Executes a query on the post-analysis action graph.

Where is the output of Bazel build?

The Bazel user's build state is located beneath outputRoot/_bazel_$USER . This is called the outputUserRoot directory. Beneath the outputUserRoot directory there is an install directory, and in it is an installBase directory whose name is the MD5 hash of the Bazel installation manifest.

How do I debug with Bazel?

Debugging BazelTo debug the C++ client, run it from gdb or lldb as usual. However, to debug Java code, attach to the server using the following: Run Bazel with the debugging option --host_jvm_debug before the command (such as bazel --host_jvm_debug build //src:bazel ). Attach a debugger to the port 5005.

What does Bazel run do?

Bazel is a tool that automates software builds and tests. Supported build tasks include running compilers and linkers to produce executable programs and libraries, and assembling deployable packages for Android, iOS and other target environments.


1 Answers

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.

like image 196
kristina Avatar answered Oct 18 '22 09:10

kristina