vcpkg_from_git: Add support for git over ssh

This commit is contained in:
Marc Boucek 2019-12-23 02:48:03 +01:00 committed by Marc Boucek
parent 0a64f3a1f6
commit 9b81b16c4c
4 changed files with 28 additions and 10 deletions

View File

@ -19,7 +19,7 @@ Specifies the out-variable that will contain the extracted location.
This should be set to `SOURCE_PATH` by convention.
### URL
The url of the git repository. Must start with `https`.
The url of the git repository.
### REF
The git sha of the commit to download.

View File

@ -19,7 +19,7 @@
## This should be set to `SOURCE_PATH` by convention.
##
## ### URL
## The url of the git repository. Must start with `https`.
## The url of the git repository.
##
## ### REF
## The git sha of the commit to download.
@ -49,13 +49,6 @@ function(vcpkg_from_git)
message(FATAL_ERROR "The git url must be specified")
endif()
if( NOT _vdud_URL MATCHES "^https:")
# vcpkg_from_git does not support a SHA256 parameter because hashing the git archive is
# not stable across all supported platforms. The tradeoff is to require https to download
# and the ref to be the git sha (i.e. not things that can change like a label)
message(FATAL_ERROR "The git url must be https")
endif()
if(NOT DEFINED _vdud_REF)
message(FATAL_ERROR "The git ref must be specified.")
endif()

View File

@ -241,6 +241,12 @@ namespace vcpkg
// Enables proxy information to be passed to Curl, the underlying download library in cmake.exe
L"http_proxy",
L"https_proxy",
// Environment variables to tell git to use custom SSH executable or command
L"GIT_SSH",
L"GIT_SSH_COMMAND",
// Environment variables needed for ssh-agent based authentication
L"SSH_AUTH_SOCK",
L"SSH_AGENT_PID",
// Enables find_package(CUDA) and enable_language(CUDA) in CMake
L"CUDA_PATH",
L"CUDA_PATH_V9_0",

View File

@ -469,12 +469,31 @@ namespace vcpkg::Build
auto& fs = paths.get_filesystem();
auto&& scfl = action.source_control_file_location.value_or_exit(VCPKG_LINE_INFO);
std::string prepend_to_path;
#if defined(_WIN32)
const fs::path& powershell_exe_path = paths.get_tool_exe("powershell-core");
if (!fs.exists(powershell_exe_path.parent_path() / "powershell.exe"))
{
fs.copy(powershell_exe_path, powershell_exe_path.parent_path() / "powershell.exe", fs::copy_options::none);
}
prepend_to_path += powershell_exe_path.parent_path().u8string() + ";";
// We need to add the git ssh path in order to be able to use git with ssh
// We search for the ssh executable located in a sibling folder of git
const fs::path& git_exe_path = paths.get_tool_exe(Tools::GIT);
fs::path git_ssh_search_path = git_exe_path.parent_path();
for(int parent = 0; parent < 2; ++parent )
{
git_ssh_search_path = git_ssh_search_path.parent_path();
fs::path git_ssh_exe_path = git_ssh_search_path / "usr" / "bin" / "ssh.exe";
if (fs.exists(git_ssh_exe_path))
{
prepend_to_path += git_ssh_exe_path.parent_path().u8string() + ";";
break;
}
}
#endif
Triplet triplet = action.spec.triplet();
@ -513,7 +532,7 @@ namespace vcpkg::Build
const auto& env = build_env_cache.get_lazy({&base_env, build_env_cmd}, [&]() {
auto clean_env =
System::get_modified_clean_environment(base_env, powershell_exe_path.parent_path().u8string() + ";");
System::get_modified_clean_environment(base_env, prepend_to_path);
if (build_env_cmd.empty())
return clean_env;
else