From 5445155dba87b0529c3f1b206015e12f6f3a5e06 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 4 Aug 2021 01:04:08 +0200 Subject: [PATCH] Meta: Auto-detect where QEMU is installed on Windows --- Documentation/BuildInstructionsWindows.md | 6 ------ Meta/run.sh | 14 +++++++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Documentation/BuildInstructionsWindows.md b/Documentation/BuildInstructionsWindows.md index 13103204d48..45e74fad32c 100644 --- a/Documentation/BuildInstructionsWindows.md +++ b/Documentation/BuildInstructionsWindows.md @@ -34,12 +34,6 @@ will need to install the tools as well as the system emulators for i386 and x86_ ![QEMU Components](QEMU_Components.png) -Locate the `qemu-system-x86_64.exe` executable in WSL. -By default this will be at `/mnt/c/Program Files/qemu/qemu-system-x86_64.exe`. - -Set the `SERENITY_QEMU_BIN` environment variable to that location. For example: \ -`export SERENITY_QEMU_BIN='/mnt/c/Program Files/qemu/qemu-system-x86_64.exe'` - Run `Meta/serenity.sh run` to build and run SerenityOS as usual. ### Hardware acceleration diff --git a/Meta/run.sh b/Meta/run.sh index 1ce2183bbec..a2ba475a35f 100755 --- a/Meta/run.sh +++ b/Meta/run.sh @@ -38,13 +38,21 @@ PATH="$SCRIPT_DIR/../Toolchain/Local/i686/bin:$PATH" SERENITY_RUN="${SERENITY_RUN:-$1}" if [ -z "$SERENITY_QEMU_BIN" ]; then - if command -v qemu-system-x86_64 >/dev/null; then - SERENITY_QEMU_BIN="qemu-system-x86_64" + if command -v wslpath >/dev/null; then + QEMU_INSTALL_DIR=$(reg.exe query 'HKLM\Software\QEMU' /v Install_Dir /t REG_SZ | grep '^ Install_Dir' | sed 's/ / /g' | cut -f4- -d' ') + if [ -z "$QEMU_INSTALL_DIR" ]; then + die "Could not determine where QEMU for Windows is installed. Please make sure QEMU is installed or set SERENITY_QEMU_BIN if it is already installed." + fi + QEMU_BINARY_PREFIX="$(wslpath -- "${QEMU_INSTALL_DIR}" | tr -d '\r\n')/" + QEMU_BINARY_SUFFIX=".exe" + fi + if command -v "${QEMU_BINARY_PREFIX}qemu-system-x86_64${QEMU_BINARY_SUFFIX}" >/dev/null; then + SERENITY_QEMU_BIN="${QEMU_BINARY_PREFIX}qemu-system-x86_64${QEMU_BINARY_SUFFIX}" else if [ "$SERENITY_ARCH" = "x86_64" ]; then die "Please install the 64-bit QEMU system emulator (qemu-system-x86_64)." fi - SERENITY_QEMU_BIN="qemu-system-i386" + SERENITY_QEMU_BIN="${QEMU_BINARY_PREFIX}qemu-system-i386${QEMU_BINARY_SUFFIX}" fi fi