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