[vcpkg] Use enum class for RestoreResult

This commit is contained in:
Robert Schumacher 2020-03-18 11:19:25 -07:00
parent 6b55c62144
commit ebf8213945
4 changed files with 20 additions and 16 deletions

View File

@ -16,11 +16,11 @@ namespace vcpkg::Build
namespace vcpkg
{
enum RestoreResult
enum class RestoreResult
{
MISSING,
SUCCESS,
BUILD_FAILED,
missing,
success,
build_failed,
};
struct IBinaryProvider

View File

@ -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;
}
};
}

View File

@ -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<BinaryControlFile>(std::move(maybe_bcf).value_or_exit(VCPKG_LINE_INFO));

View File

@ -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);