[vcpkg] Add support of external downloader aria2
MODIFY
include/vcpkg/build.h
include/vcpkg/build.h
@@ -57,12 +57,20 @@ namespace vcpkg::Build
RELEASE,
};
+ enum class DownloadTool
+ {
+ BUILT_IN,
+ ARIA2,
+ };
+ const std::string& to_string(DownloadTool tool);
+
struct BuildPackageOptions
{
UseHeadVersion use_head_version;
AllowDownloads allow_downloads;
CleanBuildtrees clean_buildtrees;
CleanPackages clean_packages;
+ DownloadTool download_tool;
};
enum class BuildResult

MODIFY
src/vcpkg/build.cpp
src/vcpkg/build.cpp
@@ -165,6 +165,19 @@ namespace vcpkg::Build
}
}
+ static const std::string NAME_BUILD_IN_DOWNLOAD = "BUILT_IN";
+ static const std::string NAME_ARIA2_DOWNLOAD = "ARIA2";
+
+ const std::string& to_string(DownloadTool tool)
+ {
+ switch (tool)
+ {
+ case DownloadTool::BUILT_IN: return NAME_BUILD_IN_DOWNLOAD;
+ case DownloadTool::ARIA2: return NAME_ARIA2_DOWNLOAD;
+ default: Checks::unreachable(VCPKG_LINE_INFO);
+ }
+ }
+
Optional<LinkageType> to_linkage_type(const std::string& str)
{
if (str == "dynamic") return LinkageType::DYNAMIC;
@@ -349,7 +362,9 @@ namespace vcpkg::Build
{"VCPKG_PLATFORM_TOOLSET", toolset.version.c_str()},
{"VCPKG_USE_HEAD_VERSION",
Util::Enum::to_bool(config.build_package_options.use_head_version) ? "1" : "0"},
- {"_VCPKG_NO_DOWNLOADS", !Util::Enum::to_bool(config.build_package_options.allow_downloads) ? "1" : "0"},
+ {"_VCPKG_NO_DOWNLOADS",
+ !Util::Enum::to_bool(config.build_package_options.allow_downloads) ? "1" : "0"},
+ {"_VCPKG_DOWNLOAD_TOOL", to_string(config.build_package_options.download_tool)},
{"GIT", git_exe_path},
{"FEATURES", Strings::join(";", config.feature_list)},
{"ALL_FEATURES", all_features},

MODIFY
src/vcpkg/install.cpp
src/vcpkg/install.cpp
@@ -412,13 +412,15 @@ namespace vcpkg::Install
static constexpr StringLiteral OPTION_RECURSE = "--recurse";
static constexpr StringLiteral OPTION_KEEP_GOING = "--keep-going";
static constexpr StringLiteral OPTION_XUNIT = "--x-xunit";
+ static constexpr StringLiteral OPTION_USE_ARIA2 = "--use-aria2";
- static constexpr std::array<CommandSwitch, 5> INSTALL_SWITCHES = {{
+ static constexpr std::array<CommandSwitch, 6> INSTALL_SWITCHES = {{
{OPTION_DRY_RUN, "Do not actually build or install"},
{OPTION_USE_HEAD_VERSION, "Install the libraries on the command line using the latest upstream sources"},
{OPTION_NO_DOWNLOADS, "Do not download new sources"},
{OPTION_RECURSE, "Allow removal of packages as part of installation"},
{OPTION_KEEP_GOING, "Continue installing packages on failure"},
+ {OPTION_USE_ARIA2, "Use aria2 to perform download tasks"},
}};
static constexpr std::array<CommandSetting, 1> INSTALL_SETTINGS = {{
{OPTION_XUNIT, "File to output results in XUnit format (Internal use)"},
@@ -547,16 +549,22 @@ namespace vcpkg::Install
const bool use_head_version = Util::Sets::contains(options.switches, (OPTION_USE_HEAD_VERSION));
const bool no_downloads = Util::Sets::contains(options.switches, (OPTION_NO_DOWNLOADS));
const bool is_recursive = Util::Sets::contains(options.switches, (OPTION_RECURSE));
+ const bool use_aria2 = Util::Sets::contains(options.switches, (OPTION_USE_ARIA2));
const KeepGoing keep_going = to_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING));
// create the plan
StatusParagraphs status_db = database_load_check(paths);
+ Build::DownloadTool download_tool = Build::DownloadTool::BUILT_IN;
+ if (use_aria2)
+ download_tool = Build::DownloadTool::ARIA2;
+
const Build::BuildPackageOptions install_plan_options = {
Util::Enum::to_enum<Build::UseHeadVersion>(use_head_version),
Util::Enum::to_enum<Build::AllowDownloads>(!no_downloads),
Build::CleanBuildtrees::NO,
- Build::CleanPackages::NO};
+ Build::CleanPackages::NO,
+ download_tool};
auto all_ports = Paragraphs::load_all_ports(paths.get_filesystem(), paths.ports);
std::unordered_map<std::string, SourceControlFile> scf_map;

[vcpkg] Add support of external downloader aria2