Makefile 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # 导入环境变量
  2. include ./env.mk
  3. # export ARCH ?= x86_64
  4. # 如果是x86_64, 则使用x86_64-unknown-none.json作为target
  5. ifeq ($(ARCH), x86_64)
  6. export TARGET_JSON=arch/x86_64/x86_64-unknown-none.json
  7. else ifeq ($(ARCH), riscv64)
  8. export TARGET_JSON=arch/riscv64/riscv64gc-unknown-none-elf.json
  9. endif
  10. export CARGO_ZBUILD=-Z build-std=core,alloc,compiler_builtins -Z build-std-features=compiler-builtins-mem
  11. .PHONY: ECHO
  12. ECHO:
  13. @echo "$@"
  14. all:
  15. $(MAKE) -C src all ARCH=$(ARCH) || (sh -c "echo 内核编译失败" && exit 1)
  16. clean:
  17. rm -f Cargo.lock
  18. $(MAKE) -C src clean ARCH=$(ARCH)
  19. .PHONY: fmt
  20. fmt:
  21. RUSTFLAGS="$(RUSTFLAGS)" cargo fmt --all $(FMT_CHECK)
  22. ifeq ($(ARCH), x86_64)
  23. RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 clippy --all-features
  24. endif
  25. .PHONY: check
  26. check: ECHO
  27. $(MAKE) -C src check ARCH=$(ARCH)
  28. test:
  29. # 测试内核库
  30. RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --workspace --exclude dragonos_kernel rbpf
  31. test-rbpf:
  32. cd crates/rbpf && RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --features=std,user,cranelift