xref: /DragonOS/user/apps/user-manage/Makefile (revision c635d8a9cfe25bc11779f323ef0c7d7a0f597d4a)
1# The toolchain we use.
2# You can get it by running DragonOS' `tools/bootstrap.sh`
3TOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu"
4RUSTFLAGS+=""
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	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force