zephyr-image: Add image artifacts to output files

Inherit image-artifact-names bbclass in zephyr-image.inc and add
image artifacts to output generated files.

Also keep old image artifacts nomenclature in do_deploy task for
backward compatibility.

Before:
zephyr-helloworld.elf

After:
zephyr-helloworld-{MACHINE}-{DATETIME}.elf

Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com>
This commit is contained in:
Sandeep Gundlupet Raju
2025-08-18 16:02:56 -06:00
committed by Lee Chee Yang
parent 09be45cbb5
commit a28ec67aa0

View File

@@ -1,29 +1,56 @@
require zephyr-kernel-src.inc
require zephyr-kernel-common.inc
inherit deploy
inherit deploy image-artifact-names
OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
ZEPHYR_IMAGE_LINK_NAME ?= "${PN}-${MACHINE}"
ZEPHYR_IMAGE_BASE_NAME ?= "${PN}-${MACHINE}${IMAGE_VERSION_SUFFIX}"
do_install() {
install -d ${D}/firmware
install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${D}/firmware/${PN}.elf
install -D ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${D}/firmware/${ZEPHYR_IMAGE_BASE_NAME}.elf
if [ -f ${B}/zephyr/${ZEPHYR_MAKE_BIN_OUTPUT} ]
then
install -D ${B}/zephyr/${ZEPHYR_MAKE_BIN_OUTPUT} ${D}/firmware/${PN}.bin
install -D ${B}/zephyr/${ZEPHYR_MAKE_BIN_OUTPUT} ${D}/firmware/${ZEPHYR_IMAGE_BASE_NAME}.bin
fi
if [ -f ${B}/zephyr/${ZEPHYR_MAKE_EFI_OUTPUT} ]
then
install -D ${B}/zephyr/${ZEPHYR_MAKE_EFI_OUTPUT} ${D}/firmware/${PN}.efi
install -D ${B}/zephyr/${ZEPHYR_MAKE_EFI_OUTPUT} ${D}/firmware/${ZEPHYR_IMAGE_BASE_NAME}.efi
fi
}
FILES:${PN} = "/firmware"
INSANE_SKIP += "ldflags buildpaths"
SYSROOT_DIRS += "/firmware"
do_deploy() {
cp ${D}/firmware/${PN}.* ${DEPLOYDIR}/
cp ${B}/zephyr/${ZEPHYR_MAKE_OUTPUT} ${DEPLOYDIR}/${ZEPHYR_IMAGE_BASE_NAME}.elf
ln -sf ${ZEPHYR_IMAGE_BASE_NAME}.elf ${DEPLOYDIR}/${ZEPHYR_IMAGE_LINK_NAME}.elf
# Keep old image artifact nomenclautre for backward compatibility.
ln -sf ${ZEPHYR_IMAGE_BASE_NAME}.elf ${DEPLOYDIR}/${PN}.elf
if [ -f ${B}/zephyr/${ZEPHYR_MAKE_BIN_OUTPUT} ]
then
cp ${B}/zephyr/${ZEPHYR_MAKE_BIN_OUTPUT} ${DEPLOYDIR}/${ZEPHYR_IMAGE_BASE_NAME}.bin
ln -sf ${ZEPHYR_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/${ZEPHYR_IMAGE_LINK_NAME}.bin
# Keep old image artifact nomenclautre for backward compatibility.
ln -sf ${ZEPHYR_IMAGE_BASE_NAME}.bin ${DEPLOYDIR}/${PN}.bin
fi
if [ -f ${B}/zephyr/${ZEPHYR_MAKE_EFI_OUTPUT} ]
then
cp ${B}/zephyr/${ZEPHYR_MAKE_EFI_OUTPUT} ${DEPLOYDIR}/${ZEPHYR_IMAGE_BASE_NAME}.efi
ln -sf ${ZEPHYR_IMAGE_BASE_NAME}.efi ${DEPLOYDIR}/${ZEPHYR_IMAGE_LINK_NAME}.efi
# Keep old image artifact nomenclautre for backward compatibility.
ln -sf ${ZEPHYR_IMAGE_BASE_NAME}.efi ${DEPLOYDIR}/${PN}.efi
fi
}
addtask deploy after do_install