aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/triplet.cpp
diff options
context:
space:
mode:
authorJan HrubĂ˝ <jhruby.web@gmail.com>2017-03-13 08:56:05 +0100
committerGitHub <noreply@github.com>2017-03-13 08:56:05 +0100
commit665f4118f603c5858217ed7a2f2f824b18ff4fc5 (patch)
treef0167041edf71e90f2331b5025f603392a8de67a /toolsrc/src/triplet.cpp
parent1bec0fcb73073b5b1719f454c368a63f1bff625e (diff)
parent1c9873a0daf625f67474aaf3e163c592c27ecb65 (diff)
downloadvcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.tar.gz
vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.zip
Merge pull request #1 from Microsoft/master
pull
Diffstat (limited to 'toolsrc/src/triplet.cpp')
-rw-r--r--toolsrc/src/triplet.cpp61
1 files changed, 26 insertions, 35 deletions
diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp
index 14f19d5cd..d91e0e68f 100644
--- a/toolsrc/src/triplet.cpp
+++ b/toolsrc/src/triplet.cpp
@@ -1,19 +1,19 @@
+#include "pch.h"
#include "triplet.h"
-#include "vcpkg.h"
-#include "vcpkg_System.h"
#include "vcpkg_Checks.h"
+#include "vcpkg_Strings.h"
namespace vcpkg
{
- const triplet triplet::X86_WINDOWS = {"x86-windows"};
- const triplet triplet::X64_WINDOWS = {"x64-windows"};
- const triplet triplet::X86_UWP = {"x86-uwp"};
- const triplet triplet::X64_UWP = {"x64-uwp"};
- const triplet triplet::ARM_UWP = {"arm-uwp"};
+ const triplet triplet::X86_WINDOWS = from_canonical_name("x86-windows");
+ const triplet triplet::X64_WINDOWS = from_canonical_name("x64-windows");
+ const triplet triplet::X86_UWP = from_canonical_name("x86-uwp");
+ const triplet triplet::X64_UWP = from_canonical_name("x64-uwp");
+ const triplet triplet::ARM_UWP = from_canonical_name("arm-uwp");
std::string to_string(const triplet& t)
{
- return t.value;
+ return t.canonical_name();
}
std::string to_printf_arg(const triplet& t)
@@ -23,7 +23,7 @@ namespace vcpkg
bool operator==(const triplet& left, const triplet& right)
{
- return left.value == right.value;
+ return left.canonical_name() == right.canonical_name();
}
bool operator!=(const triplet& left, const triplet& right)
@@ -36,40 +36,31 @@ namespace vcpkg
return os << to_string(t);
}
- std::string triplet::architecture() const
+ triplet triplet::from_canonical_name(const std::string& triplet_as_string)
{
- if (*this == X86_WINDOWS || *this == X86_UWP)
- return "x86";
- if (*this == X64_WINDOWS || *this == X64_UWP)
- return "x64";
- if (*this == ARM_UWP)
- return "arm";
+ const std::string s(Strings::ascii_to_lowercase(triplet_as_string));
+ auto it = std::find(s.cbegin(), s.cend(), '-');
+ Checks::check_exit(it != s.cend(), "Invalid triplet: %s", triplet_as_string);
- Checks::exit_with_message("Unknown architecture: %s", value);
+ triplet t;
+ t.m_canonical_name = s;
+ return t;
}
- std::string triplet::system() const
+ const std::string& triplet::canonical_name() const
{
- if (*this == X86_WINDOWS || *this == X64_WINDOWS)
- return "windows";
- if (*this == X86_UWP || *this == X64_UWP || *this == ARM_UWP)
- return "uwp";
+ return this->m_canonical_name;
+ }
- Checks::exit_with_message("Unknown system: %s", value);
+ std::string triplet::architecture() const
+ {
+ auto it = std::find(this->m_canonical_name.cbegin(), this->m_canonical_name.cend(), '-');
+ return std::string(this->m_canonical_name.cbegin(), it);
}
- bool triplet::validate(const vcpkg_paths & paths)
+ std::string triplet::system() 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(value == triplet_file_name) // TODO: fuzzy compare
- {
- //value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare
- return true;
- }
- }
- return false;
+ auto it = std::find(this->m_canonical_name.cbegin(), this->m_canonical_name.cend(), '-');
+ return std::string(it + 1, this->m_canonical_name.cend());
}
}