如何简化 recipe-sysroot-native

how to simplify recipe-sysroot-native

目录recipe-sysroot-native占用200M+磁盘space,我发现它存在于每个WORKDIR中,我认为它们都有保存内容。有这么多副本是对磁盘 space 的浪费,而且它可能会减慢构建时间。能不能放在一个固定的地方,每个WORKDIR通过符号link访问它??

staging.bbclass 中所述,recipe-sysrootrecipe-sysroot-native 中的文件并不总是副本。 Yocto 尝试创建指向实际文件的硬链接(即仅增加对文件的引用计数)。

因此 recipe-sysrootrecipe-sysroot-native 中的所有文件都是指向磁盘中一个源文件的硬链接。所以你的磁盘上没有任何重复的 space 被占用。

Here 您可以看到 staging.bbclass 的实际实现,它会尝试创建硬链接,如果不允许,则会创建一个副本。

您可以随时使用 ls -i 查看文件的引用计数。

以下文字是从yocto mega meanual复制的,

The second stage addresses recipes that want to use something from another recipe and declare a dependency on that recipe through the DEPENDS variable. The recipe will have a do_prepare_recipe_sysroot task and when this task executes, it creates the recipe-sysroot and recipe-sysroot-native in the recipe work directory (i.e. WORKDIR). The OpenEmbedded build system creates hard links to copies of the relevant files from sysroots-components into the recipe work directory.

Note: If hard links are not possible, the build system uses actual copies.