Makefile 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. sed -i '/^[[:space:]]*$$/d' ./src/include/bindings/bindings.rs
  22. RUSTFLAGS="$(RUSTFLAGS)" cargo fmt --all $(FMT_CHECK)
  23. ifeq ($(ARCH), x86_64)
  24. RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 clippy --all-features
  25. endif
  26. .PHONY: check
  27. check: ECHO
  28. $(MAKE) -C src check ARCH=$(ARCH)
  29. test:
  30. # 测试内核库
  31. RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --workspace --exclude dragonos_kernel rbpf
  32. test-rbpf:
  33. cd crates/rbpf && RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --features=std,user,cranelift