From 8621d8a155030be428b38c4ee7c30f1b43c536c2 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 27 Sep 2023 13:49:01 +0300 Subject: [PATCH] BuildSystem: Rework calling qemu I change always manually the serial/graphical. When running cmake you can define variable QEMU_ACCEL that will be used as accelerator. Also ninja has the following targets for running qemu 1. qemu: Run graphical qemu environment 2. qemu-nographic: Run qemu without graphical screen. You should select 'serial only' from grub menu. 3. qemu-debug: Run qemu without accelerator and interrupt debugger. --- CMakeLists.txt | 14 ++++++++++++-- PreLoad.cmake | 1 + README.md | 6 ++++-- qemu.sh | 1 - 4 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 PreLoad.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f178e01c5e..5da27514cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,10 @@ if(NOT EXISTS ${CMAKE_CXX_COMPILER}) set(CMAKE_CXX_COMPILER g++) endif() +if(DEFINED QEMU_ACCEL) + set(QEMU_ACCEL -accel ${QEMU_ACCEL}) +endif() + add_compile_options(-mno-sse -mno-sse2) add_compile_definitions(__enable_sse=0) @@ -90,13 +94,19 @@ add_custom_target(check-fs ) add_custom_target(qemu - COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/qemu.sh -accel kvm + COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/qemu.sh -serial stdio ${QEMU_ACCEL} + DEPENDS image + USES_TERMINAL +) + +add_custom_target(qemu-nographic + COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/qemu.sh -nographic ${QEMU_ACCEL} DEPENDS image USES_TERMINAL ) add_custom_target(qemu-debug - COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/qemu.sh -d int -no-reboot + COMMAND ${CMAKE_COMMAND} -E env BANAN_ARCH="${BANAN_ARCH}" DISK_IMAGE_PATH="${DISK_IMAGE_PATH}" ${CMAKE_SOURCE_DIR}/qemu.sh -serial stdio -d int -no-reboot DEPENDS image USES_TERMINAL ) diff --git a/PreLoad.cmake b/PreLoad.cmake new file mode 100644 index 0000000000..94a06cf828 --- /dev/null +++ b/PreLoad.cmake @@ -0,0 +1 @@ +set(CMAKE_GENERATOR "Ninja" CACHE INTERNAL "" FORCE) diff --git a/README.md b/README.md index e5da495fe2..438df7e372 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,20 @@ Each major component and library has its own subdirectory (kernel, userspace, li There does not exist a complete list of needed packages for building. From the top of my head I can say that *cmake*, *ninja*, *make*, *grub*, *rsync* and emulator (*qemu* or *bochs*) are needed. +You can and *should* pass cmake variable QEMU_ACCEL set to proper accelerator to cmake commands. For example on Linux this means adding -DQEMU_ACCEL=kvm to the end of all cmake commands. + Create the build directory and cofigure cmake ```sh mkdir build cd build -cmake -G Ninja .. +cmake .. ``` To build the toolchain for this os. You can run the following command. > ***NOTE:*** The following step has to be done only once. This might take a long time since we are compiling binutils and gcc. ```sh ninja toolchain -cmake -G Ninja --fresh .. # We need to reconfigure cmake to use the new compiler +cmake --fresh .. # We need to reconfigure cmake to use the new compiler ninja libstdc++ ``` diff --git a/qemu.sh b/qemu.sh index 17aa3791d7..00b38fba33 100755 --- a/qemu.sh +++ b/qemu.sh @@ -5,5 +5,4 @@ qemu-system-$BANAN_ARCH \ -m 128 \ -smp 2 \ -drive format=raw,media=disk,file=${DISK_IMAGE_PATH} \ - -serial stdio \ $@ \