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