Details please refer to [1].
./qemu-system-x86_64 \ -m 4G \ -machine pc,accel=kvm,memory-backend=mem,usb=off \ -device virtio-scsi-pci,id=scsi0 \ -device virtio-net-pci,netdev=net0 \ -netdev user,id=net0,hostfwd=tcp::8022-:22 \ -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \ -device virtio-vga-rutabaga,gfxstream-vulkan=on,cross-domain=on,wayland-socket-path=${WAYLAND_SOCK},hostmem=8G
[1] https://linaro.atlassian.net/wiki/spaces/ORKO/ pages/28985622530/Building+QEMU+with+virtio-gpu+and+rutabaga_gfx
Lei Zhou (3): aemu: add AEMU library gfxstream: add gfxstream recipe rutabaga_gfx_ffi: add as a YOCTO recipe
meta-linaro/recipes-graphics/aemu/aemu_git.bb | 18 +++++ .../gfxstream/gfxstream_git.bb | 18 +++++ ...-Use-env-variable-to-pass-in-RUTABAG.patch | 41 ++++++++++++ .../rutabaga-gfx-ffi-crates.inc | 54 +++++++++++++++ .../rutabaga-gfx-ffi_0.1.3.bb | 65 +++++++++++++++++++ 5 files changed, 196 insertions(+) create mode 100644 meta-linaro/recipes-graphics/aemu/aemu_git.bb create mode 100644 meta-linaro/recipes-graphics/gfxstream/gfxstream_git.bb create mode 100644 meta-linaro/recipes-graphics/rutabaga_gfx_ffi/files/0001-rutabaga-gfx-ffi-Use-env-variable-to-pass-in-RUTABAG.patch create mode 100644 meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi-crates.inc create mode 100644 meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi_0.1.3.bb
AEMU as per [1] is an utility library for common functions used in the Android Emulator. External projects (gfxstream, QEMU) may use to perform C++ functions.
[1] https://android.googlesource.com/platform/hardware/google/aemu
Signed-off-by: Lei Zhou lei.zhou@linaro.org --- meta-linaro/recipes-graphics/aemu/aemu_git.bb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 meta-linaro/recipes-graphics/aemu/aemu_git.bb
diff --git a/meta-linaro/recipes-graphics/aemu/aemu_git.bb b/meta-linaro/recipes-graphics/aemu/aemu_git.bb new file mode 100644 index 0000000..c5d892b --- /dev/null +++ b/meta-linaro/recipes-graphics/aemu/aemu_git.bb @@ -0,0 +1,18 @@ +SUMMARY = "AEMU utility library for common functions used in the Android Emulator" +HOMEPAGE = "https://android.googlesource.com/platform/hardware/google/aemu" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=ff39be111c2cce0426721beaa1211c63" + +inherit cmake pkgconfig + +SRC_URI = "git://android.googlesource.com/platform/hardware/google/aemu;protocol=https;branch=android14-qpr2-release" +SRCREV = "${AUTOREV}" + +PV = "git${SRCPV}" +S = "${WORKDIR}/git" + +DEPENDS += "gfxstream" +BBCLASSEXTEND = "native nativesdk" +EXTRA_OECMAKE = "-DAEMU_COMMON_GEN_PKGCONFIG=ON -DENABLE_VKCEREAL_TESTS=OFF" +EXTRA_OECMAKE:append = " -DAEMU_COMMON_BUILD_CONFIG=gfxstream"
Graphics Streaming Kit (formerly: Vulkan Cereal) as per [1] is a code generator that makes it easier to serialize and forward graphics API calls from one place to another.
[1] https://android.googlesource.com/platform/hardware/google/gfxstream
Signed-off-by: Lei Zhou lei.zhou@linaro.org --- .../gfxstream/gfxstream_git.bb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 meta-linaro/recipes-graphics/gfxstream/gfxstream_git.bb
diff --git a/meta-linaro/recipes-graphics/gfxstream/gfxstream_git.bb b/meta-linaro/recipes-graphics/gfxstream/gfxstream_git.bb new file mode 100644 index 0000000..5bd7975 --- /dev/null +++ b/meta-linaro/recipes-graphics/gfxstream/gfxstream_git.bb @@ -0,0 +1,18 @@ +SUMMARY = "gfxstream for graphics" +DESCRIPTION = "Graphics Streaming Kit is a code generator that makes \ +it easier to serialize and forward graphics API calls from one place to another" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=8c18bc94001e6e45c4727758ff462348" + +SRC_URI = "git://android.googlesource.com/platform/hardware/google/gfxstream;protocol=https;branch=main" +SRCREV = "${AUTOREV}" + +PV = "git${SRCPV}" +S = "${WORKDIR}/git" + +DEPENDS = "aemu libdrm virtual/libx11" +EXTRA_OEMESON += "-Ddefault_library=static" + +inherit meson pkgconfig +BBCLASSEXTEND = "nativesdk"
A RUST crate for handling 2D and 3D virtio-gpu hypercalls, along with graphics swapchain allocation and mapping
[1] https://github.com/google/crosvm/tree/main/rutabaga_gfx/ [2] https://crates.io/crates/rutabaga_gfx/0.1.3
Signed-off-by: Lei Zhou lei.zhou@linaro.org --- ...-Use-env-variable-to-pass-in-RUTABAG.patch | 41 ++++++++++++ .../rutabaga-gfx-ffi-crates.inc | 54 +++++++++++++++ .../rutabaga-gfx-ffi_0.1.3.bb | 65 +++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 meta-linaro/recipes-graphics/rutabaga_gfx_ffi/files/0001-rutabaga-gfx-ffi-Use-env-variable-to-pass-in-RUTABAG.patch create mode 100644 meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi-crates.inc create mode 100644 meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi_0.1.3.bb
diff --git a/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/files/0001-rutabaga-gfx-ffi-Use-env-variable-to-pass-in-RUTABAG.patch b/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/files/0001-rutabaga-gfx-ffi-Use-env-variable-to-pass-in-RUTABAG.patch new file mode 100644 index 0000000..b57a82d --- /dev/null +++ b/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/files/0001-rutabaga-gfx-ffi-Use-env-variable-to-pass-in-RUTABAG.patch @@ -0,0 +1,41 @@ +From 65f9224bc82212956ab28d9172a9e328e65d691c Mon Sep 17 00:00:00 2001 +From: lei zhou lei.zhou@linaro.org +Date: Mon, 11 Mar 2024 19:26:36 +0000 +Subject: [PATCH] rutabaga-gfx-ffi: Use env variable to pass in + RUTABAGA_OUT_DIR + +Signed-off-by: lei zhou lei.zhou@linaro.org +--- + build.rs | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +diff --git a/build.rs b/build.rs +index 3a407c7..9a32955 100644 +--- a/build.rs ++++ b/build.rs +@@ -32,13 +32,17 @@ Libs: -L${libdir} -lrutabaga_gfx_ffi + "###, + ); + ++ let out_dir = env::var("RUTABAGA_OUT_DIR").unwrap_or(format!( ++ "{}/{}", ++ env::var("CARGO_TARGET_DIR").as_deref().unwrap_or("target"), ++ env::var("PROFILE").unwrap() ++ )); ++ let pc_file = format!("{out_dir}/rutabaga_gfx_ffi.pc"); ++ ++ println!("leizhou pc_file = {pc_file}"); ++ + // Write the .pc file to the output directory +- let mut pc_file = File::create(format!( +- "{}/{}/rutabaga_gfx_ffi.pc", +- env::var("CARGO_TARGET_DIR").as_deref().unwrap_or("target"), +- env::var("PROFILE").unwrap() +- )) +- .unwrap(); ++ let mut pc_file = File::create(pc_file).unwrap(); + pc_file.write_all(pc_contents.as_bytes()).unwrap(); + + println!("cargo:rerun-if-changed=build.rs"); // Rebuild if build.rs changes +-- +2.34.1 diff --git a/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi-crates.inc b/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi-crates.inc new file mode 100644 index 0000000..dc251ed --- /dev/null +++ b/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi-crates.inc @@ -0,0 +1,54 @@ +# Autogenerated with 'bitbake -c update_crates rutabaga-gfx-ffi' + +# from ffi/Cargo.lock +SRC_URI += " \ + crate://crates.io/anyhow/1.0.86 \ + crate://crates.io/autocfg/1.3.0 \ + crate://crates.io/bitflags/2.6.0 \ + crate://crates.io/byteorder/1.5.0 \ + crate://crates.io/cfg-if/1.0.0 \ + crate://crates.io/cfg_aliases/0.1.1 \ + crate://crates.io/libc/0.2.155 \ + crate://crates.io/log/0.4.22 \ + crate://crates.io/memoffset/0.9.1 \ + crate://crates.io/nix/0.28.0 \ + crate://crates.io/once_cell/1.19.0 \ + crate://crates.io/pkg-config/0.3.30 \ + crate://crates.io/proc-macro2/1.0.86 \ + crate://crates.io/quote/1.0.36 \ + crate://crates.io/remain/0.2.14 \ + crate://crates.io/syn/2.0.68 \ + crate://crates.io/thiserror/1.0.61 \ + crate://crates.io/thiserror-impl/1.0.61 \ + crate://crates.io/unicode-ident/1.0.12 \ + crate://crates.io/winapi/0.3.9 \ + crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \ + crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \ + crate://crates.io/zerocopy/0.7.34 \ + crate://crates.io/zerocopy-derive/0.7.34 \ +" + +SRC_URI[anyhow-1.0.86.sha256sum] = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +SRC_URI[autocfg-1.3.0.sha256sum] = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +SRC_URI[bitflags-2.6.0.sha256sum] = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +SRC_URI[byteorder-1.5.0.sha256sum] = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +SRC_URI[cfg-if-1.0.0.sha256sum] = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +SRC_URI[cfg_aliases-0.1.1.sha256sum] = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +SRC_URI[libc-0.2.155.sha256sum] = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +SRC_URI[log-0.4.22.sha256sum] = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +SRC_URI[memoffset-0.9.1.sha256sum] = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +SRC_URI[nix-0.28.0.sha256sum] = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +SRC_URI[once_cell-1.19.0.sha256sum] = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +SRC_URI[pkg-config-0.3.30.sha256sum] = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +SRC_URI[proc-macro2-1.0.86.sha256sum] = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +SRC_URI[quote-1.0.36.sha256sum] = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +SRC_URI[remain-0.2.14.sha256sum] = "46aef80f842736de545ada6ec65b81ee91504efd6853f4b96de7414c42ae7443" +SRC_URI[syn-2.0.68.sha256sum] = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +SRC_URI[thiserror-1.0.61.sha256sum] = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +SRC_URI[thiserror-impl-1.0.61.sha256sum] = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +SRC_URI[unicode-ident-1.0.12.sha256sum] = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +SRC_URI[winapi-0.3.9.sha256sum] = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +SRC_URI[winapi-i686-pc-windows-gnu-0.4.0.sha256sum] = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +SRC_URI[winapi-x86_64-pc-windows-gnu-0.4.0.sha256sum] = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +SRC_URI[zerocopy-0.7.34.sha256sum] = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +SRC_URI[zerocopy-derive-0.7.34.sha256sum] = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" diff --git a/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi_0.1.3.bb b/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi_0.1.3.bb new file mode 100644 index 0000000..5dbd585 --- /dev/null +++ b/meta-linaro/recipes-graphics/rutabaga_gfx_ffi/rutabaga-gfx-ffi_0.1.3.bb @@ -0,0 +1,65 @@ +SUMMARY = "rutabaga_ffi" +DESCRIPTION = "Handling virtio-gpu protocols with C API" +HOMEPAGE = "https://github.com/google/crosvm/tree/main/rutabaga_gfx" + +LICENSE = "BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=03dbda889fc4ff3d6d2981a1504ea88b" + +inherit cargo +inherit cargo-update-recipe-crates +inherit pkgconfig + +DEPENDS += "gfxstream" + +S = "${WORKDIR}/git" +SRC_URI[rutabaga_gfx_ffi.sha256sum] = "ac16079a0ca9c54ef44bd6333491f987b73081e82ce453c3206e127539cd3f24" +EXTRA_OECARGO_PATHS += "${WORKDIR}/rutabaga_gfx_0.1.3" + +SRCREV_rutabaga_gfx_ffi = "${AUTOREV}" +SRC_URI += "crate://crates.io/api/v1/crates/rutabaga_gfx_ffi/0.1.3;name=rutabaga-gfx-ffi-0.1.3" +SRC_URI += "file://0001-rutabaga-gfx-ffi-Use-env-variable-to-pass-in-RUTABAG.patch" + +require rutabaga-gfx-ffi-crates.inc + +# pass to rutabaga's build.rs script to host *.pc file. +export RUTABAGA_OUT_DIR="${B}/target/${BUILD_DIR}" +CARGO_BUILD_FLAGS += "--features=gfxstream" + +INHIBIT_PACKAGE_STRIP = "1" +DEBUG_BUILD = "1" + +CARGO_SRC_DIR = "ffi" + +# rutabaga has no Cargo.lock file, so we need to generate one to make the rest of the tooling happy... +# Note: +# 1. rutabaga 0.1.3 crate need to be patched to sync with upstream using Cargo.toml [patch.crates-io] +# 2. However, OE doesn't allow network access except for do_fetch stage. Therefore, this step will fail +# in any case when any crate dependancies are overriden. +# 3. Therefore, we workaround by generating cargo.lock file offline via $bitbake -c devshell +# +do_configure:append() { + "${CARGO}" generate-lockfile --offline --manifest-path=${MANIFEST_PATH} +} + +LIB_NAME = "librutabaga_gfx_ffi.so" +prefix ?= "/usr/local" +libdir = "${prefix}/lib" +includedir = "${prefix}/include/rutabaga_gfx" +SRC ?= "${S}/${CARGO_SRC_DIR}/src" +RUTABAGA_VERSION_MAJOR = "0" + +do_install() { + install -d ${D}${includedir} + install -d ${D}${libdir}/pkgconfig + + install -m755 ${B}/target/${CARGO_TARGET_SUBDIR}/deps/${LIB_NAME} ${D}${libdir}/ + mv ${D}${libdir}/${LIB_NAME} ${D}${libdir}/${LIB_NAME}.${PV} + + ln -sf ${LIB_NAME}.${PV} ${D}${libdir}/${LIB_NAME}.${RUTABAGA_VERSION_MAJOR} + ln -sf ${LIB_NAME}.${PV} ${D}${libdir}/${LIB_NAME} + + install -m644 ${RUTABAGA_OUT_DIR}/rutabaga_gfx_ffi.pc ${D}${libdir}/pkgconfig/ + install -m644 ${SRC}/include/rutabaga_gfx_ffi.h ${D}${includedir}/ +} + +BBCLASSEXTEND = "nativesdk"