NXP官方yocto学习(四)如何加入 hello-world 应用程序

        找一个目录下面建立目录“recipes-customer”,以及子目录“hello-world”;在recipes-customer/hello-world/路径下,建立 “hello-world”子目录和“hello-world_1.0.0.bb”文件。
recipes-customer/
└── hello-world
    ├── hello-world
    │   └── hello-world.cpp
    └── hello-world_1.0.0.bb

        hello-world_1.0.0.bb文件 

# Package summary
SUMMARY = "Hello World"
# License, for example MIT
LICENSE = "MIT"
# License checksum file is always required
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
# hello-world.c from local file
SRC_URI = "file://hello-world.cpp"
 
# Set LDFLAGS options provided by the build system
TARGET_CC_ARCH += "${LDFLAGS}"
 
# Change source directory to workdirectory where hello-world.cpp is
S = "${WORKDIR}"
 
# Compile hello-world from sources, no Makefile
do_compile() {
    ${CXX} -Wall hello-world.cpp -o hello-world
}
 
# Install binary to final directory /usr/bin
do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${S}/hello-world ${D}${bindir}
}

        在hello-world目录下创建“hello-world.cpp”文件

#include <stdio.h>
 
int main(int argc, char *argv[]){
    printf("Hello world!\n");
    return 0;
}

        修改recipes-core/images/core-image-minimal.bb 文件,告知 image 构建规则需要加入 hello-world 应用程序

IMAGE_INSTALL_append = " \
    hello-world\
        构建镜像,镜像中的根文件系统下的/usr/bin 就内置了 hello-world 应用程序。        
bitbake hello-world

        编译临时目录 

[wangyb@wangyb-VirtualBox:build]$ ls tmp/work/aarch64-poky-linux/hello-world/1.0.0-r0/
configure.sstate   hello-world       image            packages-split  pseudo                 sstate-install-package      sstate-install-package_write_rpm  sysroot-destdir
debugsources.list  hello-world.cpp   license-destdir  patches         recipe-sysroot         sstate-install-packagedata  sstate-install-populate_lic       temp
deploy-rpms        hello-world.spec  package          pkgdata         recipe-sysroot-native  sstate-install-package_qa   sstate-install-populate_sysroot

猜你喜欢

转载自blog.csdn.net/TSZ0000/article/details/124153068