Skip to content

Commit a2c6e77

Browse files
committed
Add option to clean buildtrees folder only on success
This helps debugging build failures since the buildtrees folder is not removed in that case.
1 parent f9b6c69 commit a2c6e77

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

include/vcpkg/fwd/build.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace vcpkg
3636
enum class CleanBuildtrees
3737
{
3838
No = 0,
39+
OnSuccess,
3940
Yes
4041
};
4142

src/vcpkg/commands.build.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,8 @@ namespace vcpkg
12091209
{
12101210
auto result = do_build_package(args, paths, host_triplet, build_options, action, all_dependencies_satisfied);
12111211

1212-
if (build_options.clean_buildtrees == CleanBuildtrees::Yes)
1212+
if (build_options.clean_buildtrees == CleanBuildtrees::Yes ||
1213+
(build_options.clean_buildtrees == CleanBuildtrees::OnSuccess && result.code == BuildResult::Succeeded))
12131214
{
12141215
auto& fs = paths.get_filesystem();
12151216
// Will keep the logs, which are regular files

src/vcpkg/commands.set-installed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ namespace vcpkg
340340
BuildMissing::Yes,
341341
AllowDownloads::Yes,
342342
only_downloads,
343-
CleanBuildtrees::Yes,
343+
CleanBuildtrees::OnSuccess,
344344
CleanPackages::Yes,
345345
CleanDownloads::No,
346346
prohibit_backcompat_features,

src/vcpkg/commands.test-features.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ namespace vcpkg
115115
static constexpr CommandSwitch TEST_FEATURES_SWITCHES[] = {
116116

117117
{SwitchAll, msgCmdTestFeaturesAll},
118+
{SwitchCleanBuildtreesAfterBuild, msgHelpTxtOptCleanBuildTreesAfterBuild},
118119
{SwitchNoCore, msgCmdTestFeaturesNoCore},
119120
{SwitchNoSeparated, msgCmdTestFeaturesNoSeparated},
120121
{SwitchNoCombined, msgCmdTestFeaturesNoCombined},
@@ -153,6 +154,7 @@ namespace vcpkg
153154
const auto test_feature_core = !Util::Sets::contains(options.switches, SwitchNoCore);
154155
const auto test_features_combined = !Util::Sets::contains(options.switches, SwitchNoCombined);
155156
const auto test_features_separately = !Util::Sets::contains(options.switches, SwitchNoSeparated);
157+
const bool clean_buildtrees = Util::Sets::contains(options.switches, (SwitchCleanBuildtreesAfterBuild));
156158

157159
BinaryCache binary_cache(fs);
158160
if (!binary_cache.install_providers(args, paths, out_sink))
@@ -243,11 +245,11 @@ namespace vcpkg
243245
PackagesDirAssigner packages_dir_assigner{paths.packages()};
244246
CreateInstallPlanOptions install_plan_options{
245247
nullptr, host_triplet, UnsupportedPortAction::Warn, UseHeadVersion::No, Editable::No};
246-
static constexpr BuildPackageOptions build_options{
248+
BuildPackageOptions build_options{
247249
BuildMissing::Yes,
248250
AllowDownloads::Yes,
249251
OnlyDownloads::No,
250-
CleanBuildtrees::Yes,
252+
clean_buildtrees ? CleanBuildtrees::Yes : CleanBuildtrees::OnSuccess,
251253
CleanPackages::Yes,
252254
CleanDownloads::No,
253255
BackcompatFeatures::Prohibit,

0 commit comments

Comments
 (0)