xref: /DragonReach/Makefile (revision 40362c48d633ac31f30270cfa409f3e69e6b0d26)
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"
4dfd3fd98S裕依2439RUSTFLAGS+="-C target-feature=+crt-static -C link-arg=-no-pie"
5236b9b4fSLoGin
6*40362c48SChiichenifdef DADK_CURRENT_BUILD_DIR
7dfd3fd98S裕依2439# 如果是在dadk中编译,那么安装到dadk的安装目录中
8*40362c48SChiichen	INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
9*40362c48SChiichenelse
10dfd3fd98S裕依2439# 如果是在本地编译,那么安装到当前目录下的install目录中
11*40362c48SChiichen	INSTALL_DIR = ./install
12*40362c48SChiichenendif
1317ae4661SGnoCiYeH
14236b9b4fSLoGin
15*40362c48SChiichenifeq ($(ARCH), x86_64)
16*40362c48SChiichen	export RUST_TARGET=x86_64-unknown-linux-musl
17*40362c48SChiichenelse ifeq ($(ARCH), riscv64)
18*40362c48SChiichen	export RUST_TARGET=riscv64gc-unknown-linux-gnu
19*40362c48SChiichenelse
20*40362c48SChiichen# 默认为x86_86,用于本地编译
21*40362c48SChiichen	export RUST_TARGET=x86_64-unknown-linux-musl
22*40362c48SChiichenendif
23*40362c48SChiichen
244e851715SGnoCiYeHbuild:
25*40362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
264e851715SGnoCiYeH
27dfd3fd98S裕依2439run-dragonreach:
28*40362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --bin DragonReach
297ae82d4aSGnoCiYeH
307ae82d4aSGnoCiYeHclean:
31dfd3fd98S裕依2439	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean
32dfd3fd98S裕依2439
33dfd3fd98S裕依2439build-release:
34*40362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
35dfd3fd98S裕依2439
36dfd3fd98S裕依2439clean-release:
37*40362c48SChiichen	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
50*40362c48SChiichen	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force