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