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