Introduce VcpkgPaths::get_available_triplets()

This commit is contained in:
Alexander Karatarakis 2017-10-15 23:24:34 -07:00
parent 6942c00a45
commit b486be5eb3
3 changed files with 21 additions and 12 deletions

View File

@ -36,6 +36,7 @@ namespace vcpkg
fs::path build_info_file_path(const PackageSpec& spec) const; fs::path build_info_file_path(const PackageSpec& spec) const;
fs::path listfile_path(const BinaryParagraph& pgh) const; fs::path listfile_path(const BinaryParagraph& pgh) const;
const std::vector<std::string>& get_available_triplets() const;
bool is_valid_triplet(const Triplet& t) const; bool is_valid_triplet(const Triplet& t) const;
fs::path root; fs::path root;
@ -74,6 +75,7 @@ namespace vcpkg
Files::Filesystem& get_filesystem() const; Files::Filesystem& get_filesystem() const;
private: private:
Lazy<std::vector<std::string>> available_triplets;
Lazy<fs::path> cmake_exe; Lazy<fs::path> cmake_exe;
Lazy<fs::path> git_exe; Lazy<fs::path> git_exe;
Lazy<fs::path> nuget_exe; Lazy<fs::path> nuget_exe;

View File

@ -16,9 +16,9 @@ namespace vcpkg::Help
void help_topic_valid_triplet(const VcpkgPaths& paths) void help_topic_valid_triplet(const VcpkgPaths& paths)
{ {
System::println("Available architecture triplets:"); System::println("Available architecture triplets:");
for (auto&& path : paths.get_filesystem().get_files_non_recursive(paths.triplets)) for (auto&& triplet : paths.get_available_triplets())
{ {
System::println(" %s", path.stem().filename().string()); System::println(" %s", triplet);
} }
} }

View File

@ -255,18 +255,25 @@ namespace vcpkg
return this->vcpkg_dir_info / (pgh.fullstem() + ".list"); return this->vcpkg_dir_info / (pgh.fullstem() + ".list");
} }
const std::vector<std::string>& VcpkgPaths::get_available_triplets() const
{
return this->available_triplets.get_lazy([this]() -> std::vector<std::string> {
std::vector<std::string> output;
for (auto&& path : this->get_filesystem().get_files_non_recursive(this->triplets))
{
output.push_back(path.stem().filename().string());
}
return output;
});
}
bool VcpkgPaths::is_valid_triplet(const Triplet& t) const bool VcpkgPaths::is_valid_triplet(const Triplet& t) const
{ {
for (auto&& path : get_filesystem().get_files_non_recursive(this->triplets)) auto it = Util::find_if(this->get_available_triplets(),
{ [&](auto&& available_triplet) { return t.canonical_name() == available_triplet; });
const std::string triplet_file_name = path.stem().generic_u8string(); return it != this->get_available_triplets().cend();
if (t.canonical_name() == triplet_file_name) // TODO: fuzzy compare
{
// t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
return true;
}
}
return false;
} }
const fs::path& VcpkgPaths::get_cmake_exe() const const fs::path& VcpkgPaths::get_cmake_exe() const