Yocto Recipe中class-target与class-native的区别及语法疑问
class-native vs class-target in Yocto Recipes Great question! This is a core concept in Yocto's cross-compilation workflow, so let's break it down clearly.
First, it helps to remember that Yocto builds two distinct types of software: tools that run on your build host (the Linux machine you're using to create the embedded image), and software that runs on your target embedded system (the board/device you're deploying to). These two classes define which context a recipe or variable applies to.
What is class-native?
class-nativerefers to software compiled to run on your build host, not the target device.- These are typically tools needed during the build process: cross-compilers, image utilities, bootloader tools (like
grub-efi-native), or packaging helpers. - When you see a variable suffix like
_class-native(e.g.,DEPENDS_class-native), it means that variable only applies when building a native-class recipe.
What is class-target?
class-targetis the default for most recipes, referring to software compiled to run on the target embedded system.- This includes everything that ends up in your final embedded image: the Linux kernel, user-space apps, libraries, and system services.
- A suffix like
_class-target(like your exampleDEPENDS_append_class-target = " grub-efi-native") means the variable applies only when building a target-class recipe.
Your Example Explained
The line DEPENDS_append_class-target = " grub-efi-native" tells BitBake:
When building this target-class recipe (the one that will run on your embedded device), we first need to build the
grub-efi-nativetool (which runs on your build host). This native tool is required during the build process of the target software—maybe to generate EFI boot files or perform some bootloader-related setup for the target.
Quick Comparison
class-native- Runs on: Build host
- Purpose: Build-time tools for the host
- Variable suffix: Applies only to native recipes
class-target- Runs on: Target embedded system
- Purpose: End-user software for the device
- Variable suffix: Applies only to target recipes
内容的提问来源于stack exchange,提问作者md.jamal

