Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu"
  2. # RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
  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. else ifeq ($(ARCH), riscv64)
  13. export RUST_TARGET=riscv64gc-unknown-linux-gnu
  14. else
  15. # 默认为x86_86,用于本地编译
  16. export RUST_TARGET=x86_64-unknown-linux-musl
  17. endif
  18. run:
  19. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET)
  20. build-linux:
  21. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
  22. build-dragonos:
  23. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --features dragonos
  24. clean:
  25. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET)
  26. test:
  27. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET)
  28. doc:
  29. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET)
  30. fmt:
  31. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
  32. fmt-check:
  33. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
  34. run-release:
  35. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release
  36. build-release:
  37. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
  38. clean-release:
  39. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
  40. test-release:
  41. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release
  42. .PHONY: install-dragonos
  43. install-dragonos:
  44. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --features dragonos --path . --no-track --root $(INSTALL_DIR) --force
  45. install-linux:
  46. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force