1*1c11e7deSyuyi2439TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu" 2*1c11e7deSyuyi2439RUSTFLAGS+="" 345e17157SR0ronoa 4*1c11e7deSyuyi2439ifdef DADK_CURRENT_BUILD_DIR 545e17157SR0ronoa# 如果是在dadk中编译,那么安装到dadk的安装目录中 6*1c11e7deSyuyi2439 INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR) 7*1c11e7deSyuyi2439else 845e17157SR0ronoa# 如果是在本地编译,那么安装到当前目录下的install目录中 9*1c11e7deSyuyi2439 INSTALL_DIR = ./install 10*1c11e7deSyuyi2439endif 1145e17157SR0ronoa 12*1c11e7deSyuyi2439ifeq ($(ARCH), x86_64) 13*1c11e7deSyuyi2439 export RUST_TARGET=x86_64-unknown-linux-musl 14*1c11e7deSyuyi2439else ifeq ($(ARCH), riscv64) 15*1c11e7deSyuyi2439 export RUST_TARGET=riscv64gc-unknown-linux-gnu 16*1c11e7deSyuyi2439else 17*1c11e7deSyuyi2439# 默认为x86_86,用于本地编译 18*1c11e7deSyuyi2439 export RUST_TARGET=x86_64-unknown-linux-musl 19*1c11e7deSyuyi2439endif 2045e17157SR0ronoa 2145e17157SR0ronoarun: 22*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) 2345e17157SR0ronoa 2445e17157SR0ronoabuild: 25*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) 2645e17157SR0ronoa 2745e17157SR0ronoaclean: 28*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) 2945e17157SR0ronoa 3045e17157SR0ronoatest: 31*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) 3245e17157SR0ronoa 3345e17157SR0ronoadoc: 34*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET) 35*1c11e7deSyuyi2439 36*1c11e7deSyuyi2439fmt: 37*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt 38*1c11e7deSyuyi2439 39*1c11e7deSyuyi2439fmt-check: 40*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check 4145e17157SR0ronoa 4245e17157SR0ronoarun-release: 43*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release 4445e17157SR0ronoa 4545e17157SR0ronoabuild-release: 46*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release 4745e17157SR0ronoa 4845e17157SR0ronoaclean-release: 49*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release 5045e17157SR0ronoa 5145e17157SR0ronoatest-release: 52*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release 5345e17157SR0ronoa 5445e17157SR0ronoa.PHONY: install 5545e17157SR0ronoainstall: 56*1c11e7deSyuyi2439 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force 57