xref: /DragonOS/user/apps/test-for-robustfutex/Makefile (revision 2eab6dd743e94a86a685f1f3c01e599adf86610a)
1TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu"
2RUSTFLAGS+=""
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:
25	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
26
27clean:
28	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET)
29
30test:
31	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET)
32
33doc:
34	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET)
35
36fmt:
37	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
38
39fmt-check:
40	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
41
42run-release:
43	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release
44
45build-release:
46	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
47
48clean-release:
49	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
50
51test-release:
52	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release
53
54.PHONY: install
55install:
56	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force
57