Introduce VcpkgPaths::get_available_triplets()
MODIFY
include/vcpkg/vcpkgpaths.h
include/vcpkg/vcpkgpaths.h
@@ -36,6 +36,7 @@ namespace vcpkg
fs::path build_info_file_path(const PackageSpec& spec) 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;
fs::path root;
@@ -74,6 +75,7 @@ namespace vcpkg
Files::Filesystem& get_filesystem() const;
private:
+ Lazy<std::vector<std::string>> available_triplets;
Lazy<fs::path> cmake_exe;
Lazy<fs::path> git_exe;
Lazy<fs::path> nuget_exe;

MODIFY
src/vcpkg/help.cpp
src/vcpkg/help.cpp
@@ -16,9 +16,9 @@ namespace vcpkg::Help
void help_topic_valid_triplet(const VcpkgPaths& paths)
{
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);
}
}

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

Introduce VcpkgPaths::get_available_triplets()