diff options
| author | Albert Ziegenhagel <albert.ziegenhagel@outlook.com> | 2016-09-23 09:44:30 +0200 |
|---|---|---|
| committer | Albert Ziegenhagel <albert.ziegenhagel@outlook.com> | 2016-09-23 09:44:30 +0200 |
| commit | 31935aa0fd142cbb4e0db1a62ba1483294b740f8 (patch) | |
| tree | 41be4e9498a385ecc8796d9158bf871c07ecdbc1 /toolsrc/src/main.cpp | |
| parent | 4a818b6a3e86514af27381fe16dcf311a5c28ffb (diff) | |
| download | vcpkg-31935aa0fd142cbb4e0db1a62ba1483294b740f8.tar.gz vcpkg-31935aa0fd142cbb4e0db1a62ba1483294b740f8.zip | |
Improved error reporting when user provides invalid triplets
Diffstat (limited to 'toolsrc/src/main.cpp')
| -rw-r--r-- | toolsrc/src/main.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp index 2ec2c8fba..a2f6fa10f 100644 --- a/toolsrc/src/main.cpp +++ b/toolsrc/src/main.cpp @@ -70,40 +70,31 @@ static void inner(const vcpkg_cmd_arguments& args) } triplet default_target_triplet; - const auto vcpkg_default_triplet_env = System::wdupenv_str(L"VCPKG_DEFAULT_TRIPLET"); - if(!vcpkg_default_triplet_env.empty()) + if(args.target_triplet != nullptr) { - default_target_triplet = {Strings::utf16_to_utf8(vcpkg_default_triplet_env)}; + default_target_triplet = {*args.target_triplet}; } else { - default_target_triplet = triplet::X86_WINDOWS; - } - - if (args.target_triplet != nullptr) - { - const std::string& target_triplet = *args.target_triplet; - - auto it = fs::directory_iterator(paths.triplets); - for (; it != fs::directory_iterator(); ++it) + const auto vcpkg_default_triplet_env = System::wdupenv_str(L"VCPKG_DEFAULT_TRIPLET"); + if(!vcpkg_default_triplet_env.empty()) { - std::string triplet_file_name = it->path().stem().generic_u8string(); - if (target_triplet == triplet_file_name) // TODO: fuzzy compare - { - default_target_triplet = {triplet_file_name}; - break; - } + default_target_triplet = {Strings::utf16_to_utf8(vcpkg_default_triplet_env)}; } - - if (it == fs::directory_iterator()) + else { - System::println(System::color::error, "Error: invalid triplet: %s", target_triplet); - TrackProperty("error", "invalid triplet: " + target_triplet); - help_topic_valid_triplet(paths); - exit(EXIT_FAILURE); + default_target_triplet = triplet::X86_WINDOWS; } } + if(!default_target_triplet.validate(paths)) + { + System::println(System::color::error, "Error: invalid triplet: %s", default_target_triplet.value); + TrackProperty("error", "invalid triplet: " + default_target_triplet.value); + help_topic_valid_triplet(paths); + exit(EXIT_FAILURE); + } + if (auto command_function = find_command(args.command, get_available_commands_type_a())) { return command_function(args, paths, default_target_triplet); |
