Skip to content

Latest commit

 

History

History
158 lines (125 loc) · 5.59 KB

File metadata and controls

158 lines (125 loc) · 5.59 KB

submodule

本项目的第三方库使用submodule进行管理

关于第三方库的构建你可参阅:https://czyt1988.github.io/data-workbench/zh/build/third-party-build

关于第三方库的管理和介绍你可参阅:https://czyt1988.github.io/data-workbench/zh/dev-guide/third-party-manage

submdule的拉取

首次拉取项目之后,需要执行:

git submodule update --init --recursive

对所有的submodule进行拉取

当然也可以逐个拉取:

git submodule update src/3rdparty/zlib
git submodule update src/3rdparty/quazip
git submodule update src/3rdparty/spdlog
git submodule update src/3rdparty/SARibbon
git submodule update src/3rdparty/ADS
git submodule update src/3rdparty/pybind11
git submodule update src/3rdparty/QtPropertyBrowser
git submodule update src/3rdparty/ordered-map

submodule的添加

第三方库统一放置到/src/3rdparty/xxx目录下

添加submodule,以pybind11举例

git submodule add https://github.com/pybind/pybind11 ./src/3rdparty/pybind11

  • 注意最后路径是./src/3rdparty/pybind11,库名称文件夹要指定

DA目前添加的submodule有如下:

github版本:

git submodule add https://github.com/madler/zlib ./src/3rdparty/zlib
git submodule add https://github.com/stachenov/quazip ./src/3rdparty/quazip
git submodule add https://github.com/gabime/spdlog ./src/3rdparty/spdlog
git submodule add https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System ./src/3rdparty/ADS
git submodule add https://github.com/czyt1988/SARibbon ./src/3rdparty/SARibbon
git submodule add https://github.com/pybind/pybind11 ./src/3rdparty/pybind11
git submodule add https://github.com/czyt1988/QtPropertyBrowser ./src/3rdparty/QtPropertyBrowser
git submodule add https://github.com/czyt1988/QWT ./src/3rdparty/qwt
git submodule add https://github.com/Tessil/ordered-map ./src/3rdparty/ordered-map

gitee版本:

git submodule add https://gitee.com/czyt1988/zlib ./src/3rdparty/zlib
git submodule add https://gitee.com/czyt1988/quazip ./src/3rdparty/quazip
git submodule add https://gitee.com/czyt1988/spdlog ./src/3rdparty/spdlog
git submodule add https://gitee.com/czyt1988/Qt-Advanced-Docking-System ./src/3rdparty/ADS
git submodule add https://gitee.com/czyt1988/SARibbon ./src/3rdparty/SARibbon
git submodule add https://gitee.com/czyt1988/pybind11 ./src/3rdparty/pybind11
git submodule add https://gitee.com/czyt1988/QtPropertyBrowser ./src/3rdparty/QtPropertyBrowser
git submodule add https://gitee.com/czyt1988/QWT ./src/3rdparty/qwt
git submodule add https://gitee.com/czyt1988/ordered-map ./src/3rdparty/ordered-map

submodule的更新

如果某个submodule更新了,使用git submodule update --remote {submodule}进行更新,如SARibbon项目更新了,可以执行:

git submodule update --remote src/3rdparty/SARibbon

submodule的批量操作

单独进入某个submodule目录下执行git命令和普通的git仓库操作一样,也可以批量执行,如

git submodule foreach '{需要执行的git命令}'

如 git submodule foreach 'git checkout main'

替换为github源

由于github访问域限制,目前项目默认的subbmodule的url都是gitee的,如果要切换为github的,可以按照如下步骤执行:

  1. .gitmodules文件的调整

    打开.gitmodules文件,此文件包含了第三方库的地址,你可以对此地址进行调整,例如下面为当前第三方库的github地址配置

    [submodule "src/3rdparty/spdlog"]
    	url = https://github.com/gabime/spdlog.git
    	active = true
    [submodule "src/3rdparty/ADS"]
    	url = https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
    	active = true
    [submodule "src/3rdparty/SARibbon"]
    	url = https://github.com/czyt1988/SARibbon.git
    	active = true
    [submodule "src/3rdparty/pybind11"]
    	url = https://github.com/pybind/pybind11.git
    	active = true
    [submodule "src/3rdparty/QtPropertyBrowser"]
    	url = https://github.com/czyt1988/QtPropertyBrowser.git
    	active = true
    [submodule "src/3rdparty/qwt"]
    	url = https://github.com/czyt1988/QWT.git
    	active = true
    [submodule "src/3rdparty/ordered-map"]
    	url = https://github.com/Tessil/ordered-map.git
    	active = true
    [submodule "src/3rdparty/quazip"]
    	url = https://github.com/stachenov/quazip.git
    	active = true
    [submodule "src/3rdparty/zlib"]
    	url = https://github.com/madler/zlib.git
    	active = true

    你也可以调整为其它地址,例如

    [submodule "src/3rdparty/spdlog"]
    	url = https://gitee.com/czyt1988/spdlog.git
    	active = true
    [submodule "src/3rdparty/ADS"]
    	url = https://gitee.com/czyt1988/Qt-Advanced-Docking-System.git
    	active = true
    [submodule "src/3rdparty/SARibbon"]
    	url = https://gitee.com/czyt1988/SARibbon.git
    	active = true
    [submodule "src/3rdparty/pybind11"]
    	url = https://gitee.com/czyt1988/pybind11.git
    	active = true
    [submodule "src/3rdparty/QtPropertyBrowser"]
    	url = https://gitee.com/czyt1988/QtPropertyBrowser.git
    	active = true
    [submodule "src/3rdparty/qwt"]
    	url = https://gitee.com/czyt1988/QWT.git
    	active = true
    [submodule "src/3rdparty/ordered-map"]
    	url = https://gitee.com/czyt1988/ordered-map.git
    	active = true
    [submodule "src/3rdparty/quazip"]
    	url = https://gitee.com/czyt1988/quazip.git
    	active = true
    [submodule "src/3rdparty/zlib"]
    	url = https://gitee.com/czyt1988/zlib
    	active = true
  2. 同步调整./.git/config文件里对应的url

    .gitmodules文件调整后需要同步调整.git/config文件里对应的url才能生效