xref: /DragonOS/kernel/Makefile (revision 5c4224e5a8244cb0fb32512e70354362fccd6321)
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	$(MAKE) -C src all ARCH=$(ARCH) || (sh -c "echo 内核编译失败" && exit 1)
20
21
22clean:
23	rm -f Cargo.lock
24	$(MAKE) -C src clean ARCH=$(ARCH)
25
26.PHONY: fmt
27fmt:
28	cargo fmt --all $(FMT_CHECK)
29
30.PHONY: check
31check: ECHO
32# @echo "Checking kernel... ARCH=$(ARCH)"
33# @exit 1
34ifeq ($(ARCH), x86_64)
35	@cargo +nightly-2023-08-15 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
36else ifeq ($(ARCH), riscv64)
37	@cargo +nightly-2023-08-15 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
38endif
39
40test:
41# 测试内核库
42	@cargo +nightly-2023-08-15 test --workspace --exclude dragonos_kernel
43
44