Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. RUSTFLAGS+=""
  5. ifdef DADK_CURRENT_BUILD_DIR
  6. # 如果是在dadk中编译,那么安装到dadk的安装目录中
  7. INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
  8. else
  9. # 如果是在本地编译,那么安装到当前目录下的install目录中
  10. INSTALL_DIR = ./install
  11. endif
  12. ifeq ($(ARCH), x86_64)
  13. export RUST_TARGET=x86_64-unknown-linux-musl
  14. else ifeq ($(ARCH), riscv64)
  15. export RUST_TARGET=riscv64gc-unknown-linux-gnu
  16. else
  17. # 默认为x86_86,用于本地编译
  18. export RUST_TARGET=x86_64-unknown-linux-musl
  19. endif
  20. build:
  21. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
  22. run-dragonreach:
  23. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --bin DragonReach
  24. clean:
  25. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean
  26. build-release:
  27. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
  28. clean-release:
  29. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
  30. fmt:
  31. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
  32. fmt-check:
  33. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
  34. .PHONY: install
  35. install:
  36. mkdir -p $(INSTALL_DIR)/etc/reach/system
  37. mkdir -p $(INSTALL_DIR)/etc/reach/ipc
  38. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force