简体   繁体   English

bitbake 配方中的变量扩展

[英]Variable expansion in bitbake recipes

folks.伙计们。

I've been studying yocto building process and I noticed the usage of the following structure:我一直在研究 yocto 构建过程,我注意到以下结构的用法:

PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"

I know that ${} means variable expansion and grep command showed that the function "vars_from_file" is located at bitbake/lib/bb/parse/__init__.py.我知道 ${} 表示变量扩展,并且 grep 命令显示 function “vars_from_file”位于 bitbake/lib/bb/parse/__init__.py。

I would like to understand how this variable expansion works, so I explored bitbake files and found out that:我想了解这个变量扩展是如何工作的,所以我探索了 bitbake 文件并发现:

  • oe-init-build-env calls oe-buildenv-internal, and the last one sets PYTHONPATH to bitbake/lib. oe-init-build-env 调用 oe-buildenv-internal,最后一个将 PYTHONPATH 设置为 bitbake/lib。

  • I'm infering that bitbake uses PYTHONPATH to search for the function vars_from_file我推断 bitbake 使用 PYTHONPATH 搜索 function vars_from_file

What I have not understood are:我不明白的是:

  • the meaning of the symbol "@" in the variable expansion;变量扩展中符号“@”的含义;
  • if bitbake uses PYTHONPATH to search for the function, why did not pass the absolute path ${@bb.parse.__init__.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'} instead of "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"如果 bitbake 使用 PYTHONPATH 搜索 function,为什么没有传递绝对路径${@bb.parse.__init__.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'} "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
  • Is this type of variable expansion applied only in bitbake?.这种类型的变量扩展是否仅适用于 bitbake? I searched in gnu website , and there is not the application of "@" in the beginning of the structures.我在gnu网站上搜索,结构开头没有“@”的应用。

Can someone help me understand them?有人可以帮我理解它们吗?

The @ symbol, is used bit bitbake for inline python variable expansion, and it basically states that you'd be calling a function and expanding its result, usually assigning it to a variable, in your case: @ 符号用于内联 python 变量扩展的位 bitbake,它基本上表明您将调用 function 并扩展其结果,通常将其分配给变量,在您的情况下:

PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"

Its assigning to PN (package name) the result of the function vars_from_file coming from the bitbake python module parse, located at bitbake/lib/bb/parse/它将来自 bitbake python 模块解析的 function vars_from_file 的结果分配给 PN(包名称),位于 bitbake/lib/bb/parse/

Like any other Python module, it automatically loads init .py and has access to those functions when imported.与任何其他 Python 模块一样,它会自动加载init .py 并在导入时访问这些函数。

Whats special about these functions is that they've got access to bitbake's data dictionary, called "d".这些函数的特别之处在于它们可以访问 bitbake 的数据字典,称为“d”。

AFAIC this IS specific to bitbake. AFAIC 这是特定于 bitbake 的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM