This issue is to track support for directory targets. The first step is to describe exactly what directory targets mean. @snowleopard pointed to this document which explains how the Microsoft tools handle directory targets. This seems like a good starting point.
So, here is a draft proposal, which we can turn into a proper RFC at some point.
A directory target corresponds to a file tree rooted at a specified path, for example, docs/*. Typical examples of rules producing directory targets are: unzipping an archive, running make in a vendored package, and building files with non-deterministic names (e.g. including the current date).
There are two ways to depend on a directory target:
docs/*. Opaque dependencies are invalidated if the contents of the tree is changed in any way.docs/html/index.html. A projection dependency works like a usual file dependency and supports early cutoff. For example, if the docs/* directory is rebuilt and only docs/html/logo.png is modified, then the dependency on docs/html/index.html is considered to be up-to-date. Note that it is easy to make a mistake with such projection dependencies, for example, by forgetting that index.html actually does include the image docs/html/logo.png. In such cases, sandboxing will help since only the requested projection dependencies will be copied.Constraints:
Here are some possible extensions of the above basic version to consider:
Opaque directory targets: a rule may declare that its directory target is opaque, in which case projection dependencies on its content will be disallowed. One can also consider only partially opaque directory targets, where the contents of the directory is only partially visible.
Shared directory targets: it is possible to allow multiple rules to write to the same directory target, as long as they do not write to the same files. In this case, depending on a directory target would mean depending on all of the rules that declare it as a target. Conceptually, this is more complex but it can be added as an extension.
I will be editing this comment to include other alternatives as the discussion goes, so that we can keep everything in one place.
I like this proposal :)
One thought: when a sandboxed rule depends on an opaque directory, we could produce a single symlink to the directory. That would save doing one symlink for each file. Though it's a bit dodgy as one could escape the sandbox by accident with ...
Most helpful comment
So, here is a draft proposal, which we can turn into a proper RFC at some point.
Directory targets
A directory target corresponds to a file tree rooted at a specified path, for example,
docs/*. Typical examples of rules producing directory targets are: unzipping an archive, runningmakein a vendored package, and building files with non-deterministic names (e.g. including the current date).There are two ways to depend on a directory target:
docs/*. Opaque dependencies are invalidated if the contents of the tree is changed in any way.docs/html/index.html. A projection dependency works like a usual file dependency and supports early cutoff. For example, if thedocs/*directory is rebuilt and onlydocs/html/logo.pngis modified, then the dependency ondocs/html/index.htmlis considered to be up-to-date. Note that it is easy to make a mistake with such projection dependencies, for example, by forgetting thatindex.htmlactually does include the imagedocs/html/logo.png. In such cases, sandboxing will help since only the requested projection dependencies will be copied.Constraints:
Extensions
Here are some possible extensions of the above basic version to consider:
Opaque directory targets: a rule may declare that its directory target is opaque, in which case projection dependencies on its content will be disallowed. One can also consider only partially opaque directory targets, where the contents of the directory is only partially visible.
Shared directory targets: it is possible to allow multiple rules to write to the same directory target, as long as they do not write to the same files. In this case, depending on a directory target would mean depending on all of the rules that declare it as a target. Conceptually, this is more complex but it can be added as an extension.
I will be editing this comment to include other alternatives as the discussion goes, so that we can keep everything in one place.