1*7c28051eSlinfengTOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu" 2b4eb05a1STTaq# RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie" 3b4eb05a1STTaq 4b4eb05a1STTaqifdef DADK_CURRENT_BUILD_DIR 5b4eb05a1STTaq# 如果是在dadk中编译,那么安装到dadk的安装目录中 6b4eb05a1STTaq INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR) 7b4eb05a1STTaqelse 8b4eb05a1STTaq# 如果是在本地编译,那么安装到当前目录下的install目录中 9b4eb05a1STTaq INSTALL_DIR = ./install 10b4eb05a1STTaqendif 11b4eb05a1STTaq 12b4eb05a1STTaqifeq ($(ARCH), x86_64) 13b4eb05a1STTaq export RUST_TARGET=x86_64-unknown-linux-musl 14b4eb05a1STTaqelse ifeq ($(ARCH), riscv64) 15b4eb05a1STTaq export RUST_TARGET=riscv64gc-unknown-linux-gnu 16b4eb05a1STTaqelse 17b4eb05a1STTaq# 默认为x86_86,用于本地编译 18b4eb05a1STTaq export RUST_TARGET=x86_64-unknown-linux-musl 19b4eb05a1STTaqendif 20b4eb05a1STTaq 21b4eb05a1STTaqrun: 22b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) 23b4eb05a1STTaq 24b4eb05a1STTaqbuild: 25b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) 26b4eb05a1STTaq 27b4eb05a1STTaqclean: 28b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) 29b4eb05a1STTaq 30b4eb05a1STTaqtest: 31b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) 32b4eb05a1STTaq 33b4eb05a1STTaqdoc: 34b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET) 35b4eb05a1STTaq 36b4eb05a1STTaqfmt: 37b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt 38b4eb05a1STTaq 39b4eb05a1STTaqfmt-check: 40b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check 41b4eb05a1STTaq 42b4eb05a1STTaqrun-release: 43b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release 44b4eb05a1STTaq 45b4eb05a1STTaqbuild-release: 46b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release 47b4eb05a1STTaq 48b4eb05a1STTaqclean-release: 49b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release 50b4eb05a1STTaq 51b4eb05a1STTaqtest-release: 52b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release 53b4eb05a1STTaq 54b4eb05a1STTaq.PHONY: install 55b4eb05a1STTaqinstall: 56b4eb05a1STTaq RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force 57