diff options
| -rw-r--r-- | toolsrc/include/triplet.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_paths.h | 1 | ||||
| -rw-r--r-- | toolsrc/src/main.cpp | 6 | ||||
| -rw-r--r-- | toolsrc/src/triplet.cpp | 17 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_paths.cpp | 15 |
5 files changed, 19 insertions, 24 deletions
diff --git a/toolsrc/include/triplet.h b/toolsrc/include/triplet.h index 23c1ea404..f9d1e9483 100644 --- a/toolsrc/include/triplet.h +++ b/toolsrc/include/triplet.h @@ -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); diff --git a/toolsrc/include/vcpkg_paths.h b/toolsrc/include/vcpkg_paths.h index 72cba01b7..c444d695e 100644 --- a/toolsrc/include/vcpkg_paths.h +++ b/toolsrc/include/vcpkg_paths.h @@ -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; diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp index a2f6fa10f..c7162dce0 100644 --- a/toolsrc/src/main.cpp +++ b/toolsrc/src/main.cpp @@ -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); diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp index 080198f2b..e3a935958 100644 --- a/toolsrc/src/triplet.cpp +++ b/toolsrc/src/triplet.cpp @@ -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; - } } diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp index 30d32a99b..b3bbcbee1 100644 --- a/toolsrc/src/vcpkg_paths.cpp +++ b/toolsrc/src/vcpkg_paths.cpp @@ -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; + } } |
