1# The toolchain we use. 2# You can get it by running DragonOS' `tools/bootstrap.sh` 3TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu" 4RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie" 5 6ifdef DADK_CURRENT_BUILD_DIR 7# 如果是在dadk中编译,那么安装到dadk的安装目录中 8 INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR) 9else 10# 如果是在本地编译,那么安装到当前目录下的install目录中 11 INSTALL_DIR = ./install 12endif 13 14 15ifeq ($(ARCH), x86_64) 16 export RUST_TARGET=x86_64-unknown-linux-musl 17else ifeq ($(ARCH), riscv64) 18 export RUST_TARGET=riscv64gc-unknown-linux-gnu 19else 20# 默认为x86_86,用于本地编译 21 export RUST_TARGET=x86_64-unknown-linux-musl 22endif 23 24build: 25 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) 26 27run-dragonreach: 28 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --bin DragonReach 29 30clean: 31 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean 32 33build-release: 34 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release 35 36clean-release: 37 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release 38 39fmt: 40 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt 41 42fmt-check: 43 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check 44 45.PHONY: install 46install: 47 mkdir -p $(INSTALL_DIR)/etc/reach/system 48 mkdir -p $(INSTALL_DIR)/etc/reach/ipc 49 cp ./parse_test/shell.service $(INSTALL_DIR)/etc/reach/system/shell.service 50 RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force