1# 导入环境变量 2include ../env.mk 3 4export ARCH ?= x86_64 5# 如果是x86_64, 则使用x86_64-unknown-none.json作为target 6ifeq ($(ARCH), x86_64) 7 export TARGET_JSON=arch/x86_64/x86_64-unknown-none.json 8else ifeq ($(ARCH), riscv64) 9 export TARGET_JSON=arch/riscv64/riscv64imac-unknown-none-elf.json 10endif 11 12export CARGO_ZBUILD=-Z build-std=core,alloc,compiler_builtins -Z build-std-features=compiler-builtins-mem 13 14.PHONY: ECHO 15ECHO: 16 @echo "$@" 17 18all: 19 @if [ -z $$DragonOS_GCC ]; then echo "\033[31m [错误]尚未安装DragonOS交叉编译器, 请使用tools文件夹下的build_gcc_toolchain.sh脚本安装 \033[0m"; exit 1; fi 20 $(MAKE) -C src all ARCH=$(ARCH) || (sh -c "echo 内核编译失败" && exit 1) 21 22 23clean: 24 rm -f Cargo.lock 25 $(MAKE) -C src clean ARCH=$(ARCH) 26 27.PHONY: fmt 28fmt: 29 cargo fmt --all $(FMT_CHECK) 30 31.PHONY: check 32check: ECHO 33# @echo "Checking kernel... ARCH=$(ARCH)" 34# @exit 1 35ifeq ($(ARCH), x86_64) 36 @cargo +nightly-2023-08-15 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON) 37else ifeq ($(ARCH), riscv64) 38 @cargo +nightly-2023-08-15 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON) 39endif 40 41test: 42# 测试内核库 43 @cargo +nightly-2023-08-15 test --workspace --exclude dragonos_kernel 44 45