Skip to content

Commit

Permalink
解决设置rust workspace带来的“工具链不一致”的问题
Browse files Browse the repository at this point in the history
更改workflow
  • Loading branch information
fslongjin committed Aug 26, 2023
1 parent 781a1ed commit 5d0bb86
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 19 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,5 @@ jobs:
printf "\n" >> user/libs/libc/src/include/internal/bindings/bindings.rs
- name: Check format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: |
FMT_CHECK=1 make fmt
7 changes: 0 additions & 7 deletions Cargo.toml

This file was deleted.

15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ export NM=$(DragonOS_GCC)/x86_64-elf-nm
export AR=$(DragonOS_GCC)/x86_64-elf-ar
export OBJCOPY=$(DragonOS_GCC)/x86_64-elf-objcopy

# 检查是否需要进行fmt --check
# 解析命令行参数
FMT_CHECK?=0

ifeq ($(FMT_CHECK), 1)
FMT_CHECK=--check
else
FMT_CHECK=
endif


.PHONY: all
all: kernel user
Expand Down Expand Up @@ -142,6 +152,11 @@ run-docker:
$(MAKE) write_diskimage || exit 1
$(MAKE) qemu

fmt:
@echo "格式化代码"
FMT_CHECK=$(FMT_CHECK) $(MAKE) fmt -C kernel
FMT_CHECK=$(FMT_CHECK) $(MAKE) fmt -C user

help:
@echo "编译:"
@echo " make all -j <n> - 本地编译,不运行,n为要用于编译的CPU核心数"
Expand Down
1 change: 1 addition & 0 deletions docs/introduction/build_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ make run-docker
- 清理编译产生的文件: `make clean`
- 编译文档: `make docs` (需要手动安装sphinx以及docs下的`requirements.txt`中的依赖)
- 清理文档: `make clean-docs`
- 格式化代码: `make fmt`

:::{note}
如果您需要在vnc中运行DragonOS,请在上述命令后加上`-vnc`后缀。如:`make run-vnc`
Expand Down
6 changes: 5 additions & 1 deletion kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ all:

clean:
rm -f Cargo.lock
$(MAKE) -C src clean
$(MAKE) -C src clean

.PHONY: fmt
fmt:
cargo fmt --all $(FMT_CHECK)
3 changes: 0 additions & 3 deletions rust-toolchain.toml

This file was deleted.

6 changes: 5 additions & 1 deletion user/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ clean:
cd $$subdir && $(MAKE) clean;\
cd .. ;\
done


.PHONY: fmt
fmt:
FMT_CHECK=$(FMT_CHECK) $(MAKE) -C libs
FMT_CHECK=$(FMT_CHECK) $(MAKE) -C apps
5 changes: 4 additions & 1 deletion user/apps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ $(user_apps_sub_dirs): ECHO
$(MAKE) -C $@ all CFLAGS="$(CFLAGS)" tmp_output_dir="$(tmp_output_dir)" output_dir="$(output_dir)" sys_libs_dir="$(sys_libs_dir)"

all: $(user_apps_sub_dirs)


.PHONY: clean
fmt:
@echo "格式化代码: user/apps"
7 changes: 6 additions & 1 deletion user/libs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ clean:
echo "Clean in dir: $$subdir";\
cd $$subdir && $(MAKE) clean;\
cd .. ;\
done
done

.PHONY: clean
fmt:
@echo "格式化代码: user/libs"
FMT_CHECK=$(FMT_CHECK) $(MAKE) -C libc fmt
6 changes: 5 additions & 1 deletion user/libs/libc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ all:

clean:
rm -f Cargo.lock
$(MAKE) -C src clean
$(MAKE) -C src clean

.PHONY: fmt
fmt:
cargo fmt --all $(FMT_CHECK)

0 comments on commit 5d0bb86

Please sign in to comment.