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