From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Daniel Lazzari <dlazzari@leapfrog.com>
Cc: "'bitbake-devel@lists.openembedded.org'
\(bitbake-devel@lists.openembedded.org\)"
<bitbake-devel@lists.openembedded.org>
Subject: Re: python function used in variable expansion called multiple times per recipe
Date: Thu, 19 Apr 2012 23:28:00 +0100 [thread overview]
Message-ID: <1334874480.3028.18.camel@ted> (raw)
In-Reply-To: <E7A9054A5ACABE48B0E540E46E862B0F0427CB32@NAEMMAIL01.na.leapfrog.com>
On Thu, 2012-04-19 at 21:24 +0000, Daniel Lazzari wrote:
> >> I think immediate expansion is what I’ll need to use, thanks for the tip.
> >> That at least brings the invocation down to once per run. Unfortunately, the
> >> variable doesn’t seem to get filled in when I change to immediate
> >expansion.
> >>
> >> def testFunc(bb, d):
> >> print( bb.data.getVar("PN", d, True) )
> >> return "e1"
> >>
> >> EXTERNPV := "${@testFunc(bb, d)}"
> >>
> >> Now only prints the package name once, but using –e, I don’t see the
> >> variable EXTERNPV at all.
> >
> >Don't know what to tell you. It does work, so it's something wrong on
> >your end. Either it's returning an empty string, which will result in
> >-e only showing the commented out definition, or it's raising an
> >exception, or something else in your setup. Aside: you don't need to
> >pass 'bb' in. That namespace is always accessible, even from def'd
> >python functions.
> >--
> >Christopher Larson
>
> Just thought I'd provide an update real quick on this. I discovered,
> to my dismay, that even doing an immediate expansion still ran the
> code before every task for that recipe. I switched to using an event
> handler, but the RecipeParsed event occurs before every task for that
> recipe. Eventually I discovered that the variable BB_WORKERCONTEXT is
> set for RecipeParsed events when they are occurring before a task, but
> not for the initial parse. Also, I discovered that setting a variable
> in the event handler would not necessarily keep it set through
> building the recipe. Thus I devised the below code to run the time
> intensive code during initial parse and cache the value in a file so
> it can be picked up again in later events. I'm leaving this here in
> case it helps someone else.
Just as a note, we have the persist_data code in bitbake which was
written for this kind of reason in relation to SRCREV and AUTOINC which
uses a sqlite backend as the storage. There isn't anything wrong with
what you're doing, I just thought I'd mention it.
Cheers,
Richard
next prev parent reply other threads:[~2012-04-19 22:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-18 21:21 python function used in variable expansion called multiple times per recipe Daniel Lazzari
2012-04-18 23:06 ` Christopher Larson
2012-04-18 23:39 ` Daniel Lazzari
2012-04-18 23:41 ` Chris Larson
2012-04-18 23:57 ` Daniel Lazzari
2012-04-19 21:24 ` Daniel Lazzari
2012-04-19 22:28 ` Richard Purdie [this message]
2012-04-19 23:13 ` Daniel Lazzari
2012-04-20 0:12 ` Chris Larson
2012-04-20 1:05 ` Daniel Lazzari
2012-04-19 23:34 ` McClintock Matthew-B29882
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=1334874480.3028.18.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
--cc=dlazzari@leapfrog.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.