xref: /DragonReach/Makefile (revision 3d99c3a9d908b9e345c484352599a23f19d01943)
1dfd3fd98S裕依2439# The toolchain we use.
2dfd3fd98S裕依2439# You can get it by running DragonOS' `tools/bootstrap.sh`
3dfd3fd98S裕依2439TOOLCHAIN="+nightly-2023-08-15-x86_64-unknown-linux-gnu"
4*3d99c3a9SLoGinRUSTFLAGS+=""
5236b9b4fSLoGin
640362c48SChiichenifdef DADK_CURRENT_BUILD_DIR
7dfd3fd98S裕依2439# 如果是在dadk中编译,那么安装到dadk的安装目录中
840362c48SChiichen	INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
940362c48SChiichenelse
10dfd3fd98S裕依2439# 如果是在本地编译,那么安装到当前目录下的install目录中
1140362c48SChiichen	INSTALL_DIR = ./install
1240362c48SChiichenendif
1317ae4661SGnoCiYeH
14236b9b4fSLoGin
1540362c48SChiichenifeq ($(ARCH), x86_64)
1640362c48SChiichen	export RUST_TARGET=x86_64-unknown-linux-musl
1740362c48SChiichenelse ifeq ($(ARCH), riscv64)
1840362c48SChiichen	export RUST_TARGET=riscv64gc-unknown-linux-gnu
1940362c48SChiichenelse
2040362c48SChiichen# 默认为x86_86,用于本地编译
2140362c48SChiichen	export RUST_TARGET=x86_64-unknown-linux-musl
2240362c48SChiichenendif
2340362c48SChiichen
244e851715SGnoCiYeHbuild:
2540362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
264e851715SGnoCiYeH
27dfd3fd98S裕依2439run-dragonreach:
2840362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --bin DragonReach
297ae82d4aSGnoCiYeH
307ae82d4aSGnoCiYeHclean:
31dfd3fd98S裕依2439	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean
32dfd3fd98S裕依2439
33dfd3fd98S裕依2439build-release:
3440362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
35dfd3fd98S裕依2439
36dfd3fd98S裕依2439clean-release:
3740362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
38236b9b4fSLoGin
39236b9b4fSLoGinfmt:
40dfd3fd98S裕依2439	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
41236b9b4fSLoGin
42236b9b4fSLoGinfmt-check:
43dfd3fd98S裕依2439	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
44236b9b4fSLoGin
45dfd3fd98S裕依2439.PHONY: install
46dfd3fd98S裕依2439install:
47dfd3fd98S裕依2439	mkdir -p $(INSTALL_DIR)/etc/reach/system
487c7ad4f0SLoGin	mkdir -p $(INSTALL_DIR)/etc/reach/ipc
49dfd3fd98S裕依2439	cp ./parse_test/shell.service $(INSTALL_DIR)/etc/reach/system/shell.service
5040362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force