Subject: Re: [PATCH] Don't create nested target directories automatically

From: Sergey Matveev <[email-masked]>
Date: Fri, 15 Apr 2022 19:23:38 +0300

*** goredo [2022-04-15 13:17]:
>Next situation: In goredo, it is legal and wanted, that you can implement always-out-of-date targets by not creating any output. You would still need the directory to store the record for that target. And it would not be obvious, why you'd have to have a mkdir call, when you don't want to write something.

Absolutely right! Phony targets will anyway just have to store at least
their "Build:"-identifier that is used to determine if the target was
already built during parallel jobs run. And it keeps ifcreate-dependencies
on .do-files. Phony targets are the first citizen dependencies as any
others too, they just do not has any content and are always out-of-date
because of that.

>One suggestion to your patch: Instead of failing, you could defer creating the directory to the point where redo actually wants to write a record to a file.

The only thing I see is really just to defer creating of dependency
information file until .do-file was really found. But if .do file is
run, then directories will be created anyway to store $3 and stdout
output. They can neither be deferred nor placed in other directories,
because they are renamed, that happens only within single filesystem.
So if .do fails, then anyway you will have directories and probably
empty .redo left.

Is it worth adding more complex code, just to remove some garbage if no
.do file was found? Anyway if you have got some default.do in
directories above, then the whole bunch of directories and .redo will be
created anyway, probably failing the target, leaving no $3/stdout files,
but directories are have to be created there. And you can not remove
them, checking if they are empty, because that will race with probably
running simultaneous jobs.

-- 
Sergey Matveev (http://www.stargrave.org/)
OpenPGP: CF60 E89A 5923 1E76 E263  6422 AE1A 8109 E498 57EF