Valiting triplets is now the responsibility of vcpkg_paths

This commit is contained in:
Alexander Karatarakis 2016-09-28 12:39:05 -07:00
parent ac2e248e8f
commit fb1130876f
5 changed files with 19 additions and 24 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;
}
}