mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 19:03:02 +08:00
[toolsrc] Optionally allow vcpkg to clean after each build (#6522)
* [toolsrc] Optionally allow vcpkg to clean packages, buildtrees and downloads after each build Adds switch --clean-after-build * [toolsrc] Clarify that --clean-after-build deletes downloads * [toolsrc] Revert changes to ci download caching behaviour
This commit is contained in:
parent
52dfee03b5
commit
17623739df
@ -51,6 +51,12 @@ namespace vcpkg::Build
|
||||
YES
|
||||
};
|
||||
|
||||
enum class CleanDownloads
|
||||
{
|
||||
NO = 0,
|
||||
YES
|
||||
};
|
||||
|
||||
enum class ConfigurationType
|
||||
{
|
||||
DEBUG,
|
||||
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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)};
|
||||
}
|
||||
|
||||
@ -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)"},
|
||||
@ -623,6 +635,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
|
||||
@ -634,8 +647,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,
|
||||
|
Loading…
Reference in New Issue
Block a user