From 40a527bb235f4dbca82cc1b501ffa35be6cd0010 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Mon, 26 Sep 2022 20:59:46 -0400 Subject: [PATCH] Bundle QEMU --- .gitmodules | 4 ++++ dependencies/CMakeLists.txt | 4 ++++ dependencies/qemu/CMakeLists.txt | 33 ++++++++++++++++++++++++++ dependencies/qemu/src | 1 + docs/INSTALL.md | 3 --- libreborn/src/util/exec.c | 3 --- media-layer/core/dependencies/glfw/src | 2 +- 7 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 dependencies/qemu/CMakeLists.txt create mode 160000 dependencies/qemu/src diff --git a/.gitmodules b/.gitmodules index 75ff9ad6b..0d6b906fa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,3 +14,7 @@ [submodule "dependencies/LIEF/src"] path = dependencies/LIEF/src url = https://github.com/lief-project/LIEF.git +[submodule "dependencies/qemu/src"] + path = dependencies/qemu/src + url = https://gitlab.com/qemu-project/qemu.git + ignore = dirty diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index f975e7382..69db2ce55 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -16,3 +16,7 @@ endif() if(BUILD_NATIVE_COMPONENTS OR (BUILD_ARM_COMPONENTS AND NOT MCPI_SERVER_MODE AND NOT MCPI_USE_MEDIA_LAYER_PROXY)) add_subdirectory(LIEF) endif() +# QEMU +if(BUILD_NATIVE_COMPONENTS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")) + add_subdirectory(qemu) +endif() diff --git a/dependencies/qemu/CMakeLists.txt b/dependencies/qemu/CMakeLists.txt new file mode 100644 index 000000000..f0772dc20 --- /dev/null +++ b/dependencies/qemu/CMakeLists.txt @@ -0,0 +1,33 @@ +project(qemu) + +## QEMU + +# Build +include(ProcessorCount) +ProcessorCount(NPROC) +include(ExternalProject) +ExternalProject_Add(qemu + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src" + CONFIGURE_COMMAND + "${CMAKE_COMMAND}" "-E" "env" "PKG_CONFIG_LIBDIR=$ENV{PKG_CONFIG_LIBDIR}" + "/configure" + "--prefix=${CMAKE_INSTALL_PREFIX}" + "--cross-prefix=" + "--cc=${CMAKE_C_COMPILER}" + "--cxx=${CMAKE_CXX_COMPILER}" + "--target-list=arm-linux-user" + "--without-default-features" + USES_TERMINAL_CONFIGURE TRUE + BUILD_COMMAND "make" "-j${NPROC}" "qemu-arm" + USES_TERMINAL_BUILD TRUE + INSTALL_COMMAND "" + TEST_COMMAND "" + BUILD_BYPRODUCTS "/qemu-arm" +) + +# Install +ExternalProject_Get_property(qemu BINARY_DIR) +install(PROGRAMS "${BINARY_DIR}/qemu-arm" DESTINATION "${MCPI_BIN_DIR}") + +# License +install(FILES src/COPYING DESTINATION "${MCPI_LEGAL_DIR}/qemu") diff --git a/dependencies/qemu/src b/dependencies/qemu/src new file mode 160000 index 000000000..621da7789 --- /dev/null +++ b/dependencies/qemu/src @@ -0,0 +1 @@ +Subproject commit 621da7789083b80d6f1ff1c0fb499334007b4f51 diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 49e68c7f7..5f49bfc17 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -5,9 +5,6 @@ Download packages [here](https://jenkins.thebrokenrail.com/job/minecraft-pi-rebo ### System Requirements * Debian Buster/Ubuntu 18.04 Or Higher -* QEMU User-Mode - * Debian/Ubuntu: ``sudo apt install qemu-user`` - * Arch: ``sudo pacman -S qemu-user`` * Client-Only Dependencies * Graphics Drivers * GTK+ 3 diff --git a/libreborn/src/util/exec.c b/libreborn/src/util/exec.c index 95b97bea5..9e34717a4 100644 --- a/libreborn/src/util/exec.c +++ b/libreborn/src/util/exec.c @@ -37,9 +37,6 @@ __attribute__((noreturn)) void safe_execvpe(const char *const argv[], const char // Run int ret = execvpe(argv[0], (char *const *) argv, (char *const *) envp); if (ret == -1) { - if (errno == ENOENT && strcmp(argv[0], "qemu-qrm")) { - ERR("Unable to find QEMU! To install on Ubuntu/Debian, run \"sudo apt install qemu-user\". To install on Arch Linux, run \"sudo pacman -S qemu-user\"."); - } ERR("Unable To Execute Program: %s: %s", argv[0], strerror(errno)); } else { IMPOSSIBLE(); diff --git a/media-layer/core/dependencies/glfw/src b/media-layer/core/dependencies/glfw/src index c18851f52..dd8a678a6 160000 --- a/media-layer/core/dependencies/glfw/src +++ b/media-layer/core/dependencies/glfw/src @@ -1 +1 @@ -Subproject commit c18851f52ec9704eb06464058a600845ec1eada1 +Subproject commit dd8a678a66f1967372e5a5e3deac41ebf65ee127