bugmake - Bugs: bug #63241, implement "exit" in...

 
 

bug #63241: implement "exit" in makefile parsing

Submitter:  None
Submitted:  Wed 19 Oct 2022 04:43:52 PM UTC
   
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  4.4 Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 20 Oct 2022 09:20:02 PM UTC, comment #1: 

i'd prefer to keep make language free of imperative constructs. Once you give them "if", they'll want "for" and "break" and "exit", etc.
In my experience, it is better to avoid code like

ifneq ($(filter %clean clobber,$(MAKECMDGOALS)),).

This piece of code is an example of an imperative construct.

There are make tools, like target specific variables, implicit rules, pattern matching, etc which often solve the task at hand and reduce complexity.

Dmitry Goncharov <dgoncharov>
Wed 19 Oct 2022 04:43:52 PM UTC, original submission:  

I’ll start this by making an analogy with scripting languages. A Python script might have logic like:

while <condition1>:
    if <condition2>:
        # do thing A
    else:
        # do thing B

Indenting can go to unlimited depths so most languages offer a short-circuit which makes things more readable:

while <condition1>:
    if <condition2>:
        # do thing A
        continue

    # do thing B

Coming back to GNU make, I have quite a few complex (many hundreds of lines) makefiles which require logic like this (greatly simplified):

ifneq ($(filter %clean clobber,$(MAKECMDGOALS)),)
  <clean targets>
else
  <real targets>
endif

This makes it harder to read, because all the “real” logic is a subclause (or 2, or 3) deep. Tracking if-else-endif across large files is difficult. I’m wondering if the make parser would be capable of something like this:

ifneq ($(filter %clean clobber,$(MAKECMDGOALS)),)
  <clean targets>
  exit
endif
<real targets>

Where the “exit” keyword simply says to stop parsing. Perhaps there’s a better name, but the basic idea is to implement short-circuit parsing analogously to the shell example. Doable?

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dgoncharov (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.14-8eb0.
    Corresponding source code