On May 25, 2013, at 23:41, Evan Martin <
mar...@danga.com> wrote:
> […] Your idea (of automatically providing the path) is interesting. I guess it would work around your spaces issue too, wouldn't it? (In that $gcc_depfile could string expand to a quoted path like who $in does.)
Yes, it would also be a fix for the spaces issue.
> Some random thoughts:
> - In the case where you're not using deps mode (where the .d files need to stick around between builds), Ninja isn't really equipped to generate a long-lived path for you. This means we might need to vary behavior (generate paths vs not) in deps vs non-deps mode.
I hadn’t considered that case. I assume though that if people want the .d file to stick around, they want to control the path themselves.
> - We don't really have a precedent for "magic" behavior like this (where accessing a variable automatically makes it both exist and have meaning). Though maybe you could squint at it and say it's like "$in", like: "If you specify deps=gcc, then the variable $depfile is also provided by Ninja to point at a temporary file."
That does remove the magic (and I generally prefer explicit, as it leaves no room for misunderstandings). It gives us 4 total cases:
1. ‘deps’ unset and ‘depfile’ unset → ninja does nothing
2. ‘deps’ unset and ‘depfile’ set → ninja uses depfile
3. ‘deps’ set and ‘depfile’ set → ninja copies to cache and unlinks
4. ‘deps’ set and ‘depfile’ unset → ninja sets $depfile for execution, copies to cache and unlinks
Here #2 would be for users that want the .d files to stick around and #3 would be legacy since #4 offers handling of shell escaping with less syntax.
Possibly #4 would only have my stated action for ‘deps = gcc’ and for ‘deps = msvc’ it would read from stdout rather than involve the temporary file (if I understood you correct).
If we conisder #3 legacy my only dislike with the above is that #2 leaves the shell escaping to the user, which is somewhat arcane. However, this is also the current situation, and I would think very few users would actually need #2, so the manual would encourage #4 and mention #2 as a possibility for those who need full control over the lifetime of their .d files.