From ebf8213945060c646e8074bcdf2b9463bcd44216 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 18 Mar 2020 11:19:25 -0700 Subject: [vcpkg] Use enum class for RestoreResult --- toolsrc/include/vcpkg/binarycaching.h | 8 ++++---- toolsrc/src/vcpkg/binarycaching.cpp | 14 +++++++------- toolsrc/src/vcpkg/build.cpp | 10 +++++++--- toolsrc/src/vcpkg/commands.ci.cpp | 4 ++-- 4 files changed, 20 insertions(+), 16 deletions(-) (limited to 'toolsrc') diff --git a/toolsrc/include/vcpkg/binarycaching.h b/toolsrc/include/vcpkg/binarycaching.h index 60b2eeab7..199b01acc 100644 --- a/toolsrc/include/vcpkg/binarycaching.h +++ b/toolsrc/include/vcpkg/binarycaching.h @@ -16,11 +16,11 @@ namespace vcpkg::Build namespace vcpkg { - enum RestoreResult + enum class RestoreResult { - MISSING, - SUCCESS, - BUILD_FAILED, + missing, + success, + build_failed, }; struct IBinaryProvider diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp index 659681c9e..af4a879ca 100644 --- a/toolsrc/src/vcpkg/binarycaching.cpp +++ b/toolsrc/src/vcpkg/binarycaching.cpp @@ -84,7 +84,7 @@ namespace System::print2("Failed to decompress archive package\n"); if (action.build_options.purge_decompress_failure == Build::PurgeDecompressFailure::NO) { - return RestoreResult::BUILD_FAILED; + return RestoreResult::build_failed; } else { @@ -94,7 +94,7 @@ namespace } else { - return RestoreResult::SUCCESS; + return RestoreResult::success; } } @@ -103,7 +103,7 @@ namespace if (action.build_options.fail_on_tombstone == Build::FailOnTombstone::YES) { System::print2("Found failure tombstone: ", archive_tombstone_path.u8string(), "\n"); - return RestoreResult::BUILD_FAILED; + return RestoreResult::build_failed; } else { @@ -116,7 +116,7 @@ namespace System::printf("Could not locate cached archive: %s\n", archive_path.u8string()); } - return RestoreResult::MISSING; + return RestoreResult::missing; } void push_success(const VcpkgPaths& paths, const Dependencies::InstallPlanAction& action) override { @@ -200,7 +200,7 @@ namespace if (fs.exists(archive_path)) { - return RestoreResult::SUCCESS; + return RestoreResult::success; } if (purge_tombstones) @@ -211,11 +211,11 @@ namespace { if (action.build_options.fail_on_tombstone == Build::FailOnTombstone::YES) { - return RestoreResult::BUILD_FAILED; + return RestoreResult::build_failed; } } - return RestoreResult::MISSING; + return RestoreResult::missing; } }; } diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp index e6a81607d..81997e79c 100644 --- a/toolsrc/src/vcpkg/build.cpp +++ b/toolsrc/src/vcpkg/build.cpp @@ -527,7 +527,11 @@ namespace vcpkg::Build { std::error_code err; fs.create_directory(buildpath, err); - Checks::check_exit(VCPKG_LINE_INFO, !err.value(), "Failed to create directory '%s', code: %d", buildpath.u8string(), err.value()); + Checks::check_exit(VCPKG_LINE_INFO, + !err.value(), + "Failed to create directory '%s', code: %d", + buildpath.u8string(), + err.value()); } auto stdoutlog = buildpath / ("stdout-" + action.spec.triplet().canonical_name() + ".log"); std::ofstream out_file(stdoutlog.native().c_str(), std::ios::out | std::ios::binary | std::ios::trunc); @@ -865,9 +869,9 @@ namespace vcpkg::Build if (binary_caching_enabled) { auto restore = binaries_provider->try_restore(paths, action); - if (restore == RestoreResult::BUILD_FAILED) + if (restore == RestoreResult::build_failed) return BuildResult::BUILD_FAILED; - else if (restore == RestoreResult::SUCCESS) + else if (restore == RestoreResult::success) { auto maybe_bcf = Paragraphs::try_load_cached_package(paths, spec); auto bcf = std::make_unique(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO)); diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp index 9cf3026cb..09bee8ddc 100644 --- a/toolsrc/src/vcpkg/commands.ci.cpp +++ b/toolsrc/src/vcpkg/commands.ci.cpp @@ -348,12 +348,12 @@ namespace vcpkg::Commands::CI ret->known.emplace(p->spec, BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES); will_fail.emplace(p->spec); } - else if (precheck_result == RestoreResult::SUCCESS) + else if (precheck_result == RestoreResult::success) { state = "pass"; ret->known.emplace(p->spec, BuildResult::SUCCEEDED); } - else if (precheck_result == RestoreResult::BUILD_FAILED) + else if (precheck_result == RestoreResult::build_failed) { state = "fail"; ret->known.emplace(p->spec, BuildResult::BUILD_FAILED); -- cgit v1.2.3