Makefile 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ifdef DADK_CURRENT_BUILD_DIR
  2. # 如果是在dadk中编译,那么安装到dadk的安装目录中
  3. INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
  4. else
  5. # 如果是在本地编译,那么安装到当前目录下的install目录中
  6. INSTALL_DIR = ./install
  7. endif
  8. ifeq ($(ARCH), x86_64)
  9. export RUST_TARGET=x86_64-unknown-linux-musl
  10. else ifeq ($(ARCH), riscv64)
  11. export RUST_TARGET=riscv64gc-unknown-linux-gnu
  12. else
  13. # 默认为x86_86,用于本地编译
  14. export RUST_TARGET=x86_64-unknown-linux-musl
  15. endif
  16. run:
  17. cargo run --target $(RUST_TARGET)
  18. build:
  19. cargo build --target $(RUST_TARGET)
  20. clean:
  21. cargo clean --target $(RUST_TARGET)
  22. test:
  23. cargo test --target $(RUST_TARGET)
  24. doc:
  25. cargo doc --target $(RUST_TARGET)
  26. fmt:
  27. cargo fmt
  28. fmt-check:
  29. cargo fmt --check
  30. run-release:
  31. cargo run --target $(RUST_TARGET) --release
  32. build-release:
  33. cargo build --target $(RUST_TARGET) --release
  34. clean-release:
  35. cargo clean --target $(RUST_TARGET) --release
  36. test-release:
  37. cargo test --target $(RUST_TARGET) --release
  38. .PHONY: install
  39. install:
  40. cargo install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force