[oe] Programtically setting TMPDIR in bitbake.conf

Chris Larson clarson at kergoth.com
Thu Jun 3 14:53:58 UTC 2010


On Thu, Jun 3, 2010 at 7:08 AM, Alex Bennee <kernel-hacker at bennee.com>wrote:

> I'd like tweak the OpenEmbedded TMPDIR variable so it can optionally
> build into a sub-directory of ${TOPDIR} based on the current git
> status of the OE tree. The usage I envisage would be something like:
>
> bitbake my-image
> =>
> builds to /path/to/build/current/[deploy/staging/etc...]
>
> RELEASE=1 bitbake my-image
> =>
> builds to /path/to/build/build-12345ab/[deploy/staging/etc...]
>
> Which would be based on the GIT commit ID. I'd probably want to
> support the "dirty" semantics similar to the kernels versioning to
> indicate the tree had uncommitted changes.
>
> I know bitbake.conf can use arbitrary python to fill in the variables
> but I'm unclear where these fragments can be put. A lot of python
> snippets seem to refer to things like bb.data.getVar() which I assume
> is part of bitbake itself. Is it possible to define some python in the
> OE tree I can call from bitbake.conf? Is this functionality that has
> to be added to bitbake itself?
>

It supports this just fine today, and I'd bet there are hundreds of examples
in the conf/ and classes/ directories today, as well as in many recipes.


> I assume the change has to be made to bitbake.conf as other variables
> are derived from TMPDIR at that point?
>

That's incorrect.  Bitbake variables are like make variables - they're
evaluated when they're used, lazily, not immediately, unless you use :=
(immediately evaluate).  Anything set in bitbake.conf can be set just as
well in your local.conf.


> Basically I want to avoid writing an overly complex python one-liner
> directly in bitbake.conf, that would seem to perl-ish ;-)
>

If you don't want the entire thing in the variable, define it in a python
function in a .inc and include it from a .conf, and use it in the snippet.

I.e. conf/foo.inc:
def myfunction(d):
    return d.getVar("foo", True) + "bar"

conf/local.conf:
require conf/foo.inc
TMPDIR = "${@myfunction(d)}"
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics



More information about the Openembedded-devel mailing list