2016-10-01 07:49:30 +08:00
|
|
|
#include "vcpkg_Input.h"
|
|
|
|
#include "vcpkg_System.h"
|
2016-10-01 07:54:07 +08:00
|
|
|
#include "metrics.h"
|
|
|
|
#include "vcpkg_Commands.h"
|
2016-10-01 07:49:30 +08:00
|
|
|
|
|
|
|
namespace vcpkg {namespace Input
|
|
|
|
{
|
|
|
|
package_spec check_and_get_package_spec(const std::string& package_spec_as_string, const triplet& default_target_triplet, const char* example_text)
|
|
|
|
{
|
2016-10-05 05:47:42 +08:00
|
|
|
const std::string as_lowercase = Strings::ascii_to_lowercase(package_spec_as_string);
|
|
|
|
expected<package_spec> expected_spec = package_spec::from_string(as_lowercase, default_target_triplet);
|
2016-10-01 07:49:30 +08:00
|
|
|
if (auto spec = expected_spec.get())
|
|
|
|
{
|
|
|
|
return *spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
System::println(System::color::error, "Error: %s: %s", expected_spec.error_code().message(), package_spec_as_string);
|
|
|
|
System::print(example_text);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<package_spec> check_and_get_package_specs(const std::vector<std::string>& package_specs_as_strings, const triplet& default_target_triplet, const char* example_text)
|
|
|
|
{
|
|
|
|
std::vector<package_spec> specs;
|
|
|
|
for (const std::string& spec : package_specs_as_strings)
|
|
|
|
{
|
|
|
|
specs.push_back(check_and_get_package_spec(spec, default_target_triplet, example_text));
|
|
|
|
}
|
|
|
|
|
|
|
|
return specs;
|
|
|
|
}
|
2016-10-01 07:54:07 +08:00
|
|
|
|
|
|
|
void check_triplet(const triplet& t, const vcpkg_paths& paths)
|
|
|
|
{
|
|
|
|
if (!paths.is_valid_triplet(t))
|
|
|
|
{
|
2016-10-04 08:20:52 +08:00
|
|
|
System::println(System::color::error, "Error: invalid triplet: %s", t.canonical_name());
|
|
|
|
TrackProperty("error", "invalid triplet: " + t.canonical_name());
|
2016-10-01 07:54:07 +08:00
|
|
|
help_topic_valid_triplet(paths);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
2016-10-01 07:55:34 +08:00
|
|
|
|
2016-10-01 08:02:39 +08:00
|
|
|
void check_triplets(std::vector<package_spec> triplets, const vcpkg_paths& paths)
|
2016-10-01 07:55:34 +08:00
|
|
|
{
|
|
|
|
for (const package_spec& spec : triplets)
|
|
|
|
{
|
2016-10-04 08:45:01 +08:00
|
|
|
check_triplet(spec.target_triplet(), paths);
|
2016-10-01 07:55:34 +08:00
|
|
|
}
|
|
|
|
}
|
2016-10-01 07:49:30 +08:00
|
|
|
}}
|