1*bd70d2d1SLoGinTOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu" 252da9a59SGnoCiYeH# RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie" 352da9a59SGnoCiYeH 452da9a59SGnoCiYeHifdef DADK_CURRENT_BUILD_DIR 552da9a59SGnoCiYeH# 如果是在dadk中编译,那么安装到dadk的安装目录中 652da9a59SGnoCiYeH INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR) 752da9a59SGnoCiYeHelse 852da9a59SGnoCiYeH# 如果是在本地编译,那么安装到当前目录下的install目录中 952da9a59SGnoCiYeH INSTALL_DIR = ./install 1052da9a59SGnoCiYeHendif 1152da9a59SGnoCiYeH 1252da9a59SGnoCiYeHifeq ($(ARCH), x86_64) 1352da9a59SGnoCiYeH export RUST_TARGET=x86_64-unknown-linux-musl 1452da9a59SGnoCiYeHelse ifeq ($(ARCH), riscv64) 1552da9a59SGnoCiYeH export RUST_TARGET=riscv64gc-unknown-linux-gnu 1652da9a59SGnoCiYeHelse 1752da9a59SGnoCiYeH# 默认为x86_86,用于本地编译 1852da9a59SGnoCiYeH export RUST_TARGET=x86_64-unknown-linux-musl 1952da9a59SGnoCiYeHendif 2052da9a59SGnoCiYeH 2152da9a59SGnoCiYeHrun: 2252da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) 2352da9a59SGnoCiYeH 2452da9a59SGnoCiYeHbuild: 2552da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) 2652da9a59SGnoCiYeH 2752da9a59SGnoCiYeHclean: 2852da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) 2952da9a59SGnoCiYeH 3052da9a59SGnoCiYeHtest: 3152da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) 3252da9a59SGnoCiYeH 3352da9a59SGnoCiYeHdoc: 3452da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET) 3552da9a59SGnoCiYeH 3652da9a59SGnoCiYeHfmt: 3752da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt 3852da9a59SGnoCiYeH 3952da9a59SGnoCiYeHfmt-check: 4052da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check 4152da9a59SGnoCiYeH 4252da9a59SGnoCiYeHrun-release: 4352da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release 4452da9a59SGnoCiYeH 4552da9a59SGnoCiYeHbuild-release: 4652da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release 4752da9a59SGnoCiYeH 4852da9a59SGnoCiYeHclean-release: 4952da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release 5052da9a59SGnoCiYeH 5152da9a59SGnoCiYeHtest-release: 5252da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release 5352da9a59SGnoCiYeH 5452da9a59SGnoCiYeH.PHONY: install 5552da9a59SGnoCiYeHinstall: 5652da9a59SGnoCiYeH RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force 57