Open pauldraper opened 2 years ago
as a workaround I have done
intermediate_dir = ctx.actions.create_dir()
# emit stuff in the dir via actions
ctx.actions.symlink(output, intermediate_dir)
Clever.
I had trouble bypassing this limitation using ctx.actions.symlink
. I ended up having a rule that created many directories using ctx.actions.declare_directory
and then returning them using OutputGroupInfo
and naming them dynamically. Then you can access each dynamic directory using filegroup[output_group]
.
Its frustrating to require a workaround that should be supported properly, but this does appear to work fine.
Unfortunately, the ctx.actions.symlink
workaround creates another problem: it causes Bazel to create a symlink from a file artifact to a directory artifact. This ought to be considered a bug in ctx.actions.symlink
(it causes other parts of Bazel to become confused about whether the artifact the symlink points to is a directory or not) and I'm in the process of disallowing it.
Keeping P4, as far as I understand treeartifacts are already hard to correctly support within the rules. As such I think it’s better not to have the same problem on the targets / external rules interface.
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.
I would like to have a named output directory from a rule.
attr.output
can create output attributes, but the outputs must always be files; they cannot be directories. That seems an artificial/unnecessary limitation.I would like to support directories. Perhaps this could be an argument to
attr.output
. An argumenttype
could be"file"
,"directory"
, or"symlink"
.