diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-04-14 16:07:54 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-04-14 16:07:54 -0700 |
| commit | 20397fc845fac398a1aca2ee17ce5b932fc1a83b (patch) | |
| tree | 51235bc2602a81a89da9605272a37ca4fc1765a8 /toolsrc/src/VcpkgPaths.cpp | |
| parent | 8183671a492aa21ec20780a77f923848b0aeca41 (diff) | |
| parent | 1c08a42091cb0addd1e0c1daf27d24bf4e9d237f (diff) | |
| download | vcpkg-20397fc845fac398a1aca2ee17ce5b932fc1a83b.tar.gz vcpkg-20397fc845fac398a1aca2ee17ce5b932fc1a83b.zip | |
Merge branch 'dev/roschuma/fs-testing'
Diffstat (limited to 'toolsrc/src/VcpkgPaths.cpp')
| -rw-r--r-- | toolsrc/src/VcpkgPaths.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index 6fc0538fd..ec4bb2dce 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -6,6 +6,7 @@ #include "PackageSpec.h" #include "vcpkg_Files.h" #include "vcpkg_Util.h" +#include "..\include\VcpkgPaths.h" namespace vcpkg { @@ -155,7 +156,7 @@ namespace vcpkg Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir) { std::error_code ec; - const fs::path canonical_vcpkg_root_dir = fs::canonical(vcpkg_root_dir, ec); + const fs::path canonical_vcpkg_root_dir = fs::stdfs::canonical(vcpkg_root_dir, ec); if (ec) { return ec; @@ -213,10 +214,9 @@ namespace vcpkg bool VcpkgPaths::is_valid_triplet(const Triplet& t) const { - auto it = fs::directory_iterator(this->triplets); - for (; it != fs::directory_iterator(); ++it) + for (auto&& path : get_filesystem().get_files_non_recursive(this->triplets)) { - std::string triplet_file_name = it->path().stem().generic_u8string(); + 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 @@ -264,6 +264,8 @@ namespace vcpkg static Toolset find_toolset_instance(const VcpkgPaths& paths) { + const auto& fs = paths.get_filesystem(); + const std::vector<std::string> vs2017_installation_instances = get_VS2017_installation_instances(paths); // Note: this will contain a mix of vcvarsall.bat locations and dumpbin.exe locations. std::vector<fs::path> paths_examined; @@ -276,16 +278,15 @@ 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)) + 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; - Files::non_recursive_find_matching_paths_in_dir(msvc_path, [](const fs::path& current) - { - return fs::is_directory(current); - }, &msvc_subdirectories); + 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); + }); // Sort them so that latest comes first std::sort(msvc_subdirectories.begin(), msvc_subdirectories.end(), [](const fs::path& left, const fs::path& right) @@ -297,7 +298,7 @@ namespace vcpkg { const fs::path dumpbin_path = subdir / "bin" / "HostX86" / "x86" / "dumpbin.exe"; paths_examined.push_back(dumpbin_path); - if (fs::exists(dumpbin_path)) + if (fs.exists(dumpbin_path)) { return { dumpbin_path, vcvarsall_bat , L"v141" }; } @@ -311,11 +312,11 @@ namespace vcpkg const fs::path vs2015_vcvarsall_bat = *v / "VC" / "vcvarsall.bat"; paths_examined.push_back(vs2015_vcvarsall_bat); - if (fs::exists(vs2015_vcvarsall_bat)) + if (fs.exists(vs2015_vcvarsall_bat)) { const fs::path vs2015_dumpbin_exe = *v / "VC" / "bin" / "dumpbin.exe"; paths_examined.push_back(vs2015_dumpbin_exe); - if (fs::exists(vs2015_dumpbin_exe)) + if (fs.exists(vs2015_dumpbin_exe)) { return { vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140" }; } @@ -335,4 +336,8 @@ namespace vcpkg { return this->toolset.get_lazy([this]() { return find_toolset_instance(*this); }); } + Files::Filesystem & VcpkgPaths::get_filesystem() const + { + return Files::get_real_filesystem(); + } } |
