All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Arnout Vandecappelle <arnout@mind.be>
Cc: Michael Rommel <rommel@layer-7.net>,
	Fabrice Fontaine <fontaine.fabrice@gmail.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	buildroot@buildroot.org
Subject: Re: [Buildroot] conditional assigment check in check-package [was: Re: [PATCH v2, 2/2] package/knock: add knockd option]
Date: Thu, 21 Oct 2021 22:12:36 +0200	[thread overview]
Message-ID: <20211021201236.GG2400@scaer> (raw)
In-Reply-To: <88c82aa8-d532-eeb1-bc77-796eafa0d06e@mind.be>

Arnout, All,

On 2021-10-21 20:43 +0200, Arnout Vandecappelle spake thusly:
> On 18/10/2021 22:18, Yann E. MORIN wrote:
> >Thomas, All,
> >On 2021-10-18 22:04 +0200, Thomas Petazzoni spake thusly:
> >>On Sat, 16 Oct 2021 11:32:34 +0200
> >>Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:
> >>>+ifeq ($(BR2_PACKAGE_KNOCK_KNOCKD),y)
> >>>+KNOCK_DEPENDENCIES = libpcap
> >> From commit 97f3ad7af3dd54a15a10aa35786e7fa08cf5e7b1:
> >>     Repeat after me: "Forcing the value of <pkg>_DEPENDENCIES inside a
> >>     conditional is the root of all evil."
> >>Care to repeat after me ? :-)
> >
> >OK, I missed that in my review of v1...
> >/me hides in shame...
> >
> >But seriously though: why is that not caught by check-package?
> >
> >Because it is not actually an override: the variable is not yet set
> >there, so it is valid to unconditionally set it.
> >
> >check-package should probably recognise that the variable is
> ><FOO>_DEPENDENCIES and consider that conditional assignment should
> >still be forbidden in that case.
> 
>  I had a look at this, and it is not entirely trivial to test for in check-package.
> 
>  Basically, this is allowed:
> 
> ifeq(...)
> FOO_VAR = ...
> endif
> ... $(FOO_VAR) ... # Empty if condition not true
> 
>  And this as well:
> 
> ifeq(...)
> FOO_VAR = ...
> else
> FOO_VAR = ...
> endif
> 
>  But this is not:
> 
> ifeq(...)
> FOO_VAR = ...
> endif
> 
> ifeq(...)
> FOO_VAR = ...
> endif
> 
> 
>  So basically:
> - after a variable is assigned, it can't be assigned to any more in the same
> conditional branch;
> - it can be assigned to again in the else branch (including else ifeq constructs);
> - it can not be assigned to any more after the endif.
> 
>  In addition, conditions can be nested...
> 
>  The only way I can think of implementing this is by keeping a stack of
> conditionally assigned variables. In the else branch, the top of the stack
> is saved en empties. At the endif, the top of the stack is popped, merged
> with the saved one, and merged into the new top of the stack.
> 
>  Wow, by writing it down, I almost implemented it :-) Let's see if I can
> still find the time to actually do it tonight...

Sorry, but I think I got lost somewhere...

Currently, check-package does not whine for:

    ifeq(...)
    FOO_VAR = ...
    endif

but it does whine for:

    FOO_VAR = ...
    ifeq(...)
    FOO_VAR = ...
    endif

And these two behaviours are, I think, correct.

What I am arguing, is that FOO_DEPENDENCIES should be treated specially,
where check-package should whine for:

    ifeq(...)
    FOO_DEPENDENCIES = ...
    endif

as well as for:

    FOO_DEPENDENCIES = ...
    ifeq(...)
    FOO_DEPENDENCIES = ...
    endif

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2021-10-21 20:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-16  9:32 [Buildroot] [PATCH v2,1/2] package/knock: bump to version 0.8 Fabrice Fontaine
2021-10-16  9:32 ` [Buildroot] [PATCH v2,2/2] package/knock: add knockd option Fabrice Fontaine
2021-10-18 20:04   ` Thomas Petazzoni
2021-10-18 20:18     ` Yann E. MORIN
2021-10-21 18:43       ` [Buildroot] conditional assigment check in check-package [was: Re: [PATCH v2, 2/2] package/knock: add knockd option] Arnout Vandecappelle
2021-10-21 20:12         ` Yann E. MORIN [this message]
2021-10-21 20:25           ` Arnout Vandecappelle
2021-10-18 20:03 ` [Buildroot] [PATCH v2,1/2] package/knock: bump to version 0.8 Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211021201236.GG2400@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=arnout@mind.be \
    --cc=buildroot@buildroot.org \
    --cc=fontaine.fabrice@gmail.com \
    --cc=rommel@layer-7.net \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.