https://pantsbuild.org/ logo
#general
Title
# general
i

icy-umbrella-50644

01/09/2023, 5:12 PM
Hi, I recently came across a problem in Bazel where you have a rule that outputs a directory of randomly named files instead of a few known files. This means you can't add it to the build graph because that only deals in files, not directories. The currently recommended workaround is to zip/unzip the directory before/after running the rule. Not idea. I was wondering if Pants handles this any better?
b

bitter-ability-32190

01/09/2023, 5:15 PM
Mmmm you'd have to be more specific on the problem at hand to get a complete answer. Pants certainly can handle various things at the directory (and file) level, but depending on the situation your ability to cache results of operations may diminish
i

icy-umbrella-50644

01/09/2023, 5:18 PM
Well in Bazel when you define a rule you'd like to say something like this:
Copy code
ctx.actions.run(
        ...
        outputs = [work_dir],
    )
Where
work_dir
is a directory that gets a load of randomly named files written to it. But it doesn't really work because the build graph operates on files with names that are all known at analysis time.
It doesn't have the concept of "this rule generates a directory of stuff, and this other rule needs access to that directory as input".
b

bitter-ability-32190

01/09/2023, 5:21 PM
So Pants defintely supports directory-as-a-unit both at the BUILD-level (
experimental_shell_command
comes to mind) and at the Plugin level (using a
Digest
). Depending on where/how the directory is captured is the razor for caching. So in that regard YMMV
i

icy-umbrella-50644

01/09/2023, 5:21 PM
Ah ok cool that's good to know!