Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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=riscv64gc-unknown-none-elf
  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 clippy --all-features
  24. endif
  25. .PHONY: check
  26. check: ECHO
  27. # @echo "Checking kernel... ARCH=$(ARCH)"
  28. # @exit 1
  29. ifeq ($(ARCH), x86_64)
  30. RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
  31. else ifeq ($(ARCH), riscv64)
  32. RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json --target $(TARGET_JSON)
  33. endif
  34. test:
  35. # 测试内核库
  36. RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --workspace --exclude dragonos_kernel rbpf
  37. test-rbpf:
  38. cd crates/rbpf && RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --features=std,user,cranelift