Просмотр исходного кода

使用submodule引入DragonStub (#462)

* 修正构建系统文档: 使用repo工具克隆代码

* 使用submodule管理
LoGin 5 месяцев назад
Родитель
Сommit
af35431005
6 измененных файлов с 40 добавлено и 16 удалено
  1. 3 0
      .gitmodules
  2. 25 1
      Makefile
  3. 8 13
      docs/introduction/build_system.md
  4. 1 1
      env.mk
  5. 2 1
      kernel/src/Makefile
  6. 1 0
      kernel/submodules/DragonStub

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "kernel/submodules/DragonStub"]
+	path = kernel/submodules/DragonStub
+	url = https://github.com/DragonOS-Community/DragonStub.git

+ 25 - 1
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>       - 本地编译,不运行,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 - 从镜像更新子模块"
+

+ 8 - 13
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.使用一键初始化脚本进行安装(推荐)

+ 1 - 1
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), )

+ 2 - 1
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: 

+ 1 - 0
kernel/submodules/DragonStub

@@ -0,0 +1 @@
+Subproject commit a09217116ba686489b46f0bee85581924604b2f6