From af3543100543b9ac6159dc9f9367a76ff670b1f3 Mon Sep 17 00:00:00 2001 From: LoGin Date: Sun, 3 Dec 2023 17:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8submodule=E5=BC=95=E5=85=A5Dr?= =?UTF-8?q?agonStub=20(#462)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修正构建系统文档: 使用repo工具克隆代码 * 使用submodule管理 --- .gitmodules | 3 +++ Makefile | 26 +++++++++++++++++++++++++- docs/introduction/build_system.md | 21 ++++++++------------- env.mk | 2 +- kernel/src/Makefile | 3 ++- kernel/submodules/DragonStub | 1 + 6 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 .gitmodules create mode 160000 kernel/submodules/DragonStub diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..9e0b3597 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "kernel/submodules/DragonStub"] + path = kernel/submodules/DragonStub + url = https://github.com/DragonOS-Community/DragonStub.git diff --git a/Makefile b/Makefile index 71e36454..efee014d 100644 --- a/Makefile +++ b/Makefile @@ -150,7 +150,20 @@ fmt: log-monitor: @echo "启动日志监控" @sh -c "cd tools/debugging/logmonitor && cargo run --release -- --log-dir $(ROOT_PATH)/logs/ --kernel $(ROOT_PATH)/bin/kernel/kernel.elf" - + +.PHONY: update-submodules +update-submodules: + @echo "更新子模块" + @git submodule update --init --recursive + @git submodule foreach git pull origin master + +.PHONY: update-submodules-by-mirror +update-submodules-by-mirror: + @echo "从镜像更新子模块" + @git config --global url."https://git.mirrors.dragonos.org.cn/DragonOS-Community/".insteadOf https://github.com/DragonOS-Community/ + @$(MAKE) update-submodules + @git config --global --unset url."https://git.mirrors.dragonos.org.cn/DragonOS-Community/".insteadOf + help: @echo "编译:" @echo " make all -j - 本地编译,不运行,n为要用于编译的CPU核心数" @@ -168,3 +181,14 @@ help: @echo "" @echo "" @echo "注: 对于上述的run, run-uefi, qemu, qemu-uefi命令可以在命令后加上-vnc后缀,来通过vnc连接到DragonOS, 默认会在5900端口运行vnc服务器。如:make run-vnc " + @echo "" + @echo "其他:" + @echo " make clean - 清理编译产生的文件" + @echo " make fmt - 格式化代码" + @echo " make log-monitor - 启动日志监控" + @echo " make docs - 生成文档" + @echo " make clean-docs - 清理文档" + @echo "" + @echo " make update-submodules - 更新子模块" + @echo " make update-submodules-by-mirror - 从镜像更新子模块" + diff --git a/docs/introduction/build_system.md b/docs/introduction/build_system.md index 53a41c3f..6e9cb627 100644 --- a/docs/introduction/build_system.md +++ b/docs/introduction/build_system.md @@ -11,21 +11,13 @@ ### 1.1 下载DragonOS的源代码 -#### 1.1.1 安装git和repo工具 - -```shell -sudo apt-get install git repo - -echo "export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'" >> ~/.$(basename $SHELL)rc -source ~/.$(basename $SHELL)rc -``` - -#### 1.1.2 克隆DragonOS的代码 - 使用https克隆: ```shell -curl -sSL https://git.mirrors.dragonos.org.cn/DragonOS-Community/manifest/raw/master/scripts/init.sh | bash +git clone https://github.com/DragonOS-Community/DragonOS.git +cd DragonOS +# 使用镜像源更新子模块 +make update-submodules-by-mirror ``` 为了方便后续的开发,我们建议您使用ssh克隆(请先配置好github的SSH Key),以避免由于网络问题导致的克隆失败: @@ -35,7 +27,10 @@ curl -sSL https://git.mirrors.dragonos.org.cn/DragonOS-Community/manifest/raw/ma ```shell # 使用ssh克隆 -bash <(curl -sSL https://git.mirrors.dragonos.org.cn/DragonOS-Community/manifest/raw/master/scripts/init.sh) --use-ssh-after-clone +git clone git@github.com:DragonOS-Community/DragonOS.git +cd DragonOS +# 使用镜像源更新子模块 +make update-submodules-by-mirror ``` ## 2.使用一键初始化脚本进行安装(推荐) diff --git a/env.mk b/env.mk index 788314c7..c25873af 100644 --- a/env.mk +++ b/env.mk @@ -2,7 +2,7 @@ ifeq ($(ARCH), ) # !!!!在这里设置ARCH,可选x86_64和riscv64 # !!!!!!!如果不同时调整这里以及vscode的settings.json,那么自动补全和检查将会失效 -export ARCH=x86_64 +export ARCH?=x86_64 endif ifeq ($(EMULATOR), ) diff --git a/kernel/src/Makefile b/kernel/src/Makefile index f09ac8e2..60072f74 100644 --- a/kernel/src/Makefile +++ b/kernel/src/Makefile @@ -102,7 +102,8 @@ endif __dragon_stub: @echo "Linking dragon_stub..." - PAYLOAD_ELF=$(PAYLOAD_ELF) TARGET_SYSROOT=$(ROOT_PATH)/bin/sysroot $(MAKE) -C $(ROOT_PATH)/../DragonStub install -j $(NPROCS) + @mkdir -p $(ROOT_PATH)/bin/sysroot + PAYLOAD_ELF=$(PAYLOAD_ELF) TARGET_SYSROOT=$(ROOT_PATH)/bin/sysroot $(MAKE) -C $(ROOT_PATH)/kernel/submodules/DragonStub install -j $(NPROCS) clean: diff --git a/kernel/submodules/DragonStub b/kernel/submodules/DragonStub new file mode 160000 index 00000000..a0921711 --- /dev/null +++ b/kernel/submodules/DragonStub @@ -0,0 +1 @@ +Subproject commit a09217116ba686489b46f0bee85581924604b2f6