* How to reuse code in oe-core environment
@ 2011-06-29 23:02 Andreas Mueller
2011-06-29 23:57 ` Khem Raj
2011-06-29 23:59 ` Chris Larson
0 siblings, 2 replies; 6+ messages in thread
From: Andreas Mueller @ 2011-06-29 23:02 UTC (permalink / raw)
To: openembedded-core
Hi,
I am playing around with oe-core try to find a way of reusing code for multiple
recipes. In oe I did create foo.inc with
foo() {
# code to reuse
}
and called foo from several recipes. In oe-core the run.* scripts are much more
stripped of unnecessary. All the code included by 'require' seems to miss, so
the function foo() will not be found.
My searches for examples did not lead to a hook so what is the suggested
solution for reusing code for multiple recipes in oe-core?
regards
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: How to reuse code in oe-core environment
2011-06-29 23:02 How to reuse code in oe-core environment Andreas Mueller
@ 2011-06-29 23:57 ` Khem Raj
2011-06-29 23:59 ` Chris Larson
1 sibling, 0 replies; 6+ messages in thread
From: Khem Raj @ 2011-06-29 23:57 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Wed, Jun 29, 2011 at 4:02 PM, Andreas Mueller <schnitzeltony@gmx.de> wrote:
> Hi,
>
> I am playing around with oe-core try to find a way of reusing code for multiple
> recipes. In oe I did create foo.inc with
>
> foo() {
> # code to reuse
> }
>
> and called foo from several recipes. In oe-core the run.* scripts are much more
> stripped of unnecessary. All the code included by 'require' seems to miss, so
> the function foo() will not be found.
>
> My searches for examples did not lead to a hook so what is the suggested
> solution for reusing code for multiple recipes in oe-core?
>
hmm do u mean something like what busybox recipe is doing as an example.
or did I misunderstand
> regards
>
> Andreas
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: How to reuse code in oe-core environment
2011-06-29 23:02 How to reuse code in oe-core environment Andreas Mueller
2011-06-29 23:57 ` Khem Raj
@ 2011-06-29 23:59 ` Chris Larson
2011-06-30 0:32 ` Mark Hatle
2011-06-30 0:39 ` Andreas Mueller
1 sibling, 2 replies; 6+ messages in thread
From: Chris Larson @ 2011-06-29 23:59 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Wed, Jun 29, 2011 at 4:02 PM, Andreas Mueller <schnitzeltony@gmx.de> wrote:
> foo() {
> # code to reuse
> }
>
> and called foo from several recipes. In oe-core the run.* scripts are much more
> stripped of unnecessary. All the code included by 'require' seems to miss, so
> the function foo() will not be found.
>
> My searches for examples did not lead to a hook so what is the suggested
> solution for reusing code for multiple recipes in oe-core?
The require doesn't have to do with anything. bitbake emits only the
functions which get called somewhere from the task being run. It
tracks what variables reference what other variables. If you call a
shell function from another shell function, it tracks this, and
realizes that both need to be emitted. Either you're doing something
wrong, or you're doing something in a way that bitbake can't track.
There's a variable flag you can set to explicitly add variable
dependencies.
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: How to reuse code in oe-core environment
2011-06-29 23:59 ` Chris Larson
@ 2011-06-30 0:32 ` Mark Hatle
2011-06-30 0:42 ` Andreas Mueller
2011-06-30 0:39 ` Andreas Mueller
1 sibling, 1 reply; 6+ messages in thread
From: Mark Hatle @ 2011-06-30 0:32 UTC (permalink / raw)
To: openembedded-core
On 6/29/11 6:59 PM, Chris Larson wrote:
> On Wed, Jun 29, 2011 at 4:02 PM, Andreas Mueller <schnitzeltony@gmx.de> wrote:
>> foo() {
>> # code to reuse
>> }
>>
>> and called foo from several recipes. In oe-core the run.* scripts are much more
>> stripped of unnecessary. All the code included by 'require' seems to miss, so
>> the function foo() will not be found.
>>
>> My searches for examples did not lead to a hook so what is the suggested
>> solution for reusing code for multiple recipes in oe-core?
>
> The require doesn't have to do with anything. bitbake emits only the
> functions which get called somewhere from the task being run. It
> tracks what variables reference what other variables. If you call a
> shell function from another shell function, it tracks this, and
> realizes that both need to be emitted. Either you're doing something
> wrong, or you're doing something in a way that bitbake can't track.
> There's a variable flag you can set to explicitly add variable
> dependencies.
There is an example of how to work around this in the rootfs_rpm.bbclass.. It's
a bit odd, but it has to do with the way the function is called:
# Workaround so the parser knows we need the resolve_package function!
if false ; then
resolve_package_rpm foo ${RPMCONF_TARGET_BASE}.conf || true
fi
....
pkg_name=$(resolve_package_rpm $pkg-locale-$lang
${RPMCONF_TARGET_BASE}.conf)
So if the function is called within a subshell, the parser doesn't appear to
know it's there.. so you have to reference it in the function somewhere (the if
false works well for this) in order for it to be available to call.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: How to reuse code in oe-core environment
2011-06-30 0:32 ` Mark Hatle
@ 2011-06-30 0:42 ` Andreas Mueller
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Mueller @ 2011-06-30 0:42 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Thursday, June 30, 2011 02:32:56 AM Mark Hatle wrote:
> On 6/29/11 6:59 PM, Chris Larson wrote:
> > On Wed, Jun 29, 2011 at 4:02 PM, Andreas Mueller <schnitzeltony@gmx.de>
wrote:
> >> foo() {
> >>
> >> # code to reuse
> >>
> >> }
> >>
> >> and called foo from several recipes. In oe-core the run.* scripts are
> >> much more stripped of unnecessary. All the code included by 'require'
> >> seems to miss, so the function foo() will not be found.
> >>
> >> My searches for examples did not lead to a hook so what is the suggested
> >> solution for reusing code for multiple recipes in oe-core?
> >
> > The require doesn't have to do with anything. bitbake emits only the
> > functions which get called somewhere from the task being run. It
> > tracks what variables reference what other variables. If you call a
> > shell function from another shell function, it tracks this, and
> > realizes that both need to be emitted. Either you're doing something
> > wrong, or you're doing something in a way that bitbake can't track.
> > There's a variable flag you can set to explicitly add variable
> > dependencies.
>
> There is an example of how to work around this in the rootfs_rpm.bbclass..
> It's a bit odd, but it has to do with the way the function is called:
>
> # Workaround so the parser knows we need the resolve_package
> function! if false ; then
> resolve_package_rpm foo ${RPMCONF_TARGET_BASE}.conf || true
> fi
>
>
> ....
>
> pkg_name=$(resolve_package_rpm $pkg-locale-$lang
> ${RPMCONF_TARGET_BASE}.conf)
>
>
> So if the function is called within a subshell, the parser doesn't appear
> to know it's there.. so you have to reference it in the function somewhere
> (the if false works well for this) in order for it to be available to
> call.
I'll try to understand that tomorrow zzzzz
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to reuse code in oe-core environment
2011-06-29 23:59 ` Chris Larson
2011-06-30 0:32 ` Mark Hatle
@ 2011-06-30 0:39 ` Andreas Mueller
1 sibling, 0 replies; 6+ messages in thread
From: Andreas Mueller @ 2011-06-30 0:39 UTC (permalink / raw)
To: Patches and discussions about the oe-core layer
On Thursday, June 30, 2011 01:59:33 AM Chris Larson wrote:
> On Wed, Jun 29, 2011 at 4:02 PM, Andreas Mueller <schnitzeltony@gmx.de> wrote:
> > foo() {
> > # code to reuse
> > }
> >
> > and called foo from several recipes. In oe-core the run.* scripts are
> > much more stripped of unnecessary. All the code included by 'require'
> > seems to miss, so the function foo() will not be found.
> >
> > My searches for examples did not lead to a hook so what is the suggested
> > solution for reusing code for multiple recipes in oe-core?
>
> The require doesn't have to do with anything. bitbake emits only the
> functions which get called somewhere from the task being run. It
> tracks what variables reference what other variables. If you call a
> shell function from another shell function, it tracks this, and
> realizes that both need to be emitted. Either you're doing something
> wrong, or you're doing something in a way that bitbake can't track.
> There's a variable flag you can set to explicitly add variable
> dependencies.
the scenario I wrote was not the whole truth - sorry:
I am making a new layer. There I have created u-boot_git.bbappend. In the build
log I see that this extends u-boot_git.bb coming from meta-texasinstruments. In
u-boot_git.bbappend there is (besides other showing me that bbappending works)
| require foo.inc
and
| do_deploy_append_<mynewmachine> {
| foo
| }
the code in foo.inc is something like
| foo() {
| sed ..
| install ...
| }
Build stops complaining that foo cannot be found and the only function I see in
run.do_deploy.nnnnn is do_deploy().
All code was taken from oe and builds fine there. Only difference to oe is that
the lines now found in u-boot_git.bbappend were part of the one and only u-
boot_git.bb recipe.
Is it possible that that the dependency checks ignore functions brought in by
bbappend - or where am I going wrong?
regards
Andreas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-06-30 0:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-29 23:02 How to reuse code in oe-core environment Andreas Mueller
2011-06-29 23:57 ` Khem Raj
2011-06-29 23:59 ` Chris Larson
2011-06-30 0:32 ` Mark Hatle
2011-06-30 0:42 ` Andreas Mueller
2011-06-30 0:39 ` Andreas Mueller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox