Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions toolsrc/include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ namespace vcpkg::Build
YES
};

enum class CleanDownloads
{
NO = 0,
YES
};

enum class ConfigurationType
{
DEBUG,
Expand Down Expand Up @@ -82,6 +88,7 @@ namespace vcpkg::Build
AllowDownloads allow_downloads;
CleanBuildtrees clean_buildtrees;
CleanPackages clean_packages;
CleanDownloads clean_downloads;
DownloadTool download_tool;
BinaryCaching binary_caching;
FailOnTombstone fail_on_tombstone;
Expand Down
1 change: 1 addition & 0 deletions toolsrc/src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace vcpkg::Build::Command
Build::AllowDownloads::YES,
Build::CleanBuildtrees::NO,
Build::CleanPackages::NO,
Build::CleanDownloads::NO,
Build::DownloadTool::BUILT_IN,
GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO,
Build::FailOnTombstone::NO,
Expand Down
2 changes: 2 additions & 0 deletions toolsrc/src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ namespace vcpkg::Commands::CI
Build::AllowDownloads::YES,
Build::CleanBuildtrees::YES,
Build::CleanPackages::YES,
Build::CleanDownloads::NO,
Build::DownloadTool::BUILT_IN,
GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO,
Build::FailOnTombstone::YES,
Expand Down Expand Up @@ -372,6 +373,7 @@ namespace vcpkg::Commands::CI
Build::AllowDownloads::YES,
Build::CleanBuildtrees::YES,
Build::CleanPackages::YES,
Build::CleanDownloads::NO,
Build::DownloadTool::BUILT_IN,
GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO,
Build::FailOnTombstone::YES,
Expand Down
1 change: 1 addition & 0 deletions toolsrc/src/vcpkg/commands.upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ namespace vcpkg::Commands::Upgrade
Build::AllowDownloads::YES,
Build::CleanBuildtrees::NO,
Build::CleanPackages::NO,
Build::CleanDownloads::NO,
Build::DownloadTool::BUILT_IN,
GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO,
Build::FailOnTombstone::NO,
Expand Down
1 change: 1 addition & 0 deletions toolsrc/src/vcpkg/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace vcpkg::Export
Build::AllowDownloads::YES,
Build::CleanBuildtrees::NO,
Build::CleanPackages::NO,
Build::CleanDownloads::NO,
Build::DownloadTool::BUILT_IN,
Build::BinaryCaching::NO,
Build::FailOnTombstone::NO,
Expand Down
20 changes: 17 additions & 3 deletions toolsrc/src/vcpkg/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ namespace vcpkg::Install
fs.remove_all(package_dir, ec);
}

if (action.build_options.clean_downloads == Build::CleanDownloads::YES)
{
auto& fs = paths.get_filesystem();
const fs::path download_dir = paths.downloads;
std::error_code ec;
for(auto& p: fs.get_files_non_recursive(download_dir))
if (!fs.is_directory(p))
fs.remove(p);
}

return {code, std::move(bcf)};
}

Expand Down Expand Up @@ -463,14 +473,16 @@ namespace vcpkg::Install
static constexpr StringLiteral OPTION_KEEP_GOING = "--keep-going";
static constexpr StringLiteral OPTION_XUNIT = "--x-xunit";
static constexpr StringLiteral OPTION_USE_ARIA2 = "--x-use-aria2";
static constexpr StringLiteral OPTION_CLEAN_AFTER_BUILD = "--clean-after-build";

static constexpr std::array<CommandSwitch, 6> INSTALL_SWITCHES = {{
static constexpr std::array<CommandSwitch, 7> 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"},
{OPTION_CLEAN_AFTER_BUILD, "Clean buildtrees, packages and downloads after building each package"},
}};
static constexpr std::array<CommandSetting, 1> INSTALL_SETTINGS = {{
{OPTION_XUNIT, "File to output results in XUnit format (Internal use)"},
Expand Down Expand Up @@ -621,6 +633,7 @@ namespace vcpkg::Install
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 bool clean_after_build = Util::Sets::contains(options.switches, (OPTION_CLEAN_AFTER_BUILD));
const KeepGoing keep_going = to_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING));

// create the plan
Expand All @@ -632,8 +645,9 @@ namespace vcpkg::Install
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,
clean_after_build ? Build::CleanBuildtrees::YES : Build::CleanBuildtrees::NO,
clean_after_build ? Build::CleanPackages::YES : Build::CleanPackages::NO,
clean_after_build ? Build::CleanDownloads::YES : Build::CleanDownloads::NO,
download_tool,
GlobalState::g_binary_caching ? Build::BinaryCaching::YES : Build::BinaryCaching::NO,
Build::FailOnTombstone::NO,
Expand Down