[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Idea: Standard way to negate special targets
From: |
David A. Wheeler |
Subject: |
Re: Idea: Standard way to negate special targets |
Date: |
Wed, 12 Jun 2019 10:15:58 -0400 (EDT) |
On Wed, 12 Jun 2019 14:40:40 +0300, Michael Livshin <address@hidden> wrote:
> Or!
> How about a general syntax for canceling prerequisites (not just for
> special targets)? Say, "!:" (inspired by "&:")?
>
> Then you'd just say ".ONESHELL!: my-tricky-target". More verbose than
> "my-tricky-target: ! .ONESHELL" or whatever,
I think the verbosity is a problem - it increases the risk of bugs & time to
change things.
Every time you have to repeat a name you increase the chance
of *almost* repeating the name & having a mysterious bug.
It also means that reading the Makefile will take more time (and you have to
read a Makefile to review or edit it).
But the idea of generalizing it to cancel prerequisites in general, not just
special targets, is a good idea. If you're going to have a capability, I think
it should avoid limitations where reasonable. So I like that expansion.
I think the removal would happen at the first expansion, just like
any other rule. So you could add & remove as desired, with the last one
winning.
So you'd have to have a removal rule after all its adding rules.
That'd be easiest to implement & would be relatively unsurprising.
On Wed, 12 Jun 2019 09:43:26 -0400, Paul Smith <address@hidden> wrote:
> The thing I don't like about this is it's not clear where the "!"
> applies. Does it apply to just the next prereq?
That was my intent.
> What about modifying the target name itself, like:
>
> tricky_target: .!ONESHELL .PHONY ...
I think modifying the target name itself is MUCH worse.
I don't the problem is serious, but I *do* see your point.
I think a better alternative syntax would be to start with "!"
*without* a space after it. For example:
tricky_target: !.ONESHELL .PHONY ...
There's some logic to it; the prerequisites are space-separated,
and now they're still space-separated including the "not a prerequisite"
statement.
That would create pain for filenames that begin with "!", but
prefixing them with "./" would resolve that problem,
and make already limits filenames.
--- David A. Wheeler