mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 18:47:04 +08:00
Valiting triplets is now the responsibility of vcpkg_paths
This commit is contained in:
parent
ac2e248e8f
commit
fb1130876f
@ -4,8 +4,6 @@
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct vcpkg_paths;
|
||||
|
||||
struct triplet
|
||||
{
|
||||
static const triplet X86_WINDOWS;
|
||||
@ -19,8 +17,6 @@ namespace vcpkg
|
||||
std::string architecture() const;
|
||||
|
||||
std::string system() const;
|
||||
|
||||
bool validate(const vcpkg_paths& paths) const;
|
||||
};
|
||||
|
||||
bool operator==(const triplet& left, const triplet& right);
|
||||
|
@ -13,6 +13,7 @@ namespace vcpkg
|
||||
|
||||
fs::path package_dir(const package_spec& spec) const;
|
||||
fs::path port_dir(const package_spec& spec) const;
|
||||
bool validate_triplet(const triplet& t) const;
|
||||
|
||||
std::tr2::sys::path root;
|
||||
std::tr2::sys::path packages;
|
||||
|
@ -70,14 +70,14 @@ static void inner(const vcpkg_cmd_arguments& args)
|
||||
}
|
||||
|
||||
triplet default_target_triplet;
|
||||
if(args.target_triplet != nullptr)
|
||||
if (args.target_triplet != nullptr)
|
||||
{
|
||||
default_target_triplet = {*args.target_triplet};
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto vcpkg_default_triplet_env = System::wdupenv_str(L"VCPKG_DEFAULT_TRIPLET");
|
||||
if(!vcpkg_default_triplet_env.empty())
|
||||
if (!vcpkg_default_triplet_env.empty())
|
||||
{
|
||||
default_target_triplet = {Strings::utf16_to_utf8(vcpkg_default_triplet_env)};
|
||||
}
|
||||
@ -87,7 +87,7 @@ static void inner(const vcpkg_cmd_arguments& args)
|
||||
}
|
||||
}
|
||||
|
||||
if(!default_target_triplet.validate(paths))
|
||||
if (!paths.validate_triplet(default_target_triplet))
|
||||
{
|
||||
System::println(System::color::error, "Error: invalid triplet: %s", default_target_triplet.value);
|
||||
TrackProperty("error", "invalid triplet: " + default_target_triplet.value);
|
||||
|
@ -1,6 +1,4 @@
|
||||
#include "triplet.h"
|
||||
#include "vcpkg.h"
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkg_Checks.h"
|
||||
|
||||
namespace vcpkg
|
||||
@ -49,19 +47,4 @@ namespace vcpkg
|
||||
Checks::check_exit(it != this->value.end(), "Invalid triplet: %s", this->value);
|
||||
return std::string(it + 1, this->value.cend());
|
||||
}
|
||||
|
||||
bool triplet::validate(const vcpkg_paths& paths) const
|
||||
{
|
||||
auto it = fs::directory_iterator(paths.triplets);
|
||||
for (; it != fs::directory_iterator(); ++it)
|
||||
{
|
||||
std::string triplet_file_name = it->path().stem().generic_u8string();
|
||||
if (this->value == triplet_file_name) // TODO: fuzzy compare
|
||||
{
|
||||
//this->value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -56,4 +56,19 @@ namespace vcpkg
|
||||
{
|
||||
return this->ports / spec.name;
|
||||
}
|
||||
|
||||
bool vcpkg_paths::validate_triplet(const triplet& t) const
|
||||
{
|
||||
auto it = fs::directory_iterator(this->triplets);
|
||||
for (; it != fs::directory_iterator(); ++it)
|
||||
{
|
||||
std::string triplet_file_name = it->path().stem().generic_u8string();
|
||||
if (t.value == triplet_file_name) // TODO: fuzzy compare
|
||||
{
|
||||
//t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user