xref: /DragonOS/user/apps/test-backlog/Makefile (revision d031d46fd9e9a62e8e975dba76e3bdef027f63b6)
1TOOLCHAIN="+nightly-2024-07-23-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
14	export CC=x86_64-linux-musl-gcc
15else ifeq ($(ARCH), riscv64)
16	export RUST_TARGET=riscv64gc-unknown-linux-gnu
17else
18# 默认为x86_86,用于本地编译
19	export RUST_TARGET=x86_64-unknown-linux-musl
20endif
21
22run:
23	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --features"rust-tls"
24
25build:
26	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --features"rust-tls"
27
28clean:
29	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET)
30
31test:
32	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET)
33
34doc:
35	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET)
36
37fmt:
38	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
39
40fmt-check:
41	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
42
43run-release:
44	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release
45
46build-release:
47	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
48
49clean-release:
50	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
51
52test-release:
53	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release
54
55.PHONY: install
56install:
57	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force