How to clean non-determinate files?

9 views
Skip to first unread message

Matthew Woehlke

unread,
Aug 24, 2021, 8:59:14 AMAug 24
to ninja-build
Say I have a command (sphinx-build, particularly, though I'm sure that
isn't unique) that generates "indeterminate" outputs. Right now, AFAICT,
Ninja has no way of removing these. (Also, it means I have to treat that
edge as always out of date, but fortunately sphinx-build has its own
caching and completes very quickly ­— <1s — if nothing has changed.)

However, its outputs are all isolated in a particular directory.

Is there any way to "teach" Ninja that `-t clean` should also remove
this (non-empty) directory? (Note that right now `-t clean` also *fails*
due to these artifacts, because another rule creates the directory, and
ninja gets angry when, upon trying to remove it again, it sees that it
is non-empty.)

Ultimately, I'd really like to support CMake's ADDITIONAL_CLEAN_FILES,
but there does not seem to be any way in Ninja to do this?

--
Matthew

Ben Boeckel

unread,
Aug 24, 2021, 11:42:11 AMAug 24
to Matthew Woehlke, ninja-build
I suspect you want this PR:

https://github.com/ninja-build/ninja/pull/1953

to also hook in to `-t clean` properly. You'll need to bridge between
"what `sphinx-build` did" and telling `ninja` that manually, but it's
probably doable.

--Ben

Matthew Woehlke

unread,
Aug 24, 2021, 2:05:32 PMAug 24
to Ben Boeckel, ninja-build
I suspect that would be much more work than what I had in mind; in
particular, it would require modifying Sphinx to generate a list of
every file it wrote for Ninja to consume. (Also, that PR seems to be at
least partly about dependencies, which are not at issue in my case;
nothing consumes the output of sphinx-build. Also, sphinx-build depends
on what files *exist* on disk and so there is not really a practical way
for it to generate dependencies, either.)

I really just want a way to tell Ninja that `-t clean` should nuke a
particular *directory* without having to enumerate every file that might
be in it.

--
Matthew
Reply all
Reply to author
Forward
0 new messages