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