Makefile 1.7 KB

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