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