Subject: Re: Support for virtual targets

From: Sergey Matveev <[email-masked]>
Date: Sun, 17 Apr 2022 00:11:17 +0300

Greetings!

*** Jan Niklas Böhm [2022-04-16 21:13]:
>This caught me a bit by surprise and I was wondering whether its possible to
>actually check whether the target is ood by looking at its dependencies,
>similar to how redo-python does it.  The use case is also given in those
>documents, e. g. compiling a latex document [2].

I am strongly against checking of dependencies for those "virtual" (as
apenwarr/redo calls them) targets. This is a convenient feature.

apenwarr/redo's LaTeX-related example shows how side-effects can be
conveniently used for producing multiple files. That is useful thing,
that I personally use with LaTeX and Texinfo documentation building too.
But there will be no difference in behaviour if that virtual target
produces any output or not. You can add "touch $3" to its end and
everything will work and behave the same way in that apenwarr/redo's
example.

apenwarr/redo mentions that those virtual targets are called .PHONY ones
in make-world. And my make's man page says indeed:

     .PHONY    The target does not correspond to an actual file; it is always
               considered to be out of date, and will not be created with the
               -t option.

So even in make-world, .PHONY by definition is something always
out-of-date. But apenwarr/redo's virtual target does honest OOD
checking and it won't be *always* out-of-date and can not be claimed to
be .PHONE-analogue. apenwarr/redo just has not ability to create real
phony targets, except for using an additional workaround command like
redo-always, that is not supported in all redo implementations and its
usage won't be portable.

In comparison, goredo's non-existent targets (now I slightly corrected
documentation and replaced some "empty" with "non-existent", because it
was confusing: "empty" is just something having zero size) are the real
.PHONY ones -- they are always OOD. If you want to make a target that
honestly does OOD checking, then explicitly create a file ("touch $3" at
least).

So in goredo you can create both real "phony" targets (without producing
any output) and "virtual" targets (by making an empty file).
apenwarr/redo lacks "phony" targets possibility (except for additional
redo-always invocation). Phony targets are used mainly for targets like
"all"/"install" in practice, so as a rule they are called manually with
"redo" command, not redo-ifchange, and that is why they are forcefully
run anyway, like an ordinary phony-target should do. "Virtual" targets,
with explicit "touch $3" are also portable across apenwarr/redo, redo-c
and similar implementations -- so hardly there are any portability issues.

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