Skip to content

Commit

Permalink
使用submodule引入DragonStub (DragonOS-Community#462)
Browse files Browse the repository at this point in the history
* 修正构建系统文档: 使用repo工具克隆代码

* 使用submodule管理
  • Loading branch information
fslongjin authored Dec 3, 2023
1 parent 83ed0eb commit af35431
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "kernel/submodules/DragonStub"]
path = kernel/submodules/DragonStub
url = https://github.com/DragonOS-Community/DragonStub.git
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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核心数"
Expand All @@ -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 - 从镜像更新子模块"

21 changes: 8 additions & 13 deletions docs/introduction/build_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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),以避免由于网络问题导致的克隆失败:
Expand All @@ -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 [email protected]:DragonOS-Community/DragonOS.git
cd DragonOS
# 使用镜像源更新子模块
make update-submodules-by-mirror
```

## 2.使用一键初始化脚本进行安装(推荐)
Expand Down
2 changes: 1 addition & 1 deletion env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ifeq ($(ARCH), )
# !!!!在这里设置ARCH,可选x86_64和riscv64
# !!!!!!!如果不同时调整这里以及vscode的settings.json,那么自动补全和检查将会失效
export ARCH=x86_64
export ARCH?=x86_64
endif

ifeq ($(EMULATOR), )
Expand Down
3 changes: 2 additions & 1 deletion kernel/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions kernel/submodules/DragonStub
Submodule DragonStub added at a09217

0 comments on commit af35431

Please sign in to comment.