Search code examples
bazel

Locating Bazel output files?


When I run bazel build, bazel reports the target's output file. How can I programmatically query this?

In this example, I want to get the bazel-out/... path.

$ bazel build foo/bar:registration
INFO: Analyzed target //foo/bar:registration (546 packages loaded, 13485 targets configured).
INFO: Found 1 target...
Target //foo/bar:registration up-to-date:
  bazel-out/k8-fastbuild-ST-a82eca4c6b7c/bin/foo/bar/registration/registration_/registration

Solution

  • Update: there's indeed a shorter way since Bazel 5.3.

    bazel cquery --output=files //your:target