【问题标题】:Init git submodules outside a git repository在 git 存储库之外初始化 git 子模块
【发布时间】:2016-06-09 17:34:13
【问题描述】:

首先,这个问题可能听起来很愚蠢,但我认为没有其他办法。

对于正在工作的项目之一,我需要添加一个依赖项。有一个脚本可以自动抓取 tarball 存档、解压缩、添加补丁并构建它。就我而言,我有一个 github 项目 (restbed) 的 tarball,它需要他自己的依赖项,作为子模块(asio、openssl 和 catch)。主要问题是存档只包含restbed的源,而不是依赖项。

希望存档中有 .gitmodules 文件

[submodule "dependency/asio"]
        path = dependency/asio
        url = https://github.com/corvusoft/asio-dependency
        branch = master
[submodule "dependency/catch"]
        path = dependency/catch
        url = https://github.com/corvusoft/catch-dependency
        branch = master
[submodule "dependency/openssl"]
        path = dependency/openssl
        url = https://github.com/corvusoft/openssl-dependency
        branch = OpenSSL_1_0_2-stable

所以我尝试了经典的git submodule init,它给了我fatal: Not a git repository (or any of the parent directories): .git

那么,有没有办法获取项目的依赖关系,还是我必须手动将它们添加到项目中?

谢谢。

【问题讨论】:

  • restbed 是一个 6MB 的克隆。只需克隆它。
  • @jthill 该脚本不支持 git 克隆。另外,我们希望使用 tarball 来获得稳定版本。
  • 您的 tarball 不会为您提供稳定版本,因为它不记录依赖项。修复您的脚本以进行结帐和子模块更新。

标签: git github restbed


【解决方案1】:

独立于 Restbed 安装和构建所需的依赖项。该项目有 cmake find modules 在构建过程中从公共路径中检测所需组件,请参阅下面的 OpenSSL 模块:

# Copyright 2013-2016, Corvusoft Ltd, All Rights Reserved.

find_library( ssl_LIBRARY ssl ssleay32 HINTS "${CMAKE_SOURCE_DIR}/dependency/openssl/out32dll" "${CMAKE_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_library( crypto_LIBRARY crypto libeay32 HINTS "${CMAKE_SOURCE_DIR}/dependency/openssl/out32dll" "${CMAKE_SOURCE_DIR}/dependency/openssl" "/usr/local/opt/openssl/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib" )
find_path( ssl_INCLUDE openssl/ssl.h HINTS "${CMAKE_SOURCE_DIR}/dependency/openssl/inc32" "${CMAKE_SOURCE_DIR}/dependency/openssl/include" "/usr/local/opt/openssl/lib" "/usr/include" "/usr/local/include" "/opt/local/include" )

if ( ssl_INCLUDE AND ssl_LIBRARY AND crypto_LIBRARY )
    set( OPENSSL_FOUND TRUE )
    add_definitions( -DBUILD_SSL=TRUE )

    if ( APPLE AND BUILD_SSL )
        set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations" )
    endif( )

    message( STATUS "${Green}Found OpenSSL library at: ${ssl_LIBRARY}${Reset}" )
    message( STATUS "${Green}Found OpenSSL include at: ${ssl_INCLUDE}${Reset}" )
    message( STATUS "${Green}Found Crypto library at: ${crypto_LIBRARY}${Reset}" )
else ( )
    message( FATAL_ERROR "${Red}Failed to locate OpenSSL dependency. see restbed/dependency/openssl; ./config shared; make all${Reset}" )
endif ( )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-12
    • 2016-07-30
    • 2019-02-16
    • 2013-06-30
    • 2012-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多