aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/VcpkgPaths.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/src/VcpkgPaths.cpp')
-rw-r--r--toolsrc/src/VcpkgPaths.cpp85
1 files changed, 42 insertions, 43 deletions
diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp
index 5a1217d0a..389fffe27 100644
--- a/toolsrc/src/VcpkgPaths.cpp
+++ b/toolsrc/src/VcpkgPaths.cpp
@@ -1,15 +1,17 @@
#include "pch.h"
-#include "vcpkg_expected.h"
+
+#include "PackageSpec.h"
#include "VcpkgPaths.h"
#include "metrics.h"
-#include "vcpkg_System.h"
-#include "PackageSpec.h"
#include "vcpkg_Files.h"
+#include "vcpkg_System.h"
#include "vcpkg_Util.h"
+#include "vcpkg_expected.h"
namespace vcpkg
{
- static bool exists_and_has_equal_or_greater_version(const std::wstring& version_cmd, const std::array<int, 3>& expected_version)
+ static bool exists_and_has_equal_or_greater_version(const std::wstring& version_cmd,
+ const std::array<int, 3>& expected_version)
{
static const std::regex re(R"###((\d+)\.(\d+)\.(\d+))###");
@@ -29,7 +31,8 @@ namespace vcpkg
int d1 = atoi(match[1].str().c_str());
int d2 = atoi(match[2].str().c_str());
int d3 = atoi(match[3].str().c_str());
- if (d1 > expected_version[0] || (d1 == expected_version[0] && d2 > expected_version[1]) || (d1 == expected_version[0] && d2 == expected_version[1] && d3 >= expected_version[2]))
+ if (d1 > expected_version[0] || (d1 == expected_version[0] && d2 > expected_version[1]) ||
+ (d1 == expected_version[0] && d2 == expected_version[1] && d3 >= expected_version[2]))
{
// satisfactory version found
return true;
@@ -38,13 +41,14 @@ namespace vcpkg
return false;
}
- static Optional<fs::path> find_if_has_equal_or_greater_version(const std::vector<fs::path>& candidate_paths, const std::wstring& version_check_arguments, const std::array<int, 3>& expected_version)
+ static Optional<fs::path> find_if_has_equal_or_greater_version(const std::vector<fs::path>& candidate_paths,
+ const std::wstring& version_check_arguments,
+ const std::array<int, 3>& expected_version)
{
- auto it = Util::find_if(candidate_paths, [&](const fs::path& p)
- {
- const std::wstring cmd = Strings::wformat(LR"("%s" %s)", p.native(), version_check_arguments);
- return exists_and_has_equal_or_greater_version(cmd, expected_version);
- });
+ auto it = Util::find_if(candidate_paths, [&](const fs::path& p) {
+ const std::wstring cmd = Strings::wformat(LR"("%s" %s)", p.native(), version_check_arguments);
+ return exists_and_has_equal_or_greater_version(cmd, expected_version);
+ });
if (it != candidate_paths.cend())
{
@@ -66,7 +70,9 @@ namespace vcpkg
return Util::fmap(Strings::split(out.output, "\n"), [](auto&& s) { return fs::path(s); });
}
- static fs::path fetch_dependency(const fs::path scripts_folder, const std::wstring& tool_name, const fs::path& expected_downloaded_path)
+ static fs::path fetch_dependency(const fs::path scripts_folder,
+ const std::wstring& tool_name,
+ const fs::path& expected_downloaded_path)
{
const fs::path script = scripts_folder / "fetchDependency.ps1";
auto install_cmd = System::create_powershell_script_cmd(script, Strings::wformat(L"-Dependency %s", tool_name));
@@ -80,14 +86,17 @@ namespace vcpkg
}
const fs::path actual_downloaded_path = Strings::trimmed(rc.output);
- Checks::check_exit(VCPKG_LINE_INFO, expected_downloaded_path == actual_downloaded_path, "Expected dependency downloaded path to be %s, but was %s",
- expected_downloaded_path.generic_string(), actual_downloaded_path.generic_string());
+ Checks::check_exit(VCPKG_LINE_INFO,
+ expected_downloaded_path == actual_downloaded_path,
+ "Expected dependency downloaded path to be %s, but was %s",
+ expected_downloaded_path.generic_string(),
+ actual_downloaded_path.generic_string());
return actual_downloaded_path;
}
static fs::path get_cmake_path(const fs::path& downloads_folder, const fs::path scripts_folder)
{
- static constexpr std::array<int, 3> expected_version = { 3,8,0 };
+ static constexpr std::array<int, 3> expected_version = { 3, 8, 0 };
static const std::wstring version_check_arguments = L"--version";
const fs::path downloaded_copy = downloads_folder / "cmake-3.8.0-win32-x86" / "bin" / "cmake.exe";
@@ -99,7 +108,8 @@ namespace vcpkg
candidate_paths.push_back(System::get_ProgramFiles_platform_bitness() / "CMake" / "bin" / "cmake.exe");
candidate_paths.push_back(System::get_ProgramFiles_32_bit() / "CMake" / "bin");
- const Optional<fs::path> path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version);
+ const Optional<fs::path> path =
+ find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version);
if (auto p = path.get())
{
return *p;
@@ -110,7 +120,7 @@ namespace vcpkg
fs::path get_nuget_path(const fs::path& downloads_folder, const fs::path scripts_folder)
{
- static constexpr std::array<int, 3> expected_version = { 3,3,0 };
+ static constexpr std::array<int, 3> expected_version = { 3, 3, 0 };
static const std::wstring version_check_arguments = L"";
const fs::path downloaded_copy = downloads_folder / "nuget-3.5.0" / "nuget.exe";
@@ -131,7 +141,7 @@ namespace vcpkg
fs::path get_git_path(const fs::path& downloads_folder, const fs::path scripts_folder)
{
- static constexpr std::array<int, 3> expected_version = { 2,0,0 };
+ static constexpr std::array<int, 3> expected_version = { 2, 0, 0 };
static const std::wstring version_check_arguments = L"--version";
const fs::path downloaded_copy = downloads_folder / "MinGit-2.11.1-32-bit" / "cmd" / "git.exe";
@@ -143,7 +153,8 @@ namespace vcpkg
candidate_paths.push_back(System::get_ProgramFiles_platform_bitness() / "git" / "cmd" / "git.exe");
candidate_paths.push_back(System::get_ProgramFiles_32_bit() / "git" / "cmd" / "git.exe");
- const Optional<fs::path> path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version);
+ const Optional<fs::path> path =
+ find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version);
if (auto p = path.get())
{
return *p;
@@ -191,15 +202,9 @@ namespace vcpkg
return paths;
}
- fs::path VcpkgPaths::package_dir(const PackageSpec& spec) const
- {
- return this->packages / spec.dir();
- }
+ fs::path VcpkgPaths::package_dir(const PackageSpec& spec) const { return this->packages / spec.dir(); }
- fs::path VcpkgPaths::port_dir(const PackageSpec& spec) const
- {
- return this->ports / spec.name();
- }
+ fs::path VcpkgPaths::port_dir(const PackageSpec& spec) const { return this->ports / spec.name(); }
fs::path VcpkgPaths::build_info_file_path(const PackageSpec& spec) const
{
@@ -218,7 +223,7 @@ namespace vcpkg
std::string triplet_file_name = path.stem().generic_u8string();
if (t.canonical_name() == triplet_file_name) // TODO: fuzzy compare
{
- //t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
+ // t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
return true;
}
}
@@ -254,7 +259,8 @@ namespace vcpkg
const Optional<std::wstring> vs2015_cmntools_optional = System::get_environmental_variable(L"VS140COMNTOOLS");
if (auto v = vs2015_cmntools_optional.get())
{
- const fs::path vs2015_cmntools = fs::path(*v).parent_path(); // The call to parent_path() is needed because the env variable has a trailing backslash
+ const fs::path vs2015_cmntools = fs::path(*v).parent_path(); // The call to parent_path() is needed because
+ // the env variable has a trailing backslash
return vs2015_cmntools.parent_path().parent_path();
}
@@ -277,21 +283,17 @@ namespace vcpkg
// Skip any instances that do not have vcvarsall.
const fs::path vcvarsall_bat = vc_dir / "Auxiliary" / "Build" / "vcvarsall.bat";
paths_examined.push_back(vcvarsall_bat);
- if (!fs.exists(vcvarsall_bat))
- continue;
+ if (!fs.exists(vcvarsall_bat)) continue;
// Locate the "best" MSVC toolchain version
const fs::path msvc_path = vc_dir / "Tools" / "MSVC";
std::vector<fs::path> msvc_subdirectories = fs.get_files_non_recursive(msvc_path);
- Util::unstable_keep_if(msvc_subdirectories, [&fs](const fs::path& path) {
- return fs.is_directory(path);
- });
+ Util::unstable_keep_if(msvc_subdirectories, [&fs](const fs::path& path) { return fs.is_directory(path); });
// Sort them so that latest comes first
- std::sort(msvc_subdirectories.begin(), msvc_subdirectories.end(), [](const fs::path& left, const fs::path& right)
- {
- return left.filename() > right.filename();
- });
+ std::sort(msvc_subdirectories.begin(),
+ msvc_subdirectories.end(),
+ [](const fs::path& left, const fs::path& right) { return left.filename() > right.filename(); });
for (const fs::path& subdir : msvc_subdirectories)
{
@@ -299,7 +301,7 @@ namespace vcpkg
paths_examined.push_back(dumpbin_path);
if (fs.exists(dumpbin_path))
{
- return { dumpbin_path, vcvarsall_bat , L"v141" };
+ return { dumpbin_path, vcvarsall_bat, L"v141" };
}
}
}
@@ -335,8 +337,5 @@ namespace vcpkg
{
return this->toolset.get_lazy([this]() { return find_toolset_instance(*this); });
}
- Files::Filesystem & VcpkgPaths::get_filesystem() const
- {
- return Files::get_real_filesystem();
- }
+ Files::Filesystem& VcpkgPaths::get_filesystem() const { return Files::get_real_filesystem(); }
}