* some simple questions about assignment and appending
@ 2012-06-19 16:28 Robert P. J. Day
2012-06-19 17:32 ` Paul Eggleton
0 siblings, 1 reply; 4+ messages in thread
From: Robert P. J. Day @ 2012-06-19 16:28 UTC (permalink / raw)
To: OE Core mailing list
i want to make absolutely sure i understand the mechanics of the
different types of assignment so i'm looking at this snippet from
core-image.bbclass:
... snip ...
PACKAGE_GROUP_qt4-pkgs = "task-core-qt-demos"
CORE_IMAGE_BASE_INSTALL = '\
task-core-boot \
task-base-extended \
\
${CORE_IMAGE_EXTRA_INSTALL} \
'
CORE_IMAGE_EXTRA_INSTALL ?= ""
IMAGE_INSTALL ?= "${CORE_IMAGE_BASE_INSTALL}"
... snip ...
first, if you're assigning a fixed string (as in the first line
shown in the snippet above), i assume there is no functional
difference in using "=" versus ":=", correct?
next, is there any value in that null line in the assignment to
CORE_IMAGE_BASE_INSTALL?
next, is it technically necessary to conditionally do this?
CORE_IMAGE_EXTRA_INSTALL ?= ""
if that variable wasn't set, does it really need to be set to the
empty string?
finally, what are the evaluation mechanics of the "?=" operator? in
this line,
IMAGE_INSTALL ?= "${CORE_IMAGE_BASE_INSTALL}"
is the right-hand side evaluated first? i ask since i find the
snippet above a bit confusing in that you need to follow backwards to
deduce what IMAGE_INSTALL is eventually set to. i would think this
would be easier to read:
CORE_IMAGE_BASE_INSTALL = '\
task-core-boot \
task-base-extended
IMAGE_INSTALL = "${CORE_IMAGE_BASE_INSTALL} ${CORE_IMAGE_EXTRA_INSTALL}"
in this rewriting, i can *immediately* see what values are used to
construct IMAGE_INSTALL. in the current code, it's nowhere near as
clear, and you have to backtrack to see how CORE_IMAGE_BASE_INSTALL is
assigned. or would that not be equivalent based on a misunderstanding
of how assignment works?
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: some simple questions about assignment and appending
2012-06-19 16:28 some simple questions about assignment and appending Robert P. J. Day
@ 2012-06-19 17:32 ` Paul Eggleton
2012-06-19 20:49 ` Robert P. J. Day
0 siblings, 1 reply; 4+ messages in thread
From: Paul Eggleton @ 2012-06-19 17:32 UTC (permalink / raw)
To: Robert P. J. Day; +Cc: openembedded-core
On Tuesday 19 June 2012 12:28:22 Robert P. J. Day wrote:
> i want to make absolutely sure i understand the mechanics of the
> different types of assignment so i'm looking at this snippet from
> core-image.bbclass:
>
> ... snip ...
>
> PACKAGE_GROUP_qt4-pkgs = "task-core-qt-demos"
>
> CORE_IMAGE_BASE_INSTALL = '\
> task-core-boot \
> task-base-extended \
> \
> ${CORE_IMAGE_EXTRA_INSTALL} \
> '
>
> CORE_IMAGE_EXTRA_INSTALL ?= ""
>
> IMAGE_INSTALL ?= "${CORE_IMAGE_BASE_INSTALL}"
>
> ... snip ...
>
> first, if you're assigning a fixed string (as in the first line
> shown in the snippet above), i assume there is no functional
> difference in using "=" versus ":=", correct?
Correct. := means immediately expand all variable references and set the
variable's value to the result; if there aren't any references the value is
the same.
> next, is there any value in that null line in the assignment to
> CORE_IMAGE_BASE_INSTALL?
There's no functional meaning at least, I assume it is there purely for
formatting reasons.
> next, is it technically necessary to conditionally do this?
>
> CORE_IMAGE_EXTRA_INSTALL ?= ""
>
> if that variable wasn't set, does it really need to be set to the
> empty string?
Yes - references to unset variables are left unexpanded so without that line
if the variable was unset you would end up with a literal
${CORE_IMAGE_EXTRA_INSTALL} within the expanded value of
CORE_IMAGE_BASE_INSTALL, which would not be good.
> finally, what are the evaluation mechanics of the "?=" operator?
?= is the same as = except that it only sets the value if it is not already
set at the time the line is parsed.
> in this line,
>
> IMAGE_INSTALL ?= "${CORE_IMAGE_BASE_INSTALL}"
>
> is the right-hand side evaluated first? i ask since i find the
> snippet above a bit confusing in that you need to follow backwards to
> deduce what IMAGE_INSTALL is eventually set to. i would think this
> would be easier to read:
>
> CORE_IMAGE_BASE_INSTALL = '\
> task-core-boot \
> task-base-extended
>
> IMAGE_INSTALL = "${CORE_IMAGE_BASE_INSTALL} ${CORE_IMAGE_EXTRA_INSTALL}"
>
> in this rewriting, i can *immediately* see what values are used to
> construct IMAGE_INSTALL. in the current code, it's nowhere near as
> clear, and you have to backtrack to see how CORE_IMAGE_BASE_INSTALL is
> assigned.
So overall I agree this has unfortunately ended up being rather messy. To me,
the above change should be OK at face value and would improve readability;
however given that we potentially broke people's images/configuration not that
long ago by changing from POKY_* to CORE_IMAGE_* I think we want to be careful
about making significant changes to this again.
Cheers,
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: some simple questions about assignment and appending
2012-06-19 17:32 ` Paul Eggleton
@ 2012-06-19 20:49 ` Robert P. J. Day
2012-06-22 1:21 ` Christopher Larson
0 siblings, 1 reply; 4+ messages in thread
From: Robert P. J. Day @ 2012-06-19 20:49 UTC (permalink / raw)
To: Paul Eggleton; +Cc: openembedded-core
On Tue, 19 Jun 2012, Paul Eggleton wrote:
> On Tuesday 19 June 2012 12:28:22 Robert P. J. Day wrote:
>
> > finally, what are the evaluation mechanics of the "?=" operator?
>
> ?= is the same as = except that it only sets the value if it is not
> already set at the time the line is parsed.
just so i don't come across as a total idiot, i did understand that
"?=" is a conditional assignment -- my question was whether it had
immediate evaluation semantics like ":=" or delayed evaluation
semantics like "=", and you appear to have answered that. thanks.
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: some simple questions about assignment and appending
2012-06-19 20:49 ` Robert P. J. Day
@ 2012-06-22 1:21 ` Christopher Larson
0 siblings, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2012-06-22 1:21 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer; +Cc: Paul Eggleton
[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]
The only assignment operator that forces immediate expansion is :=. Otherwise expansion always occurs when the value is used. This is inspired by the behavior of GNU Make. See http://www.gnu.org/software/make/manual/html_node/Flavors.html#Flavors for details of how it works there.
--
Christopher Larson
On Tuesday, June 19, 2012 at 1:49 PM, Robert P. J. Day wrote:
> On Tue, 19 Jun 2012, Paul Eggleton wrote:
>
> > On Tuesday 19 June 2012 12:28:22 Robert P. J. Day wrote:
> >
> > > finally, what are the evaluation mechanics of the "?=" operator?
> >
> > ?= is the same as = except that it only sets the value if it is not
> > already set at the time the line is parsed.
> >
>
>
> just so i don't come across as a total idiot, i did understand that
> "?=" is a conditional assignment -- my question was whether it had
> immediate evaluation semantics like ":=" or delayed evaluation
> semantics like "=", and you appear to have answered that. thanks.
>
> rday
>
> --
>
> ========================================================================
> Robert P. J. Day Ottawa, Ontario, CANADA
> http://crashcourse.ca
>
> Twitter: http://twitter.com/rpjday
> LinkedIn: http://ca.linkedin.com/in/rpjday
> ========================================================================
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org (mailto:Openembedded-core@lists.openembedded.org)
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
>
[-- Attachment #2: Type: text/html, Size: 2845 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-06-22 1:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-19 16:28 some simple questions about assignment and appending Robert P. J. Day
2012-06-19 17:32 ` Paul Eggleton
2012-06-19 20:49 ` Robert P. J. Day
2012-06-22 1:21 ` Christopher Larson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox