xref: /DragonOS/user/apps/user-manage/Makefile (revision 7c28051e8c601312d3d0fd7bcb71bc71450d10c0)
103746da3SJomo# The toolchain we use.
203746da3SJomo# You can get it by running DragonOS' `tools/bootstrap.sh`
3*7c28051eSlinfengTOOLCHAIN="+nightly-2024-11-05-x86_64-unknown-linux-gnu"
403746da3SJomoRUSTFLAGS+=""
503746da3SJomo
603746da3SJomoifdef DADK_CURRENT_BUILD_DIR
703746da3SJomo# 如果是在dadk中编译,那么安装到dadk的安装目录中
803746da3SJomo	INSTALL_DIR = $(DADK_CURRENT_BUILD_DIR)
903746da3SJomoelse
1003746da3SJomo# 如果是在本地编译,那么安装到当前目录下的install目录中
1103746da3SJomo	INSTALL_DIR = ./install
1203746da3SJomoendif
1303746da3SJomo
1403746da3SJomo
1503746da3SJomoifeq ($(ARCH), x86_64)
1603746da3SJomo	export RUST_TARGET=x86_64-unknown-linux-musl
1703746da3SJomoelse ifeq ($(ARCH), riscv64)
1803746da3SJomo	export RUST_TARGET=riscv64gc-unknown-linux-gnu
1903746da3SJomoelse
2003746da3SJomo# 默认为x86_86,用于本地编译
2103746da3SJomo	export RUST_TARGET=x86_64-unknown-linux-musl
2203746da3SJomoendif
2303746da3SJomo
2403746da3SJomobuild:
2503746da3SJomo	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET)
2603746da3SJomo
2703746da3SJomorun-dragonreach:
2803746da3SJomo	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) run --target $(RUST_TARGET) --bin DragonReach
2903746da3SJomo
3003746da3SJomoclean:
3103746da3SJomo	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean
3203746da3SJomo
3303746da3SJomobuild-release:
3403746da3SJomo	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) build --target $(RUST_TARGET) --release
3503746da3SJomo
3603746da3SJomoclean-release:
3703746da3SJomo	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) clean --target $(RUST_TARGET) --release
3803746da3SJomo
3903746da3SJomofmt:
4003746da3SJomo	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt
4103746da3SJomo
4203746da3SJomofmt-check:
4303746da3SJomo	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) fmt --check
4403746da3SJomo
4503746da3SJomo.PHONY: install
4603746da3SJomoinstall:
4703746da3SJomo	RUSTFLAGS=$(RUSTFLAGS) cargo $(TOOLCHAIN) install --target $(RUST_TARGET) --path . --no-track --root $(INSTALL_DIR) --force