简体   繁体   中英

Write manifest file without building the target

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?

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, ie attr.output / attr.output_list in the rule declaration, and ctx.outputs in the rule implementation
  3. Use implicit outputs (which is not 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM