yocto 食谱中的 WORKDIR

WORKDIR in a yocto recipe

当我打开 bitbake 文件(以 .bb 扩展名结尾)时,大多数文件都使用 WORKDIR 变量,如下所示。

S = "${WORKDIR}/git" 

你能告诉我这个 WORKDIR 是在哪里定义的吗?

WORKDIR 在以下文件中定义。

bitbake/conf/bitbake.conf
oe-core/meta/conf/bitbake.conf

来自 Yocto 项目参考手册

WORKDIR

The pathname of the work directory in which the OpenEmbedded build system builds a recipe. This directory is located within the TMPDIR directory structure and is specific to the recipe being built and the system for which it is being built.

The WORKDIR directory is defined as follows:

    ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}

The actual directory depends on several things:

   TMPDIR: The top-level build output directory
   MULTIMACH_TARGET_SYS: The target system identifier
   PN: The recipe name
   EXTENDPE: The epoch - (if PE is not specified, which is usually the >case for most recipes, then EXTENDPE is blank)
   PV: The recipe version
   PR: The recipe revision

As an example, assume a Source Directory top-level folder name poky, a default Build Directory at poky/build, and a qemux86-poky-linux machine target system. Furthermore, suppose your recipe is named foo_1.3.0-r0.bb. In this case, the work directory the build system uses to build the package would be as follows:

    poky/build/tmp/work/qemux86-poky-linux/foo/1.3.0-r0

http://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#var-WORKDIR

${TMPDIR} 将是 Yocto 构建目录中名为 "tmp" 的文件夹。

${WORKDIR} 的默认值在 bitbake 变量中定义。但是你可以在食谱中改变它。它指向 bitbake 解压包的目录

您可以从bitbake环境中获取${WORKDIR}的值

bitbake -e <recipe-name> | grep ^WORKDIR=

对于特定的配方,您可以通过获取环境文件来获取所有变量的值:

bitbake -e recipe_name > env