mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-19 05:43:03 +08:00
Introduce Command namespace. Refactoring
This commit is contained in:
parent
4c51e65d50
commit
df2a05e854
@ -3,21 +3,17 @@
|
||||
#include "vcpkg_cmd_arguments.h"
|
||||
#include "vcpkg_paths.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
//
|
||||
namespace Commands::details
|
||||
{
|
||||
void build_internal(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir);
|
||||
}
|
||||
|
||||
extern const char*const INTEGRATE_COMMAND_HELPSTRING;
|
||||
|
||||
void print_usage();
|
||||
void print_example(const std::string& command_and_arguments);
|
||||
std::string create_example_string(const std::string& command_and_arguments);
|
||||
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);
|
||||
|
||||
void update_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
|
||||
|
||||
void build_internal(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir);
|
||||
void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
void install_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);
|
||||
@ -30,7 +26,6 @@ namespace vcpkg
|
||||
void list_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
|
||||
void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
|
||||
void owns_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
|
||||
void internal_test_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
|
||||
|
||||
void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths);
|
||||
|
||||
@ -45,10 +40,6 @@ namespace vcpkg
|
||||
void contact_command(const vcpkg_cmd_arguments& args);
|
||||
void hash_command(const vcpkg_cmd_arguments& args);
|
||||
|
||||
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);
|
||||
|
||||
template <class T>
|
||||
struct package_name_and_function
|
||||
{
|
||||
@ -61,7 +52,7 @@ namespace vcpkg
|
||||
const std::vector<package_name_and_function<command_type_c>>& get_available_commands_type_c();
|
||||
|
||||
template <typename T>
|
||||
T find_command(const std::string& command_name, const std::vector<package_name_and_function<T>> available_commands)
|
||||
T find(const std::string& command_name, const std::vector<package_name_and_function<T>> available_commands)
|
||||
{
|
||||
for (const package_name_and_function<T>& cmd : available_commands)
|
||||
{
|
||||
@ -75,3 +66,12 @@ namespace vcpkg
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
namespace vcpkg::Commands::Helpers
|
||||
{
|
||||
void print_usage();
|
||||
|
||||
void print_example(const std::string& command_and_arguments);
|
||||
|
||||
std::string create_example_string(const std::string& command_and_arguments);
|
||||
}
|
||||
|
44
toolsrc/src/commands_available_commands.cpp
Normal file
44
toolsrc/src/commands_available_commands.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "vcpkg_Commands.h"
|
||||
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
const std::vector<package_name_and_function<command_type_a>>& get_available_commands_type_a()
|
||||
{
|
||||
static std::vector<package_name_and_function<command_type_a>> t = {
|
||||
{"install", install_command},
|
||||
{"remove", remove_command},
|
||||
{"build", build_command},
|
||||
{"build_external", build_external_command}
|
||||
};
|
||||
return t;
|
||||
}
|
||||
|
||||
const std::vector<package_name_and_function<command_type_b>>& get_available_commands_type_b()
|
||||
{
|
||||
static std::vector<package_name_and_function<command_type_b>> t = {
|
||||
{"/?", help_command},
|
||||
{"help", help_command},
|
||||
{"search", search_command},
|
||||
{"list", list_command},
|
||||
{"integrate", integrate_command},
|
||||
{"owns", owns_command},
|
||||
{"update", update_command},
|
||||
{"edit", edit_command},
|
||||
{"create", create_command},
|
||||
{"import", import_command},
|
||||
{"cache", cache_command},
|
||||
{"portsdiff", portsdiff_command}
|
||||
};
|
||||
return t;
|
||||
}
|
||||
|
||||
const std::vector<package_name_and_function<command_type_c>>& get_available_commands_type_c()
|
||||
{
|
||||
static std::vector<package_name_and_function<command_type_c>> t = {
|
||||
{"version", &version_command},
|
||||
{"contact", &contact_command},
|
||||
{"hash", &hash_command},
|
||||
};
|
||||
return t;
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
#include "vcpkg_info.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
using Dependencies::package_spec_with_install_plan;
|
||||
using Dependencies::install_plan_type;
|
||||
@ -24,53 +24,51 @@ namespace vcpkg
|
||||
std::ofstream(binary_control_file) << bpgh;
|
||||
}
|
||||
|
||||
namespace Commands::details
|
||||
void build_internal(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir)
|
||||
{
|
||||
void build_internal(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir)
|
||||
Checks::check_exit(spec.name() == source_paragraph.name, "inconsistent arguments to build_internal()");
|
||||
const triplet& target_triplet = spec.target_triplet();
|
||||
|
||||
const fs::path ports_cmake_script_path = paths.ports_cmake;
|
||||
const std::wstring command = Strings::wformat(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")",
|
||||
Strings::utf8_to_utf16(target_triplet.architecture()),
|
||||
Strings::utf8_to_utf16(source_paragraph.name),
|
||||
Strings::utf8_to_utf16(target_triplet.canonical_name()),
|
||||
port_dir.generic_wstring(),
|
||||
ports_cmake_script_path.generic_wstring());
|
||||
|
||||
System::Stopwatch2 timer;
|
||||
timer.start();
|
||||
int return_code = System::cmd_execute(command);
|
||||
timer.stop();
|
||||
TrackMetric("buildtimeus-" + to_string(spec), timer.microseconds());
|
||||
|
||||
if (return_code != 0)
|
||||
{
|
||||
Checks::check_exit(spec.name() == source_paragraph.name, "inconsistent arguments to build_internal()");
|
||||
const triplet& target_triplet = spec.target_triplet();
|
||||
|
||||
const fs::path ports_cmake_script_path = paths.ports_cmake;
|
||||
const std::wstring command = Strings::wformat(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")",
|
||||
Strings::utf8_to_utf16(target_triplet.architecture()),
|
||||
Strings::utf8_to_utf16(source_paragraph.name),
|
||||
Strings::utf8_to_utf16(target_triplet.canonical_name()),
|
||||
port_dir.generic_wstring(),
|
||||
ports_cmake_script_path.generic_wstring());
|
||||
|
||||
System::Stopwatch2 timer;
|
||||
timer.start();
|
||||
int return_code = System::cmd_execute(command);
|
||||
timer.stop();
|
||||
TrackMetric("buildtimeus-" + to_string(spec), timer.microseconds());
|
||||
|
||||
if (return_code != 0)
|
||||
{
|
||||
System::println(System::color::error, "Error: building package %s failed", to_string(spec));
|
||||
System::println("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n"
|
||||
"submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n"
|
||||
" Package: %s\n"
|
||||
" Vcpkg version: %s\n"
|
||||
"\n"
|
||||
"Additionally, attach any relevant sections from the log files above."
|
||||
, to_string(spec), Info::version());
|
||||
TrackProperty("error", "build failed");
|
||||
TrackProperty("build_error", to_string(spec));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
PostBuildLint::perform_all_checks(spec, paths);
|
||||
|
||||
create_binary_control_file(paths, source_paragraph, target_triplet);
|
||||
|
||||
// const fs::path port_buildtrees_dir = paths.buildtrees / spec.name;
|
||||
// delete_directory(port_buildtrees_dir);
|
||||
System::println(System::color::error, "Error: building package %s failed", to_string(spec));
|
||||
System::println("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n"
|
||||
"submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n"
|
||||
" Package: %s\n"
|
||||
" Vcpkg version: %s\n"
|
||||
"\n"
|
||||
"Additionally, attach any relevant sections from the log files above."
|
||||
, to_string(spec), Info::version());
|
||||
TrackProperty("error", "build failed");
|
||||
TrackProperty("build_error", to_string(spec));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
PostBuildLint::perform_all_checks(spec, paths);
|
||||
|
||||
create_binary_control_file(paths, source_paragraph, target_triplet);
|
||||
|
||||
// const fs::path port_buildtrees_dir = paths.buildtrees / spec.name;
|
||||
// delete_directory(port_buildtrees_dir);
|
||||
}
|
||||
|
||||
void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
{
|
||||
static const std::string example = create_example_string("build zlib:x64-windows");
|
||||
static const std::string example = Helpers::create_example_string("build zlib:x64-windows");
|
||||
|
||||
// Installing multiple packages leads to unintuitive behavior if one of them depends on another.
|
||||
// Allowing only 1 package for now.
|
||||
@ -124,7 +122,7 @@ namespace vcpkg
|
||||
}
|
||||
|
||||
Environment::ensure_utilities_on_path(paths);
|
||||
Commands::details::build_internal(spgh, spec, paths, paths.port_dir(spec));
|
||||
Commands::build_internal(spgh, spec, paths, paths.port_dir(spec));
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@
|
||||
#include "vcpkg_Input.h"
|
||||
#include "vcpkg.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
{
|
||||
static const std::string example = create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)");
|
||||
static const std::string example = Commands::Helpers::create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)");
|
||||
args.check_exact_arg_count(2, example);
|
||||
|
||||
expected<package_spec> maybe_current_spec = package_spec::from_string(args.command_arguments[0], default_target_triplet);
|
||||
@ -20,13 +20,13 @@ namespace vcpkg
|
||||
const expected<SourceParagraph> maybe_spgh = try_load_port(port_dir);
|
||||
if (auto spgh = maybe_spgh.get())
|
||||
{
|
||||
Commands::details::build_internal(*spgh, *spec, paths, port_dir);
|
||||
Commands::build_internal(*spgh, *spec, paths, port_dir);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
System::println(System::color::error, "Error: %s: %s", maybe_current_spec.error_code().message(), args.command_arguments[0]);
|
||||
print_example(Strings::format("%s zlib:x64-windows", args.command));
|
||||
Commands::Helpers::print_example(Strings::format("%s zlib:x64-windows", args.command));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "Paragraphs.h"
|
||||
#include "BinaryParagraph.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
static std::vector<BinaryParagraph> read_all_binary_paragraphs(const vcpkg_paths& paths)
|
||||
{
|
||||
@ -37,7 +37,7 @@ namespace vcpkg
|
||||
void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
static const std::string example = Strings::format(
|
||||
"The argument should be a substring to search for, or no argument to display all cached libraries.\n%s", create_example_string("cache png"));
|
||||
"The argument should be a substring to search for, or no argument to display all cached libraries.\n%s", Commands::Helpers::create_example_string("cache png"));
|
||||
args.check_max_arg_count(1, example);
|
||||
|
||||
const std::vector<BinaryParagraph> binary_paragraphs = read_all_binary_paragraphs(paths);
|
||||
|
@ -4,11 +4,11 @@
|
||||
#include "vcpkg_Files.h"
|
||||
#include "vcpkg_Input.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
static const std::string example = create_example_string(R"###(create zlib2 http://zlib.net/zlib128.zip "zlib128-2.zip")###");
|
||||
static const std::string example = Commands::Helpers::create_example_string(R"###(create zlib2 http://zlib.net/zlib128.zip "zlib128-2.zip")###");
|
||||
args.check_max_arg_count(3, example);
|
||||
args.check_min_arg_count(2, example);
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkg_Input.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
void edit_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
static const std::string example = create_example_string("edit zlib");
|
||||
static const std::string example = Commands::Helpers::create_example_string("edit zlib");
|
||||
args.check_exact_arg_count(1, example);
|
||||
const std::string port_name = args.command_arguments.at(0);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "vcpkg_Commands.h"
|
||||
#include "vcpkg_System.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
static void do_file_hash(fs::path const& path, std::wstring const& hashType)
|
||||
{
|
||||
@ -26,7 +26,7 @@ namespace vcpkg
|
||||
void hash_command(const vcpkg_cmd_arguments& args)
|
||||
{
|
||||
static const std::string example = Strings::format(
|
||||
"The argument should be a file path\n%s", create_example_string("hash boost_1_62_0.tar.bz2"));
|
||||
"The argument should be a file path\n%s", Commands::Helpers::create_example_string("hash boost_1_62_0.tar.bz2"));
|
||||
args.check_min_arg_count(1, example);
|
||||
args.check_max_arg_count(2, example);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkg_info.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
void version_command(const vcpkg_cmd_arguments& args)
|
||||
{
|
||||
@ -19,18 +19,18 @@ namespace vcpkg
|
||||
args.check_max_arg_count(1);
|
||||
if (args.command_arguments.empty())
|
||||
{
|
||||
print_usage();
|
||||
Commands::Helpers::print_usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
const auto& topic = args.command_arguments[0];
|
||||
if (topic == "triplet")
|
||||
{
|
||||
help_topic_valid_triplet(paths);
|
||||
Commands::help_topic_valid_triplet(paths);
|
||||
}
|
||||
else
|
||||
{
|
||||
System::println(System::color::error, "Error: unknown topic %s", topic);
|
||||
print_usage();
|
||||
Commands::Helpers::print_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "vcpkg_Commands.h"
|
||||
#include "vcpkg_System.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands::Helpers
|
||||
{
|
||||
void print_usage()
|
||||
{
|
||||
@ -52,52 +52,4 @@ namespace vcpkg
|
||||
{
|
||||
System::println(create_example_string(command_and_arguments));
|
||||
}
|
||||
|
||||
void internal_test_command(const vcpkg_cmd_arguments& /*args*/, const vcpkg_paths& /*paths*/)
|
||||
{
|
||||
// auto data = FormatEventData("test");
|
||||
// Track(data);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
const std::vector<package_name_and_function<command_type_a>>& get_available_commands_type_a()
|
||||
{
|
||||
static std::vector<package_name_and_function<command_type_a>> t = {
|
||||
{"install", install_command},
|
||||
{"remove", remove_command},
|
||||
{"build", build_command},
|
||||
{"build_external", build_external_command}
|
||||
};
|
||||
return t;
|
||||
}
|
||||
|
||||
const std::vector<package_name_and_function<command_type_b>>& get_available_commands_type_b()
|
||||
{
|
||||
static std::vector<package_name_and_function<command_type_b>> t = {
|
||||
{"/?", help_command},
|
||||
{"help", help_command},
|
||||
{"search", search_command},
|
||||
{"list", list_command},
|
||||
{"integrate", integrate_command},
|
||||
{"owns", owns_command},
|
||||
{"update", update_command},
|
||||
{"edit", edit_command},
|
||||
{"create", create_command},
|
||||
{"import", import_command},
|
||||
{"cache", cache_command},
|
||||
{"internal_test", internal_test_command},
|
||||
{"portsdiff", portsdiff_command}
|
||||
};
|
||||
return t;
|
||||
}
|
||||
|
||||
const std::vector<package_name_and_function<command_type_c>>& get_available_commands_type_c()
|
||||
{
|
||||
static std::vector<package_name_and_function<command_type_c>> t = {
|
||||
{"version", &version_command},
|
||||
{"contact", &contact_command},
|
||||
{"hash", &hash_command},
|
||||
};
|
||||
return t;
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
#include "vcpkg_Files.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
struct Binaries
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace vcpkg
|
||||
|
||||
void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
static const std::string example = create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)");
|
||||
static const std::string example = Commands::Helpers::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)");
|
||||
args.check_exact_arg_count(3, example);
|
||||
|
||||
const fs::path control_file_path(args.command_arguments[0]);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "vcpkg_Dependencies.h"
|
||||
#include "vcpkg_Input.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
using Dependencies::package_spec_with_install_plan;
|
||||
using Dependencies::install_plan_type;
|
||||
@ -185,7 +185,7 @@ namespace vcpkg
|
||||
|
||||
void install_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
{
|
||||
static const std::string example = create_example_string("install zlib zlib:x64-windows curl boost");
|
||||
static const std::string example = Commands::Helpers::create_example_string("install zlib zlib:x64-windows curl boost");
|
||||
args.check_min_arg_count(1, example);
|
||||
StatusParagraphs status_db = database_load_check(paths);
|
||||
|
||||
@ -216,7 +216,7 @@ namespace vcpkg
|
||||
}
|
||||
else if (action.plan.type == install_plan_type::BUILD_AND_INSTALL)
|
||||
{
|
||||
Commands::details::build_internal(*action.plan.spgh, action.spec, paths, paths.port_dir(action.spec));
|
||||
Commands::build_internal(*action.plan.spgh, action.spec, paths, paths.port_dir(action.spec));
|
||||
const BinaryParagraph bpgh = try_load_cached_package(paths, action.spec).get_or_throw();
|
||||
install_package(paths, bpgh, status_db);
|
||||
System::println(System::color::success, "Package %s is installed", action.spec);
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkg_Files.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
static const std::array<fs::path, 2> old_system_target_files = {
|
||||
"C:/Program Files (x86)/MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets",
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkglib_helpers.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
static void do_print(const StatusParagraph& pgh)
|
||||
{
|
||||
@ -16,7 +16,7 @@ namespace vcpkg
|
||||
void list_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
static const std::string example = Strings::format(
|
||||
"The argument should be a substring to search for, or no argument to display all installed libraries.\n%s", create_example_string("list png"));
|
||||
"The argument should be a substring to search for, or no argument to display all installed libraries.\n%s", Commands::Helpers::create_example_string("list png"));
|
||||
args.check_max_arg_count(1, example);
|
||||
|
||||
const StatusParagraphs status_paragraphs = database_load_check(paths);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "vcpkg_System.h"
|
||||
#include "vcpkg.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
static void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db)
|
||||
{
|
||||
@ -23,7 +23,7 @@ namespace vcpkg
|
||||
|
||||
void owns_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
static const std::string example = Strings::format("The argument should be a pattern to search for. %s", create_example_string("owns zlib.dll"));
|
||||
static const std::string example = Strings::format("The argument should be a pattern to search for. %s", Commands::Helpers::create_example_string("owns zlib.dll"));
|
||||
args.check_exact_arg_count(1, example);
|
||||
|
||||
StatusParagraphs status_db = database_load_check(paths);
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "SourceParagraph.h"
|
||||
#include "vcpkg_Environment.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
static void do_print_name_and_version(const std::vector<std::string>& ports_to_print, const std::map<std::string, std::string>& names_and_versions)
|
||||
{
|
||||
@ -99,7 +99,7 @@ namespace vcpkg
|
||||
|
||||
void portsdiff_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
static const std::string example = Strings::format("The argument should be a branch/tag/hash to checkout.\n%s", create_example_string("portsdiff mybranchname"));
|
||||
static const std::string example = Strings::format("The argument should be a branch/tag/hash to checkout.\n%s", Commands::Helpers::create_example_string("portsdiff mybranchname"));
|
||||
args.check_min_arg_count(1, example);
|
||||
args.check_max_arg_count(2, example);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "vcpkg_Input.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
static const std::string OPTION_PURGE = "--purge";
|
||||
|
||||
@ -168,7 +168,7 @@ namespace vcpkg
|
||||
|
||||
void remove_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
|
||||
{
|
||||
static const std::string example = create_example_string("remove zlib zlib:x64-windows curl boost");
|
||||
static const std::string example = Commands::Helpers::create_example_string("remove zlib zlib:x64-windows curl boost");
|
||||
args.check_min_arg_count(1, example);
|
||||
|
||||
const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({OPTION_PURGE});
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "vcpkglib_helpers.h"
|
||||
#include "SourceParagraph.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
static std::vector<SourceParagraph> read_all_source_paragraphs(const vcpkg_paths& paths)
|
||||
{
|
||||
@ -42,7 +42,8 @@ namespace vcpkg
|
||||
|
||||
void search_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
static const std::string example = Strings::format("The argument should be a substring to search for, or no argument to display all libraries.\n%s", create_example_string("search png"));
|
||||
static const std::string example = Strings::format("The argument should be a substring to search for, or no argument to display all libraries.\n%s",
|
||||
Commands::Helpers::create_example_string("search png"));
|
||||
args.check_max_arg_count(1, example);
|
||||
|
||||
const std::vector<SourceParagraph> source_paragraphs = read_all_source_paragraphs(paths);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "Paragraphs.h"
|
||||
#include "vcpkg_info.h"
|
||||
|
||||
namespace vcpkg
|
||||
namespace vcpkg::Commands
|
||||
{
|
||||
void update_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ bool g_debugging = false;
|
||||
void invalid_command(const std::string& cmd)
|
||||
{
|
||||
System::println(System::color::error, "invalid command: %s", cmd);
|
||||
print_usage();
|
||||
Commands::Helpers::print_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -30,11 +30,11 @@ static void inner(const vcpkg_cmd_arguments& args)
|
||||
TrackProperty("command", args.command);
|
||||
if (args.command.empty())
|
||||
{
|
||||
print_usage();
|
||||
Commands::Helpers::print_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (auto command_function = find_command(args.command, get_available_commands_type_c()))
|
||||
if (auto command_function = Commands::find(args.command, Commands::get_available_commands_type_c()))
|
||||
{
|
||||
return command_function(args);
|
||||
}
|
||||
@ -66,7 +66,7 @@ static void inner(const vcpkg_cmd_arguments& args)
|
||||
int exit_code = _wchdir(paths.root.c_str());
|
||||
Checks::check_exit(exit_code == 0, "Changing the working dir failed");
|
||||
|
||||
if (auto command_function = find_command(args.command, get_available_commands_type_b()))
|
||||
if (auto command_function = Commands::find(args.command, Commands::get_available_commands_type_b()))
|
||||
{
|
||||
return command_function(args, paths);
|
||||
}
|
||||
@ -91,7 +91,7 @@ static void inner(const vcpkg_cmd_arguments& args)
|
||||
|
||||
Input::check_triplet(default_target_triplet, paths);
|
||||
|
||||
if (auto command_function = find_command(args.command, get_available_commands_type_a()))
|
||||
if (auto command_function = Commands::find(args.command, Commands::get_available_commands_type_a()))
|
||||
{
|
||||
return command_function(args, paths, default_target_triplet);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace vcpkg::Input
|
||||
{
|
||||
System::println(System::color::error, "Error: invalid triplet: %s", t.canonical_name());
|
||||
TrackProperty("error", "invalid triplet: " + t.canonical_name());
|
||||
help_topic_valid_triplet(paths);
|
||||
Commands::help_topic_valid_triplet(paths);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace vcpkg
|
||||
{
|
||||
System::println(System::color::error, "Error: expected value after %s", option_name);
|
||||
TrackProperty("error", "error option name");
|
||||
print_usage();
|
||||
Commands::Helpers::print_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ namespace vcpkg
|
||||
{
|
||||
System::println(System::color::error, "Error: %s specified multiple times", option_name);
|
||||
TrackProperty("error", "error option specified multiple times");
|
||||
print_usage();
|
||||
Commands::Helpers::print_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace vcpkg
|
||||
{
|
||||
System::println(System::color::error, "Error: conflicting values specified for --%s", option_name);
|
||||
TrackProperty("error", "error conflicting switches");
|
||||
print_usage();
|
||||
Commands::Helpers::print_usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
option_field = new_setting;
|
||||
|
@ -130,6 +130,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\MachineType.cpp" />
|
||||
<ClCompile Include="..\src\coff_file_reader.cpp" />
|
||||
<ClCompile Include="..\src\commands_available_commands.cpp" />
|
||||
<ClCompile Include="..\src\commands_build.cpp" />
|
||||
<ClCompile Include="..\src\commands_build_external.cpp" />
|
||||
<ClCompile Include="..\src\commands_cache.cpp" />
|
||||
@ -144,7 +145,7 @@
|
||||
<ClCompile Include="..\src\commands_search.cpp" />
|
||||
<ClCompile Include="..\src\commands_update.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg_cmd_arguments.cpp" />
|
||||
<ClCompile Include="..\src\commands_other.cpp" />
|
||||
<ClCompile Include="..\src\commands_helpers.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg_Dependencies.cpp" />
|
||||
<ClCompile Include="..\src\vcpkg_Environment.cpp" />
|
||||
<ClCompile Include="..\src\commands_install.cpp" />
|
||||
|
@ -18,9 +18,6 @@
|
||||
<ClCompile Include="..\src\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\commands_other.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\commands_help.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -90,6 +87,12 @@
|
||||
<ClCompile Include="..\src\commands_integrate.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\commands_helpers.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\commands_available_commands.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\include\post_build_lint.h">
|
||||
|
Loading…
Reference in New Issue
Block a user