xref: /DragonOS/user/apps/test-backlog/Makefile (revision bd70d2d1f490aabd570a5301b858bd5eb04149fa)
1*bd70d2d1SLoGinTOOLCHAIN="+nightly-2024-07-23-x86_64-unknown-linux-gnu"
2c719ddc6SSaga1718RUSTFLAGS+=""
3c719ddc6SSaga1718
4c719ddc6SSaga1718ifdef DADK_CURRENT_BUILD_DIR
5c719ddc6SSaga1718# 如果是在dadk中编译,那么安装到dadk的安装目录中
6c719ddc6SSaga1718	INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
7c719ddc6SSaga1718else
8c719ddc6SSaga1718# 如果是在本地编译,那么安装到当前目录下的install目录中
9c719ddc6SSaga1718	INSTALL_DIR = ./install
10c719ddc6SSaga1718endif
11c719ddc6SSaga1718
12c719ddc6SSaga1718ifeq ($(ARCH), x86_64)
13c719ddc6SSaga1718	export RUST_TARGET=x86_64-unknown-linux-musl
1470c991afSlaokengwt	export CC=x86_64-linux-musl-gcc
15c719ddc6SSaga1718else ifeq ($(ARCH), riscv64)
16c719ddc6SSaga1718	export RUST_TARGET=riscv64gc-unknown-linux-gnu
17c719ddc6SSaga1718else
18c719ddc6SSaga1718# 默认为x86_86,用于本地编译
19c719ddc6SSaga1718	export RUST_TARGET=x86_64-unknown-linux-musl
20c719ddc6SSaga1718endif
21c719ddc6SSaga1718
22c719ddc6SSaga1718run:
23c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --features"rust-tls"
24c719ddc6SSaga1718
25c719ddc6SSaga1718build:
26c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --features"rust-tls"
27c719ddc6SSaga1718
28c719ddc6SSaga1718clean:
29c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET)
30c719ddc6SSaga1718
31c719ddc6SSaga1718test:
32c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET)
33c719ddc6SSaga1718
34c719ddc6SSaga1718doc:
35c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET)
36c719ddc6SSaga1718
37c719ddc6SSaga1718fmt:
38c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
39c719ddc6SSaga1718
40c719ddc6SSaga1718fmt-check:
41c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
42c719ddc6SSaga1718
43c719ddc6SSaga1718run-release:
44c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release
45c719ddc6SSaga1718
46c719ddc6SSaga1718build-release:
47c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
48c719ddc6SSaga1718
49c719ddc6SSaga1718clean-release:
50c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
51c719ddc6SSaga1718
52c719ddc6SSaga1718test-release:
53c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release
54c719ddc6SSaga1718
55c719ddc6SSaga1718.PHONY: install
56c719ddc6SSaga1718install:
57c719ddc6SSaga1718	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force