mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 19:25:27 +08:00
triplet -> Triplet
This commit is contained in:
parent
378b018321
commit
bdf80d63c6
@ -10,7 +10,7 @@ namespace vcpkg
|
||||
{
|
||||
BinaryParagraph();
|
||||
explicit BinaryParagraph(std::unordered_map<std::string, std::string> fields);
|
||||
BinaryParagraph(const SourceParagraph& spgh, const triplet& target_triplet);
|
||||
BinaryParagraph(const SourceParagraph& spgh, const Triplet& target_triplet);
|
||||
|
||||
std::string displayname() const;
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
#pragma once
|
||||
#include "PackageSpecParseResult.h"
|
||||
#include "triplet.h"
|
||||
#include "Triplet.h"
|
||||
#include "vcpkg_expected.h"
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct PackageSpec
|
||||
{
|
||||
static expected<PackageSpec> from_string(const std::string& spec_as_string, const triplet& default_target_triplet);
|
||||
static expected<PackageSpec> from_string(const std::string& spec_as_string, const Triplet& default_target_triplet);
|
||||
|
||||
static expected<PackageSpec> from_name_and_triplet(const std::string& name, const triplet& target_triplet);
|
||||
static expected<PackageSpec> from_name_and_triplet(const std::string& name, const Triplet& target_triplet);
|
||||
|
||||
const std::string& name() const;
|
||||
|
||||
const triplet& target_triplet() const;
|
||||
const Triplet& target_triplet() const;
|
||||
|
||||
std::string display_name() const;
|
||||
|
||||
@ -23,7 +23,7 @@ namespace vcpkg
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
triplet m_target_triplet;
|
||||
Triplet m_target_triplet;
|
||||
};
|
||||
|
||||
std::string to_printf_arg(const PackageSpec& spec);
|
||||
@ -42,7 +42,7 @@ namespace std
|
||||
{
|
||||
size_t hash = 17;
|
||||
hash = hash * 31 + std::hash<std::string>()(value.name());
|
||||
hash = hash * 31 + std::hash<vcpkg::triplet>()(value.target_triplet());
|
||||
hash = hash * 31 + std::hash<vcpkg::Triplet>()(value.target_triplet());
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct triplet;
|
||||
struct Triplet;
|
||||
|
||||
struct dependency
|
||||
{
|
||||
@ -28,7 +28,7 @@ namespace vcpkg
|
||||
std::vector<dependency> depends;
|
||||
};
|
||||
|
||||
std::vector<std::string> filter_dependencies(const std::vector<vcpkg::dependency>& deps, const triplet& t);
|
||||
std::vector<std::string> filter_dependencies(const std::vector<vcpkg::dependency>& deps, const Triplet& t);
|
||||
|
||||
std::vector<vcpkg::dependency> expand_qualified_dependencies(const std::vector<std::string>& depends);
|
||||
std::vector<std::string> parse_depends(const std::string& depends_string);
|
||||
|
@ -18,9 +18,9 @@ namespace vcpkg
|
||||
{
|
||||
return find(spec.name(), spec.target_triplet());
|
||||
}
|
||||
const_iterator find(const std::string& name, const triplet& target_triplet) const;
|
||||
iterator find(const std::string& name, const triplet& target_triplet);
|
||||
const_iterator find_installed(const std::string& name, const triplet& target_triplet) const;
|
||||
const_iterator find(const std::string& name, const Triplet& target_triplet) const;
|
||||
iterator find(const std::string& name, const Triplet& target_triplet);
|
||||
const_iterator find_installed(const std::string& name, const Triplet& target_triplet) const;
|
||||
|
||||
iterator insert(std::unique_ptr<StatusParagraph>);
|
||||
|
||||
|
@ -4,15 +4,15 @@
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
struct triplet
|
||||
struct Triplet
|
||||
{
|
||||
static triplet from_canonical_name(const std::string& triplet_as_string);
|
||||
static Triplet from_canonical_name(const std::string& triplet_as_string);
|
||||
|
||||
static const triplet X86_WINDOWS;
|
||||
static const triplet X64_WINDOWS;
|
||||
static const triplet X86_UWP;
|
||||
static const triplet X64_UWP;
|
||||
static const triplet ARM_UWP;
|
||||
static const Triplet X86_WINDOWS;
|
||||
static const Triplet X64_WINDOWS;
|
||||
static const Triplet X86_UWP;
|
||||
static const Triplet X64_UWP;
|
||||
static const Triplet ARM_UWP;
|
||||
|
||||
const std::string& canonical_name() const;
|
||||
|
||||
@ -24,23 +24,23 @@ namespace vcpkg
|
||||
std::string m_canonical_name;
|
||||
};
|
||||
|
||||
bool operator==(const triplet& left, const triplet& right);
|
||||
bool operator==(const Triplet& left, const Triplet& right);
|
||||
|
||||
bool operator!=(const triplet& left, const triplet& right);
|
||||
bool operator!=(const Triplet& left, const Triplet& right);
|
||||
|
||||
std::string to_string(const triplet& spec);
|
||||
std::string to_string(const Triplet& spec);
|
||||
|
||||
std::string to_printf_arg(const triplet& spec);
|
||||
std::string to_printf_arg(const Triplet& spec);
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const triplet& spec);
|
||||
std::ostream& operator<<(std::ostream& os, const Triplet& spec);
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<vcpkg::triplet>
|
||||
struct hash<vcpkg::Triplet>
|
||||
{
|
||||
size_t operator()(const vcpkg::triplet& t) const
|
||||
size_t operator()(const vcpkg::Triplet& t) const
|
||||
{
|
||||
std::hash<std::string> hasher;
|
||||
size_t hash = 17;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
using command_type_a = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
using command_type_a = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet);
|
||||
using command_type_b = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
|
||||
using command_type_c = void(*)(const vcpkg_cmd_arguments& args);
|
||||
|
||||
@ -29,32 +29,32 @@ namespace vcpkg::Commands
|
||||
std::string create_error_message(const BuildResult build_result, const PackageSpec& spec);
|
||||
std::string create_user_troubleshooting_message(const PackageSpec& spec);
|
||||
|
||||
std::wstring make_build_env_cmd(const triplet& target_triplet, const toolset_t& toolset);
|
||||
std::wstring make_build_env_cmd(const Triplet& target_triplet, const toolset_t& toolset);
|
||||
|
||||
BuildResult build_package(const SourceParagraph& source_paragraph, const PackageSpec& spec, const vcpkg_paths& paths, const fs::path& port_dir, const StatusParagraphs& status_db);
|
||||
void perform_and_exit(const PackageSpec& spec, const fs::path& port_dir, const std::unordered_set<std::string>& options, const vcpkg_paths& paths);
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet);
|
||||
}
|
||||
|
||||
namespace BuildExternal
|
||||
{
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet);
|
||||
}
|
||||
|
||||
namespace Install
|
||||
{
|
||||
void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs* status_db);
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet);
|
||||
}
|
||||
|
||||
namespace CI
|
||||
{
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet);
|
||||
}
|
||||
|
||||
namespace Remove
|
||||
{
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet);
|
||||
}
|
||||
|
||||
namespace Update
|
||||
@ -73,7 +73,7 @@ namespace vcpkg::Commands
|
||||
|
||||
namespace Env
|
||||
{
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_triplet);
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_triplet);
|
||||
}
|
||||
|
||||
namespace Create
|
||||
|
@ -7,8 +7,8 @@ namespace vcpkg::Input
|
||||
{
|
||||
PackageSpec check_and_get_package_spec(
|
||||
const std::string& package_spec_as_string,
|
||||
const triplet& default_target_triplet,
|
||||
const Triplet& default_target_triplet,
|
||||
CStringView example_text);
|
||||
|
||||
void check_triplet(const triplet& t, const vcpkg_paths& paths);
|
||||
void check_triplet(const Triplet& t, const vcpkg_paths& paths);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace vcpkg
|
||||
fs::path build_info_file_path(const PackageSpec& spec) const;
|
||||
fs::path listfile_path(const BinaryParagraph& pgh) const;
|
||||
|
||||
bool is_valid_triplet(const triplet& t) const;
|
||||
bool is_valid_triplet(const Triplet& t) const;
|
||||
|
||||
fs::path root;
|
||||
fs::path packages;
|
||||
|
@ -29,7 +29,7 @@ namespace vcpkg
|
||||
{
|
||||
const std::string name = details::remove_required_field(&fields, BinaryParagraphRequiredField::PACKAGE);
|
||||
const std::string architecture = details::remove_required_field(&fields, BinaryParagraphRequiredField::ARCHITECTURE);
|
||||
const triplet target_triplet = triplet::from_canonical_name(architecture);
|
||||
const Triplet target_triplet = Triplet::from_canonical_name(architecture);
|
||||
|
||||
this->spec = PackageSpec::from_name_and_triplet(name, target_triplet).value_or_exit(VCPKG_LINE_INFO);
|
||||
this->version = details::remove_required_field(&fields, BinaryParagraphRequiredField::VERSION);
|
||||
@ -44,7 +44,7 @@ namespace vcpkg
|
||||
this->depends = parse_depends(deps);
|
||||
}
|
||||
|
||||
BinaryParagraph::BinaryParagraph(const SourceParagraph& spgh, const triplet& target_triplet)
|
||||
BinaryParagraph::BinaryParagraph(const SourceParagraph& spgh, const Triplet& target_triplet)
|
||||
{
|
||||
this->spec = PackageSpec::from_name_and_triplet(spgh.name, target_triplet).value_or_exit(VCPKG_LINE_INFO);
|
||||
this->version = spgh.version;
|
||||
|
@ -8,7 +8,7 @@ namespace vcpkg
|
||||
return (c == '-') || isdigit(c) || (isalpha(c) && islower(c));
|
||||
}
|
||||
|
||||
expected<PackageSpec> PackageSpec::from_string(const std::string& spec_as_string, const triplet& default_target_triplet)
|
||||
expected<PackageSpec> PackageSpec::from_string(const std::string& spec_as_string, const Triplet& default_target_triplet)
|
||||
{
|
||||
auto pos = spec_as_string.find(':');
|
||||
if (pos == std::string::npos)
|
||||
@ -23,11 +23,11 @@ namespace vcpkg
|
||||
}
|
||||
|
||||
const std::string name = spec_as_string.substr(0, pos);
|
||||
const triplet target_triplet = triplet::from_canonical_name(spec_as_string.substr(pos + 1));
|
||||
const Triplet target_triplet = Triplet::from_canonical_name(spec_as_string.substr(pos + 1));
|
||||
return from_name_and_triplet(name, target_triplet);
|
||||
}
|
||||
|
||||
expected<PackageSpec> PackageSpec::from_name_and_triplet(const std::string& name, const triplet& target_triplet)
|
||||
expected<PackageSpec> PackageSpec::from_name_and_triplet(const std::string& name, const Triplet& target_triplet)
|
||||
{
|
||||
if (std::find_if_not(name.cbegin(), name.cend(), is_valid_package_spec_char) != name.end())
|
||||
{
|
||||
@ -45,7 +45,7 @@ namespace vcpkg
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
const triplet& PackageSpec::target_triplet() const
|
||||
const Triplet& PackageSpec::target_triplet() const
|
||||
{
|
||||
return this->m_target_triplet;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "vcpkglib_helpers.h"
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkg_Maps.h"
|
||||
#include "triplet.h"
|
||||
#include "Triplet.h"
|
||||
#include "vcpkg_Checks.h"
|
||||
|
||||
namespace vcpkg
|
||||
@ -125,7 +125,7 @@ namespace vcpkg
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<std::string> filter_dependencies(const std::vector<vcpkg::dependency>& deps, const triplet& t)
|
||||
std::vector<std::string> filter_dependencies(const std::vector<vcpkg::dependency>& deps, const Triplet& t)
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
for (auto&& dep : deps)
|
||||
|
@ -11,7 +11,7 @@ namespace vcpkg
|
||||
{
|
||||
};
|
||||
|
||||
StatusParagraphs::const_iterator StatusParagraphs::find(const std::string& name, const triplet& target_triplet) const
|
||||
StatusParagraphs::const_iterator StatusParagraphs::find(const std::string& name, const Triplet& target_triplet) const
|
||||
{
|
||||
return std::find_if(begin(), end(), [&](const std::unique_ptr<StatusParagraph>& pgh)
|
||||
{
|
||||
@ -20,7 +20,7 @@ namespace vcpkg
|
||||
});
|
||||
}
|
||||
|
||||
StatusParagraphs::iterator StatusParagraphs::find(const std::string& name, const triplet& target_triplet)
|
||||
StatusParagraphs::iterator StatusParagraphs::find(const std::string& name, const Triplet& target_triplet)
|
||||
{
|
||||
return std::find_if(begin(), end(), [&](const std::unique_ptr<StatusParagraph>& pgh)
|
||||
{
|
||||
@ -29,7 +29,7 @@ namespace vcpkg
|
||||
});
|
||||
}
|
||||
|
||||
StatusParagraphs::const_iterator StatusParagraphs::find_installed(const std::string& name, const triplet& target_triplet) const
|
||||
StatusParagraphs::const_iterator StatusParagraphs::find_installed(const std::string& name, const Triplet& target_triplet) const
|
||||
{
|
||||
const const_iterator it = find(name, target_triplet);
|
||||
if (it != end() && (*it)->want == want_t::install)
|
||||
|
@ -18,14 +18,14 @@ namespace vcpkg::Commands::Build
|
||||
|
||||
static const std::string OPTION_CHECKS_ONLY = "--checks-only";
|
||||
|
||||
static void create_binary_control_file(const vcpkg_paths& paths, const SourceParagraph& source_paragraph, const triplet& target_triplet)
|
||||
static void create_binary_control_file(const vcpkg_paths& paths, const SourceParagraph& source_paragraph, const Triplet& target_triplet)
|
||||
{
|
||||
const BinaryParagraph bpgh = BinaryParagraph(source_paragraph, target_triplet);
|
||||
const fs::path binary_control_file = paths.packages / bpgh.dir() / "CONTROL";
|
||||
std::ofstream(binary_control_file) << bpgh;
|
||||
}
|
||||
|
||||
std::wstring make_build_env_cmd(const triplet& target_triplet, const toolset_t& toolset)
|
||||
std::wstring make_build_env_cmd(const Triplet& target_triplet, const toolset_t& toolset)
|
||||
{
|
||||
return Strings::wformat(LR"("%s" %s >nul 2>&1)",
|
||||
toolset.vcvarsall.native(),
|
||||
@ -36,7 +36,7 @@ namespace vcpkg::Commands::Build
|
||||
{
|
||||
Checks::check_exit(VCPKG_LINE_INFO, spec.name() == source_paragraph.name, "inconsistent arguments to build_package()");
|
||||
|
||||
const triplet& target_triplet = spec.target_triplet();
|
||||
const Triplet& target_triplet = spec.target_triplet();
|
||||
for (auto&& dep : filter_dependencies(source_paragraph.depends, target_triplet))
|
||||
{
|
||||
if (status_db.find_installed(dep, target_triplet) == status_db.end())
|
||||
@ -174,7 +174,7 @@ namespace vcpkg::Commands::Build
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet)
|
||||
{
|
||||
static const std::string example = Commands::Help::create_example_string("build zlib:x64-windows");
|
||||
args.check_exact_arg_count(1, example); // Build only takes a single package and all dependencies must already be installed
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
namespace vcpkg::Commands::BuildExternal
|
||||
{
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet)
|
||||
{
|
||||
static const std::string example = Commands::Help::create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)");
|
||||
args.check_exact_arg_count(2, example);
|
||||
|
@ -14,7 +14,7 @@ namespace vcpkg::Commands::CI
|
||||
using Dependencies::install_plan_type;
|
||||
using Build::BuildResult;
|
||||
|
||||
static std::vector<PackageSpec> load_all_package_specs(const fs::path& ports_directory, const triplet& target_triplet)
|
||||
static std::vector<PackageSpec> load_all_package_specs(const fs::path& ports_directory, const Triplet& target_triplet)
|
||||
{
|
||||
std::vector<SourceParagraph> ports = Paragraphs::load_all_ports(ports_directory);
|
||||
std::vector<PackageSpec> specs;
|
||||
@ -26,11 +26,11 @@ namespace vcpkg::Commands::CI
|
||||
return specs;
|
||||
}
|
||||
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet)
|
||||
{
|
||||
static const std::string example = Commands::Help::create_example_string("ci x64-windows");
|
||||
args.check_max_arg_count(1, example);
|
||||
const triplet target_triplet = args.command_arguments.size() == 1 ? triplet::from_canonical_name(args.command_arguments.at(0)) : default_target_triplet;
|
||||
const Triplet target_triplet = args.command_arguments.size() == 1 ? Triplet::from_canonical_name(args.command_arguments.at(0)) : default_target_triplet;
|
||||
Input::check_triplet(target_triplet, paths);
|
||||
args.check_and_get_optional_command_arguments({});
|
||||
const std::vector<PackageSpec> specs = load_all_package_specs(paths.ports, target_triplet);
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
namespace vcpkg::Commands::Env
|
||||
{
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_triplet)
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_triplet)
|
||||
{
|
||||
static const std::string example = Commands::Help::create_example_string(R"(env --triplet x64-windows)");
|
||||
static const std::string example = Commands::Help::create_example_string(R"(env --Triplet x64-windows)");
|
||||
args.check_exact_arg_count(0, example);
|
||||
args.check_and_get_optional_command_arguments({});
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace vcpkg::Commands::Install
|
||||
const fs::path package_prefix_path = paths.package_dir(bpgh.spec);
|
||||
const size_t prefix_length = package_prefix_path.native().size();
|
||||
|
||||
const triplet& target_triplet = bpgh.spec.target_triplet();
|
||||
const Triplet& target_triplet = bpgh.spec.target_triplet();
|
||||
const std::string& target_triplet_as_string = target_triplet.canonical_name();
|
||||
std::error_code ec;
|
||||
fs::create_directory(paths.installed / target_triplet_as_string, ec);
|
||||
@ -96,7 +96,7 @@ namespace vcpkg::Commands::Install
|
||||
}
|
||||
};
|
||||
|
||||
static std::vector<std::string> extract_files_in_triplet(const std::vector<StatusParagraph_and_associated_files>& pgh_and_files, const triplet& triplet)
|
||||
static std::vector<std::string> extract_files_in_triplet(const std::vector<StatusParagraph_and_associated_files>& pgh_and_files, const Triplet& triplet)
|
||||
{
|
||||
std::vector<std::string> output;
|
||||
for (const StatusParagraph_and_associated_files& t : pgh_and_files)
|
||||
@ -127,7 +127,7 @@ namespace vcpkg::Commands::Install
|
||||
return SortedVector<std::string>(std::move(package_files));
|
||||
}
|
||||
|
||||
static SortedVector<std::string> build_list_of_installed_files(const std::vector<StatusParagraph_and_associated_files>& pgh_and_files, const triplet& triplet)
|
||||
static SortedVector<std::string> build_list_of_installed_files(const std::vector<StatusParagraph_and_associated_files>& pgh_and_files, const Triplet& triplet)
|
||||
{
|
||||
std::vector<std::string> installed_files = extract_files_in_triplet(pgh_and_files, triplet);
|
||||
const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash
|
||||
@ -139,7 +139,7 @@ namespace vcpkg::Commands::Install
|
||||
void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs* status_db)
|
||||
{
|
||||
const fs::path package_dir = paths.package_dir(binary_paragraph.spec);
|
||||
const triplet& triplet = binary_paragraph.spec.target_triplet();
|
||||
const Triplet& triplet = binary_paragraph.spec.target_triplet();
|
||||
const std::vector<StatusParagraph_and_associated_files> pgh_and_files = get_installed_files(paths, *status_db);
|
||||
|
||||
const SortedVector<std::string> package_files = build_list_of_package_files(package_dir);
|
||||
@ -183,7 +183,7 @@ namespace vcpkg::Commands::Install
|
||||
status_db->insert(std::make_unique<StatusParagraph>(spgh));
|
||||
}
|
||||
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet)
|
||||
{
|
||||
// input sanitization
|
||||
static const std::string example = Commands::Help::create_example_string("install zlib zlib:x64-windows curl boost");
|
||||
|
@ -162,7 +162,7 @@ namespace vcpkg::Commands::Remove
|
||||
}
|
||||
}
|
||||
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_triplet)
|
||||
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet)
|
||||
{
|
||||
static const std::string OPTION_PURGE = "--purge";
|
||||
static const std::string OPTION_NO_PURGE = "--no-purge";
|
||||
@ -173,7 +173,7 @@ namespace vcpkg::Commands::Remove
|
||||
const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({ OPTION_PURGE, OPTION_NO_PURGE, OPTION_RECURSE, OPTION_DRY_RUN, OPTION_OUTDATED });
|
||||
|
||||
StatusParagraphs status_db = database_load_check(paths);
|
||||
std::vector<package_spec> specs;
|
||||
std::vector<PackageSpec> specs;
|
||||
if (options.find(OPTION_OUTDATED) != options.cend())
|
||||
{
|
||||
args.check_exact_arg_count(0, example);
|
||||
@ -182,7 +182,7 @@ namespace vcpkg::Commands::Remove
|
||||
else
|
||||
{
|
||||
args.check_min_arg_count(1, example);
|
||||
specs = Util::fmap(args.command_arguments, [&](auto&& arg) { return Input::check_and_get_package_spec(arg, default_triplet, example); });
|
||||
specs = Util::fmap(args.command_arguments, [&](auto&& arg) { return Input::check_and_get_package_spec(arg, default_target_triplet, example); });
|
||||
for (auto&& spec : specs)
|
||||
Input::check_triplet(spec.target_triplet(), paths);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "CppUnitTest.h"
|
||||
#include "SourceParagraph.h"
|
||||
#include "triplet.h"
|
||||
#include "Triplet.h"
|
||||
|
||||
#pragma comment(lib,"version")
|
||||
#pragma comment(lib,"winhttp")
|
||||
@ -25,12 +25,12 @@ namespace UnitTest1
|
||||
TEST_METHOD(filter_depends)
|
||||
{
|
||||
auto deps = expand_qualified_dependencies(parse_depends("libA [windows], libB, libC [uwp]"));
|
||||
auto v = filter_dependencies(deps, triplet::X64_WINDOWS);
|
||||
auto v = filter_dependencies(deps, Triplet::X64_WINDOWS);
|
||||
Assert::AreEqual(size_t(2), v.size());
|
||||
Assert::AreEqual("libA", v[0].c_str());
|
||||
Assert::AreEqual("libB", v[1].c_str());
|
||||
|
||||
auto v2 = filter_dependencies(deps, triplet::ARM_UWP);
|
||||
auto v2 = filter_dependencies(deps, Triplet::ARM_UWP);
|
||||
Assert::AreEqual(size_t(2), v.size());
|
||||
Assert::AreEqual("libB", v2[0].c_str());
|
||||
Assert::AreEqual("libC", v2[1].c_str());
|
||||
|
@ -350,23 +350,23 @@ namespace UnitTest1
|
||||
|
||||
TEST_METHOD(package_spec_parse)
|
||||
{
|
||||
vcpkg::expected<vcpkg::PackageSpec> spec = vcpkg::PackageSpec::from_string("zlib", vcpkg::triplet::X86_WINDOWS);
|
||||
vcpkg::expected<vcpkg::PackageSpec> spec = vcpkg::PackageSpec::from_string("zlib", vcpkg::Triplet::X86_WINDOWS);
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, vcpkg::to_package_spec_parse_result(spec.error_code()));
|
||||
Assert::AreEqual("zlib", spec.get()->name().c_str());
|
||||
Assert::AreEqual(vcpkg::triplet::X86_WINDOWS.canonical_name(), spec.get()->target_triplet().canonical_name());
|
||||
Assert::AreEqual(vcpkg::Triplet::X86_WINDOWS.canonical_name(), spec.get()->target_triplet().canonical_name());
|
||||
}
|
||||
|
||||
TEST_METHOD(package_spec_parse_with_arch)
|
||||
{
|
||||
vcpkg::expected<vcpkg::PackageSpec> spec = vcpkg::PackageSpec::from_string("zlib:x64-uwp", vcpkg::triplet::X86_WINDOWS);
|
||||
vcpkg::expected<vcpkg::PackageSpec> spec = vcpkg::PackageSpec::from_string("zlib:x64-uwp", vcpkg::Triplet::X86_WINDOWS);
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::SUCCESS, vcpkg::to_package_spec_parse_result(spec.error_code()));
|
||||
Assert::AreEqual("zlib", spec.get()->name().c_str());
|
||||
Assert::AreEqual(vcpkg::triplet::X64_UWP.canonical_name(), spec.get()->target_triplet().canonical_name());
|
||||
Assert::AreEqual(vcpkg::Triplet::X64_UWP.canonical_name(), spec.get()->target_triplet().canonical_name());
|
||||
}
|
||||
|
||||
TEST_METHOD(package_spec_parse_with_multiple_colon)
|
||||
{
|
||||
auto ec = vcpkg::PackageSpec::from_string("zlib:x86-uwp:", vcpkg::triplet::X86_WINDOWS).error_code();
|
||||
auto ec = vcpkg::PackageSpec::from_string("zlib:x86-uwp:", vcpkg::Triplet::X86_WINDOWS).error_code();
|
||||
Assert::AreEqual(vcpkg::PackageSpecParseResult::TOO_MANY_COLONS, vcpkg::to_package_spec_parse_result(ec));
|
||||
}
|
||||
|
||||
|
@ -1,64 +1,64 @@
|
||||
#include "pch.h"
|
||||
#include "triplet.h"
|
||||
#include "Triplet.h"
|
||||
#include "vcpkg_Checks.h"
|
||||
#include "vcpkg_Strings.h"
|
||||
|
||||
namespace vcpkg
|
||||
{
|
||||
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");
|
||||
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)
|
||||
std::string to_string(const Triplet& t)
|
||||
{
|
||||
return t.canonical_name();
|
||||
}
|
||||
|
||||
std::string to_printf_arg(const triplet& t)
|
||||
std::string to_printf_arg(const Triplet& t)
|
||||
{
|
||||
return to_string(t);
|
||||
}
|
||||
|
||||
bool operator==(const triplet& left, const triplet& right)
|
||||
bool operator==(const Triplet& left, const Triplet& right)
|
||||
{
|
||||
return left.canonical_name() == right.canonical_name();
|
||||
}
|
||||
|
||||
bool operator!=(const triplet& left, const triplet& right)
|
||||
bool operator!=(const Triplet& left, const Triplet& right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const triplet& t)
|
||||
std::ostream& operator<<(std::ostream& os, const Triplet& t)
|
||||
{
|
||||
return os << to_string(t);
|
||||
}
|
||||
|
||||
triplet triplet::from_canonical_name(const std::string& triplet_as_string)
|
||||
Triplet Triplet::from_canonical_name(const std::string& triplet_as_string)
|
||||
{
|
||||
const std::string s(Strings::ascii_to_lowercase(triplet_as_string));
|
||||
auto it = std::find(s.cbegin(), s.cend(), '-');
|
||||
Checks::check_exit(VCPKG_LINE_INFO, it != s.cend(), "Invalid triplet: %s", triplet_as_string);
|
||||
|
||||
triplet t;
|
||||
Triplet t;
|
||||
t.m_canonical_name = s;
|
||||
return t;
|
||||
}
|
||||
|
||||
const std::string& triplet::canonical_name() const
|
||||
const std::string& Triplet::canonical_name() const
|
||||
{
|
||||
return this->m_canonical_name;
|
||||
}
|
||||
|
||||
std::string triplet::architecture() const
|
||||
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);
|
||||
}
|
||||
|
||||
std::string triplet::system() const
|
||||
std::string Triplet::system() const
|
||||
{
|
||||
auto it = std::find(this->m_canonical_name.cbegin(), this->m_canonical_name.cend(), '-');
|
||||
return std::string(it + 1, this->m_canonical_name.cend());
|
||||
|
@ -69,21 +69,21 @@ static void inner(const vcpkg_cmd_arguments& args)
|
||||
return command_function(args, paths);
|
||||
}
|
||||
|
||||
triplet default_target_triplet;
|
||||
Triplet default_target_triplet;
|
||||
if (args.target_triplet != nullptr)
|
||||
{
|
||||
default_target_triplet = triplet::from_canonical_name(*args.target_triplet);
|
||||
default_target_triplet = Triplet::from_canonical_name(*args.target_triplet);
|
||||
}
|
||||
else
|
||||
{
|
||||
const optional<std::wstring> vcpkg_default_triplet_env = System::get_environmental_variable(L"VCPKG_DEFAULT_TRIPLET");
|
||||
if (auto v = vcpkg_default_triplet_env.get())
|
||||
{
|
||||
default_target_triplet = triplet::from_canonical_name(Strings::utf16_to_utf8(*v));
|
||||
default_target_triplet = Triplet::from_canonical_name(Strings::utf16_to_utf8(*v));
|
||||
}
|
||||
else
|
||||
{
|
||||
default_target_triplet = triplet::X86_WINDOWS;
|
||||
default_target_triplet = Triplet::X86_WINDOWS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
namespace vcpkg::Input
|
||||
{
|
||||
PackageSpec check_and_get_package_spec(const std::string& package_spec_as_string, const triplet& default_target_triplet, CStringView example_text)
|
||||
PackageSpec check_and_get_package_spec(const std::string& package_spec_as_string, const Triplet& default_target_triplet, CStringView example_text)
|
||||
{
|
||||
const std::string as_lowercase = Strings::ascii_to_lowercase(package_spec_as_string);
|
||||
expected<PackageSpec> expected_spec = PackageSpec::from_string(as_lowercase, default_target_triplet);
|
||||
@ -21,7 +21,7 @@ namespace vcpkg::Input
|
||||
Checks::exit_fail(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
void check_triplet(const triplet& t, const vcpkg_paths& paths)
|
||||
void check_triplet(const Triplet& t, const vcpkg_paths& paths)
|
||||
{
|
||||
if (!paths.is_valid_triplet(t))
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ namespace vcpkg
|
||||
return this->vcpkg_dir_info / (pgh.fullstem() + ".list");
|
||||
}
|
||||
|
||||
bool vcpkg_paths::is_valid_triplet(const triplet& t) const
|
||||
bool vcpkg_paths::is_valid_triplet(const Triplet& t) const
|
||||
{
|
||||
auto it = fs::directory_iterator(this->triplets);
|
||||
for (; it != fs::directory_iterator(); ++it)
|
||||
|
Loading…
x
Reference in New Issue
Block a user