mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 19:25:27 +08:00
Introduce VcpkgPaths::get_available_triplets()
This commit is contained in:
parent
6942c00a45
commit
b486be5eb3
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,18 +255,25 @@ namespace vcpkg
|
||||
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
|
||||
{
|
||||
for (auto&& path : get_filesystem().get_files_non_recursive(this->triplets))
|
||||
{
|
||||
const 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
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user