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