1# TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu" 2# RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie" 3 4ifdef DADK_CURRENT_BUILD_DIR 5# 如果是在dadk中编译,那么安装到dadk的安装目录中 6 INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR) 7else 8# 如果是在本地编译,那么安装到当前目录下的install目录中 9 INSTALL_DIR = ./install 10endif 11 12ifeq ($(ARCH), x86_64) 13 export RUST_TARGET=x86_64-unknown-linux-musl 14else ifeq ($(ARCH), riscv64) 15 export RUST_TARGET=riscv64gc-unknown-linux-gnu 16else 17# 默认为x86_86,用于本地编译 18 export RUST_TARGET=x86_64-unknown-linux-musl 19endif 20 21run: 22 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) 23 24build-linux: 25 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) 26 27build-dragonos: 28 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --features dragonos 29 30clean: 31 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) 32 33test: 34 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) 35 36doc: 37 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET) 38 39fmt: 40 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt 41 42fmt-check: 43 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check 44 45run-release: 46 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release 47 48build-release: 49 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release 50 51clean-release: 52 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release 53 54test-release: 55 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release 56 57.PHONY: install-dragonos 58install-dragonos: 59 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --features dragonos --path . --no-track --root $(INSTALL_DIR) --force 60 61install-linux: 62 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force 63