xref: /DragonOS/user/apps/test_statx/Makefile (revision b4eb05a17f0f65668f69e7979660874ef8e01a2e)
1*b4eb05a1STTaqTOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu"
2*b4eb05a1STTaq# RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
3*b4eb05a1STTaq
4*b4eb05a1STTaqifdef DADK_CURRENT_BUILD_DIR
5*b4eb05a1STTaq# 如果是在dadk中编译,那么安装到dadk的安装目录中
6*b4eb05a1STTaq	INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
7*b4eb05a1STTaqelse
8*b4eb05a1STTaq# 如果是在本地编译,那么安装到当前目录下的install目录中
9*b4eb05a1STTaq	INSTALL_DIR = ./install
10*b4eb05a1STTaqendif
11*b4eb05a1STTaq
12*b4eb05a1STTaqifeq ($(ARCH), x86_64)
13*b4eb05a1STTaq	export RUST_TARGET=x86_64-unknown-linux-musl
14*b4eb05a1STTaqelse ifeq ($(ARCH), riscv64)
15*b4eb05a1STTaq	export RUST_TARGET=riscv64gc-unknown-linux-gnu
16*b4eb05a1STTaqelse
17*b4eb05a1STTaq# 默认为x86_86,用于本地编译
18*b4eb05a1STTaq	export RUST_TARGET=x86_64-unknown-linux-musl
19*b4eb05a1STTaqendif
20*b4eb05a1STTaq
21*b4eb05a1STTaqrun:
22*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET)
23*b4eb05a1STTaq
24*b4eb05a1STTaqbuild:
25*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
26*b4eb05a1STTaq
27*b4eb05a1STTaqclean:
28*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET)
29*b4eb05a1STTaq
30*b4eb05a1STTaqtest:
31*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET)
32*b4eb05a1STTaq
33*b4eb05a1STTaqdoc:
34*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) doc --target $(RUST_TARGET)
35*b4eb05a1STTaq
36*b4eb05a1STTaqfmt:
37*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
38*b4eb05a1STTaq
39*b4eb05a1STTaqfmt-check:
40*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
41*b4eb05a1STTaq
42*b4eb05a1STTaqrun-release:
43*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --release
44*b4eb05a1STTaq
45*b4eb05a1STTaqbuild-release:
46*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
47*b4eb05a1STTaq
48*b4eb05a1STTaqclean-release:
49*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
50*b4eb05a1STTaq
51*b4eb05a1STTaqtest-release:
52*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) test --target $(RUST_TARGET) --release
53*b4eb05a1STTaq
54*b4eb05a1STTaq.PHONY: install
55*b4eb05a1STTaqinstall:
56*b4eb05a1STTaq	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force
57