[oe] Use python in variable assigment of a recipe
Steffen Sledz
sledz at dresearch-fe.de
Tue Feb 28 12:11:08 UTC 2012
On 28.02.2012 10:55, Paul Eggleton wrote:
> On Tuesday 28 February 2012 10:26:16 Steffen Sledz wrote:
>> According to the user manual it is possible to use python code in variable
>> assignments by using ${@...}.
>>
>> I like to use a function (subprocess.check_output) here which requires an
>> import statement. Where do i have to place this import?
>
> If you've got more than one line of Python then you should probably define a
> normal Python function (just use "def" as you would in a normal python script
> - there are plenty of examples of this) and then call this using ${@...}.
Works. Thx.
>> And another question. Is it possible to determine the path to the recipe
>> itself from with it?
>
> I think you just need to get the value of the FILE variable e.g
>
> d.getVar('FILE', True)
Because i'm working with oe-classic i tried this (found in some other examples):
MYVAR = "${@my_func()}"
def my_func():
bbpath = os.path.dirname(bb.data.getVar('FILE',d,1))
...
But this leads to an error:
NameError: global name 'd' is not defined
:(
--
DResearch Fahrzeugelektronik GmbH
Otto-Schmirgal-Str. 3, 10319 Berlin, Germany
Tel: +49 30 515932-237 mailto:sledz at dresearch-fe.de
Fax: +49 30 515932-299
Geschäftsführer: Dr. Michael Weber, Werner Mögle;
Amtsgericht Berlin Charlottenburg; HRB 130120 B;
Ust.-IDNr. DE273952058
More information about the Openembedded-devel
mailing list