1

When running aquery on a target, I can see two actions being performed by bazel:

bazel aquery '//bazel_test/a:foo'

action 'Writing file bazel_test/a/foo.manifest'
  Mnemonic: FileWrite
  Target: //bazel_test/a:foo
  Configuration: k8-fastbuild
  ActionKey: <hash>
  Inputs: []
  Outputs: [bazel-out/k8-fastbuild/bin/bazel_test/a/foo.manifest]

action 'Writing: bazel-out/k8-fastbuild/bin/bazel_test/a/foo.tar'
  Mnemonic: PackageTar
  Target: //bazel_test/a:foo
  Configuration: k8-fastbuild
  ActionKey: <hash>
  Inputs: [bazel-out/k8-fastbuild/bin/bazel_test/a/foo.manifest, ...]
  Outputs: [bazel-out/k8-fastbuild/bin/bazel_test/a/foo.tar]

I am interested in the manifest file because I want to see the resulting file tree of the files in foo.tar.

Is there a way to only do the first of these action and write the manifest file without writing the tar file?

I looked through different flags to use when building but I did not find a suitable one. I was thinking the maybe --nobuild would work but that actually skips the execution phase and thus skipping both of the actions above. I have the ActionKey, so I was thinking maybe there is a way to execute an action if you have the ActionKey.

There is a question closely related to this but it does not specifically mention how to create the manifest file without running the action after it. How do I get output files for a given Bazel target?

Victor
  • 13
  • 2

1 Answers1

0

Whether this is possible and how to do it depend on how the rule is implemented. The rule needs to do one of

  1. Put the output in an output group, and then the group can be requested with the --output_groups flag
  2. Use predeclared outputs, i.e. attr.output/attr.output_list in the rule declaration, and ctx.outputs in the rule implementation
  3. Use implicit outputs (which is now deprecated)

If the rule does none of the above, then there's no way to ask for that specific output file.

See the rule's documentation (or source code...) or if you're writing the rule yourself see https://bazel.build/extending/rules#requesting_output_files

ahumesky
  • 4,203
  • 8
  • 12
  • Thanks for the reply, I might not have been very clear in my original question. The rule I have is pkg_tar (implemented here: https://github.com/bazelbuild/rules_pkg/blob/main/pkg/private/tar/tar.bzl). What I would have liked is to get the manifest file that this rule is creating, without packaging the tar file. – Victor Dec 20 '22 at 08:56
  • Yeah, it doesn't look like the manifest file is exposed in a way that would allow you to request just that file. You might consider opening a feature request for this on https://github.com/bazelbuild/rules_pkg – ahumesky Jan 04 '23 at 17:37
  • Thanks, I might open a request. I will give you the checkmark for most helpful answer. – Victor Jan 05 '23 at 18:16