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