how to write a file from an aspect?

736 views
Skip to first unread message

Gregg Reynolds

unread,
Feb 27, 2021, 9:52:35 PM2/27/21
to bazel-discuss
I've got a very simple aspect that prints info from the target's providers. I'd like to write that to a file, but when I use ctx.actions.write I don't get any output.  This is running it from the command line.  The print statements show up in the DEBUG output, though.  The result looks like this:

INFO: Found 1 target...
Aspect @obazl_rules_ocaml//ocaml/_aspects:ocaml.bzl%providers_aspect of //src/lib/secrets:secrets up-to-date (nothing to build)

Am I using aspects incorrectly?

Thanks,

Gregg

Daniel Wagner-Hall

unread,
Feb 28, 2021, 6:28:37 AM2/28/21
to Gregg Reynolds, bazel-discuss
I believe you also need to add the file to an output group via the OutputGroupInfo, and request that output group on the command line. See https://docs.bazel.build/versions/master/skylark/rules.html#requesting-output-files for more information

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAO40Mi%3DgeL6PFeHACanTrSsWbh6HZHyBiFC1j7t%2BMN1yruCAPg%40mail.gmail.com.

Gregg Reynolds

unread,
Feb 28, 2021, 12:32:37 PM2/28/21
to Daniel Wagner-Hall, bazel-discuss
On Sun, Feb 28, 2021 at 5:28 AM Daniel Wagner-Hall <dawa...@gmail.com> wrote:
I believe you also need to add the file to an output group via the OutputGroupInfo, and request that output group on the command line. See https://docs.bazel.build/versions/master/skylark/rules.html#requesting-output-files for more information

Double thanks!  Not only does that solve my problem, but (re-re-)reading the related documentation on output attributes (a masterpiece of impenetrability) I realized they would solve a completely unrelated problem that has been a big problem.  So thank you thank you!
Reply all
Reply to author
Forward
0 new messages