Makefile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # The toolchain we use.
  2. # You can get it by running DragonOS' `tools/bootstrap.sh`
  3. TOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
  4. ifeq ($(ARCH), riscv64)
  5. RUSTFLAGS+="-C target-feature=+crt-static"
  6. endif
  7. ifdef DADK_CURRENT_BUILD_DIR
  8. # 如果是在dadk中编译,那么安装到dadk的安装目录中
  9. INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
  10. else
  11. # 如果是在本地编译,那么安装到当前目录下的install目录中
  12. INSTALL_DIR = ./install
  13. endif
  14. ifeq ($(ARCH), x86_64)
  15. export RUST_TARGET=x86_64-unknown-linux-musl
  16. else ifeq ($(ARCH), riscv64)
  17. export RUST_TARGET=riscv64gc-unknown-linux-musl
  18. else
  19. # 默认为x86_64,用于本地编译
  20. export RUST_TARGET=x86_64-unknown-linux-musl
  21. endif
  22. build:
  23. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
  24. run-dragonreach:
  25. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --bin DragonReach
  26. clean:
  27. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean
  28. build-release:
  29. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
  30. clean-release:
  31. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
  32. fmt:
  33. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
  34. fmt-check:
  35. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
  36. .PHONY: install
  37. install:
  38. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force