2016-06-09 262 views
0

首先,这个问题可能听起来很愚蠢,但我认为没有其他办法可以做到这一点。在git仓库之外初始化git子模块

对于工作中的一个项目,我需要添加一个依赖项。有一个脚本会自动抓取tarball档案,解压缩它,添加补丁并构建它。在我的情况下,我有一个github项目的tarball(restbed),它需要他自己的依赖关系,作为子模块(asio,openssl和catch)。主要问题是档案只包含restbed的来源,而不包含依赖关系。

希望有一个在档案

[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的.gitmodules文件。

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

谢谢。

+0

restbed是6MB克隆。只需克隆它。 – jthill

+0

@jthill脚本不支持git克隆。另外我们想要tarball有一个稳定的版本。 – Bl4ckb0ne

+0

你的tarball不会给你一个稳定的版本,因为它不记录依赖关系。修复脚本以执行结帐和子模块更新。 – jthill

回答

0

安装并构建独立于Restbed所需的依赖关系。该项目的cmake找到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 ()