bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #60077] Deterministic $@ for grouped targets patch


From: Todd Lowe
Subject: [bug #60077] Deterministic $@ for grouped targets patch
Date: Thu, 18 Feb 2021 13:42:04 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?60077>

                 Summary: Deterministic $@ for grouped targets patch
                 Project: make
            Submitted by: toddlowe
            Submitted on: Thu 18 Feb 2021 06:42:02 PM UTC
                Severity: 3 - Normal
              Item Group: Enhancement
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.3
        Operating System: None
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

My team currently uses a macro that expands to multiple rules as a way to
simulate a rule with multiple targets.  I would like to use grouped-targets
instead, but like others, have discovered that $@ referring to the target that
triggered execution rather than a specific target from the list makes it
difficult to use.

I have had a look at
[bug #57898] Automatic variable for all targets on grouped target
and 
[bug #58845] In would be nice to have "$&" expand to all targets in a grouped
target
But they refer to a way to get all targets rather than a deterministic way to
always get a “primary target”.

For my use case, I would like $@ to always expand to a specific target from
the grouped list, similar to how $< is always the first prereq.  I’m not a
fan of non-backwards compatible changes, but due to the way grouped-targets
works,  I think this change makes $@ more useful and allows it’s behaviour
to be more consistent between regular recipes and grouped-target recipes. 

I’ve attached a patch that causes $@ for grouped-targets to always be the
first target from the list plus changes to the test suite for the new
behaviour.

Matching the prereq behaviour of having variables for first, trigger, and all
seems cleaner than requiring recipes to extract a target from the entire list
so I am also considered adding $& for all a new $! to represent the triggering
target.

Since my current need is only for $@ to consistency return a specific target,
that is what I have implemented and want to share.    

In order to not force this behaviour change on multi-target pattern rules, I
ended up adding a “grouped_target” file flag and only apply my change if
it is set.  I didn’t want to add an extra flag, but other attempts at
excluding pattern-rules quickly became messy.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 18 Feb 2021 06:42:02 PM UTC  Name:
0001-Make-always-return-the-1st-target-for-grouped-target.patch  Size: 4KiB  
By: toddlowe

<http://savannah.gnu.org/bugs/download.php?file_id=50880>

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60077>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]