Makefile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. 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:build-ebpf
  21. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
  22. clean:clean-ebpf
  23. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET)
  24. test:
  25. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET)
  26. doc:
  27. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET)
  28. fmt:
  29. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
  30. fmt-check:
  31. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
  32. run-release:
  33. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release
  34. build-release:build-ebpf
  35. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
  36. clean-release:clean-ebpf
  37. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
  38. test-release:
  39. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release
  40. build-ebpf:
  41. cd ./syscall_ebpf && RUST_LOG=debug cargo xtask build --release
  42. clean-ebpf:
  43. cd ./syscall_ebpf && cargo clean
  44. .PHONY: install
  45. install:build-ebpf
  46. RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force