mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-22 09:26:26 +04:00
buildtools: feat #135: Check the version of QEMU ahead
This commit is contained in:
parent
12416cc8ce
commit
adb9672f18
13
os/Makefile
13
os/Makefile
@ -74,20 +74,23 @@ QEMU_ARGS := -machine virt \
|
|||||||
-drive file=$(FS_IMG),if=none,format=raw,id=x0 \
|
-drive file=$(FS_IMG),if=none,format=raw,id=x0 \
|
||||||
-device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
|
-device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
|
||||||
|
|
||||||
run-inner: build
|
QEMU_NAME := qemu-system-riscv64
|
||||||
|
qemu-version-check:
|
||||||
|
@sh scripts/qemu-ver-check.sh $(QEMU_NAME)
|
||||||
|
|
||||||
|
run-inner: qemu-version-check build
|
||||||
@qemu-system-riscv64 $(QEMU_ARGS)
|
@qemu-system-riscv64 $(QEMU_ARGS)
|
||||||
|
|
||||||
debug: build
|
debug: qemu-version-check build
|
||||||
@tmux new-session -d \
|
@tmux new-session -d \
|
||||||
"qemu-system-riscv64 $(QEMU_ARGS) -s -S" && \
|
"qemu-system-riscv64 $(QEMU_ARGS) -s -S" && \
|
||||||
tmux split-window -h "riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'" && \
|
tmux split-window -h "riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'" && \
|
||||||
tmux -2 attach-session -d
|
tmux -2 attach-session -d
|
||||||
|
|
||||||
|
gdbserver: qemu-version-check build
|
||||||
gdbserver: build
|
|
||||||
@qemu-system-riscv64 $(QEMU_ARGS) -s -S
|
@qemu-system-riscv64 $(QEMU_ARGS) -s -S
|
||||||
|
|
||||||
gdbclient:
|
gdbclient:
|
||||||
@riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'
|
@riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'
|
||||||
|
|
||||||
.PHONY: build env kernel clean disasm disasm-vim run-inner fs-img gdbserver gdbclient
|
.PHONY: build env kernel clean disasm disasm-vim run-inner fs-img gdbserver gdbclient qemu-version-check
|
||||||
|
26
os/scripts/qemu-ver-check.sh
Normal file
26
os/scripts/qemu-ver-check.sh
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Argument1: The filename of qemu executable, e.g. qemu-system-riscv64
|
||||||
|
QEMU_PATH=$(which $1)
|
||||||
|
RET=$?
|
||||||
|
MINIMUM_MAJOR_VERSION=7
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
NC='\033[0m'
|
||||||
|
if [ $RET != 0 ]
|
||||||
|
then
|
||||||
|
echo "$1 not found"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
QEMU_VERSION=$($1 --version|head -n 1|awk '{print $4}')
|
||||||
|
MAJOR_VERSION=$(echo $QEMU_VERSION|cut -c1-1)
|
||||||
|
if [ $MAJOR_VERSION -lt $MINIMUM_MAJOR_VERSION ]
|
||||||
|
then
|
||||||
|
echo "${RED}Error: Required major version of QEMU is ${MINIMUM_MAJOR_VERSION}, " \
|
||||||
|
"but current is ${QEMU_VERSION}.${NC}"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "${GREEN}QEMU version is ${QEMU_VERSION}(>=${MINIMUM_MAJOR_VERSION}), OK!${NC}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user