help-make
[Top][All Lists]
Advanced

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

Re: Is it possible to break from a GMAKE foreach loop and then exit from


From: Paul Smith
Subject: Re: Is it possible to break from a GMAKE foreach loop and then exit from make?
Date: Sun, 29 May 2022 12:09:45 -0400
User-agent: Evolution 3.44.1 (by Flathub.org))

On Sun, 2022-05-29 at 11:50 -0400, Pierre Rouleau wrote:
> On Sat, May 28, 2022 at 2:11 AM Kaz Kylheku <kaz@kylheku.com> wrote:
> > What you probably want is to generate clauses joined by &&
> > 
> >   $(foreach ....) --> patch < this && patch < that && ... && patch
> > < last
> > 
> > You mean unroll the loop manually?
> Unfortunately the file I'm dealing with is part of a *large* build
> system with over 2000 make file, with make recursion and multi-layer
> decision making  that end up building the list of patch files,
> storing it inside a variable.
> 
> Are you also saying that adding `|| exit 1' to the statement inside
> the foreach loop would not work?
> ie as in:
>         (cd $(OUTPUT_ROOT_DIR)/$(CFG_GLOBAL_LINUX_VERSION); $(foreach
> thepatch,$(KERNEL_PATCH_ONE),echo patching $(thepatch); patch
> --ignore-whitespace -p1 < $(thepatch) || exit 1;))

It will work.  It's simple to test so did you try it and it didn't work
and that's why you're asking?

But I don't understand why the method Kaz suggests wouldn't work.  If
you can change the loop to add "|| exit 1;" after each patch command
why can't you change the loop to add "&&" between each patch command?

It would be something like:

  $(foreach p,$(KERNEL_PATCH_ONE),echo patching $p && patch ... < $p &&) true

The advantage of the "&&" is that your script is shorter which means
you'll be less likely to run into a limit for lots of patches (although
the limits in modern POSIX systems are pretty large).

> In the end do you mean that all I could do is prepend the rule with 
> `set -e; ' and that would ensure termination on the first error?
> As in:
>          set -e; (cd $(OUTPUT_ROOT_DIR)/$(CFG_GLOBAL_LINUX_VERSION);
> $(foreach thepatch,$(KERNEL_PATCH_ONE),echo patching $(thepatch);
> patch
> --ignore-whitespace -p1 < $(thepatch)))

You need a semicolon after the patch command but yes, this will work as
well.



reply via email to

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