Skip to content

Commit

Permalink
Separate out summary information by triplet (#386)
Browse files Browse the repository at this point in the history
* Separate out summary information by triplet to account for host triplets and make generating releases easier.

Reported as https://twitter.com/Iluinrandir/status/1497132319953543201

* Regenerate messages and format.
  • Loading branch information
BillyONeal authored Mar 1, 2022
1 parent b91477a commit 725ec98
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 62 deletions.
32 changes: 17 additions & 15 deletions include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,28 @@ namespace vcpkg::msg
DECLARE_MSG_ARG(actual, "");
DECLARE_MSG_ARG(list, "");

DECLARE_MSG_ARG(email, "[email protected]");
DECLARE_MSG_ARG(path, "/foo/bar");
DECLARE_MSG_ARG(triplet, "x64-windows");
DECLARE_MSG_ARG(url, "https://github.com/microsoft/vcpkg");
DECLARE_MSG_ARG(elapsed, "3.532 min");
DECLARE_MSG_ARG(version, "1.3.8");
DECLARE_MSG_ARG(package_name, "zlib");
DECLARE_MSG_ARG(command_name, "install");
DECLARE_MSG_ARG(actual_version, "1.3.8");
DECLARE_MSG_ARG(arch, "x64");
DECLARE_MSG_ARG(build_result, "One of the BuildResultXxx messages (such as BuildResultSucceeded/SUCCEEDED)");
DECLARE_MSG_ARG(column, "42");
DECLARE_MSG_ARG(command_line, "vcpkg install zlib");
DECLARE_MSG_ARG(exit_code, "127");
DECLARE_MSG_ARG(command_name, "install");
DECLARE_MSG_ARG(count, "42");
DECLARE_MSG_ARG(row, "42");
DECLARE_MSG_ARG(column, "42");
DECLARE_MSG_ARG(arch, "x64");
DECLARE_MSG_ARG(system_name, "Darwin");
DECLARE_MSG_ARG(option, "editable");
DECLARE_MSG_ARG(elapsed, "3.532 min");
DECLARE_MSG_ARG(email, "[email protected]");
DECLARE_MSG_ARG(exit_code, "127");
DECLARE_MSG_ARG(expected_version, "1.3.8");
DECLARE_MSG_ARG(actual_version, "1.3.8");
DECLARE_MSG_ARG(new_scheme, "version");
DECLARE_MSG_ARG(old_scheme, "version-string");
DECLARE_MSG_ARG(option, "editable");
DECLARE_MSG_ARG(package_name, "zlib");
DECLARE_MSG_ARG(path, "/foo/bar");
DECLARE_MSG_ARG(row, "42");
DECLARE_MSG_ARG(spec, "zlib:x64-windows");
DECLARE_MSG_ARG(system_name, "Darwin");
DECLARE_MSG_ARG(triplet, "x64-windows");
DECLARE_MSG_ARG(url, "https://github.com/microsoft/vcpkg");
DECLARE_MSG_ARG(version, "1.3.8");
#undef DECLARE_MSG_ARG

// These are `...` instead of
Expand Down
27 changes: 18 additions & 9 deletions include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,24 @@ namespace vcpkg::Build
Build::BackcompatFeatures::PROHIBIT,
};

static constexpr std::array<BuildResult, 6> BUILD_RESULT_VALUES = {
BuildResult::SUCCEEDED,
BuildResult::BUILD_FAILED,
BuildResult::POST_BUILD_CHECKS_FAILED,
BuildResult::FILE_CONFLICTS,
BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES,
BuildResult::EXCLUDED};

const std::string& to_string(const BuildResult build_result);
struct BuildResultCounts
{
int null_value = 0;
int succeeded = 0;
int build_failed = 0;
int post_build_checks_failed = 0;
int file_conflicts = 0;
int cascaded_due_to_missing_dependencies = 0;
int excluded = 0;
int cache_missing = 0;
int downloaded = 0;

void increment(const BuildResult build_result);
void println(const Triplet& triplet) const;
};

StringLiteral to_string_locale_invariant(const BuildResult build_result);
LocalizedString to_string(const BuildResult build_result);
std::string create_error_message(const BuildResult build_result, const PackageSpec& spec);
std::string create_user_troubleshooting_message(const Dependencies::InstallPlanAction& action,
const VcpkgPaths& paths);
Expand Down
12 changes: 12 additions & 0 deletions locales/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
"AwsRestoredPackages": "Restored {count} packages from AWS servers in {elapsed}",
"AwsUploadedPackages": "Uploaded binaries to {count} AWS servers",
"BothYesAndNoOptionSpecifiedError": "error: cannot specify both --no-{option} and --{option}.",
"BuildResultBuildFailed": "BUILD_FAILED",
"BuildResultCacheMissing": "CACHE_MISSING",
"BuildResultCascadeDueToMissingDependencies": "CASCADED_DUE_TO_MISSING_DEPENDENCIES",
"BuildResultDownloaded": "DOWNLOADED",
"BuildResultExcluded": "EXCLUDED",
"BuildResultFileConflicts": "FILE_CONFLICTS",
"BuildResultPostBuildChecksFailed": "POST_BUILD_CHECKS_FAILED",
"BuildResultSucceeded": "SUCCEEDED",
"BuildResultSummaryHeader": "SUMMARY FOR {triplet}",
"BuildResultSummaryLine": " {build_result}: {count}",
"EmptyLicenseExpression": "SPDX license expression was empty.",
"ErrorIndividualPackagesUnsupported": "Error: In manifest mode, `vcpkg install` does not support individual package arguments.\nTo install additional packages, edit vcpkg.json and then run `vcpkg install` without any package arguments.",
"ErrorInvalidClassicModeOption": "Error: The option --{option} is not supported in classic mode and no manifest was found.",
Expand Down Expand Up @@ -54,6 +64,8 @@
"ProcessorArchitectureMalformed": "Failed to parse %PROCESSOR_ARCHITECTURE% ({arch}) as a valid CPU architecture.",
"ProcessorArchitectureMissing": "The required environment variable %PROCESSOR_ARCHITECTURE% is missing.",
"ProcessorArchitectureW6432Malformed": "Failed to parse %PROCESSOR_ARCHITEW6432% ({arch}) as a valid CPU architecture. Falling back to %PROCESSOR_ARCHITECTURE%.",
"ResultsHeader": "RESULTS",
"ResultsLine": " {spec}: {build_result}: {elapsed}",
"SeeURL": "See {url} for more information.",
"SuggestNewVersionScheme": "Use the version scheme \"{new_scheme}\" instead of \"{old_scheme}\" in port \"{package_name}\".\nUse `--{option}` to disable this check.",
"UnsupportedSystemName": "Error: Could not map VCPKG_CMAKE_SYSTEM_NAME '{system_name}' to a vcvarsall platform. Supported system names are '', 'Windows' and 'WindowsStore'.",
Expand Down
24 changes: 24 additions & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@
"_AwsUploadedPackages.comment": "example of {count} is '42'.\n",
"BothYesAndNoOptionSpecifiedError": "error: cannot specify both --no-{option} and --{option}.",
"_BothYesAndNoOptionSpecifiedError.comment": "example of {option} is 'editable'.\n",
"BuildResultBuildFailed": "BUILD_FAILED",
"_BuildResultBuildFailed.comment": "Printed after the name of an installed entity to indicate that it failed to build.\n",
"BuildResultCacheMissing": "CACHE_MISSING",
"_BuildResultCacheMissing.comment": "Printed after the name of an installed entity to indicate that it was not present in the binary cache when the user has requested that things may only be installed from the cache rather than built.\n",
"BuildResultCascadeDueToMissingDependencies": "CASCADED_DUE_TO_MISSING_DEPENDENCIES",
"_BuildResultCascadeDueToMissingDependencies.comment": "Printed after the name of an installed entity to indicate that it could not attempt to be installed because one of its transitive dependencies failed to install.\n",
"BuildResultDownloaded": "DOWNLOADED",
"_BuildResultDownloaded.comment": "Printed after the name of an installed entity to indicate that it was successfully downloaded but no build or install was requested.\n",
"BuildResultExcluded": "EXCLUDED",
"_BuildResultExcluded.comment": "Printed after the name of an installed entity to indicate that the user explicitly requested it not be installed.\n",
"BuildResultFileConflicts": "FILE_CONFLICTS",
"_BuildResultFileConflicts.comment": "Printed after the name of an installed entity to indicate that it conflicts with something already installed\n",
"BuildResultPostBuildChecksFailed": "POST_BUILD_CHECKS_FAILED",
"_BuildResultPostBuildChecksFailed.comment": "Printed after the name of an installed entity to indicate that it built successfully, but that it failed post build checks.\n",
"BuildResultSucceeded": "SUCCEEDED",
"_BuildResultSucceeded.comment": "Printed after the name of an installed entity to indicate that it was built and installed successfully.\n",
"BuildResultSummaryHeader": "SUMMARY FOR {triplet}",
"_BuildResultSummaryHeader.comment": "Displayed before a list of a summary installation results.\nexample of {triplet} is 'x64-windows'.\n",
"BuildResultSummaryLine": " {build_result}: {count}",
"_BuildResultSummaryLine.comment": "Displayed to show a count of results of a build_result in a summary.\nexample of {build_result} is 'One of the BuildResultXxx messages (such as BuildResultSucceeded/SUCCEEDED)'.\nexample of {count} is '42'.\n",
"EmptyLicenseExpression": "SPDX license expression was empty.",
"ErrorIndividualPackagesUnsupported": "Error: In manifest mode, `vcpkg install` does not support individual package arguments.\nTo install additional packages, edit vcpkg.json and then run `vcpkg install` without any package arguments.",
"ErrorInvalidClassicModeOption": "Error: The option --{option} is not supported in classic mode and no manifest was found.",
Expand Down Expand Up @@ -89,6 +109,10 @@
"ProcessorArchitectureMissing": "The required environment variable %PROCESSOR_ARCHITECTURE% is missing.",
"ProcessorArchitectureW6432Malformed": "Failed to parse %PROCESSOR_ARCHITEW6432% ({arch}) as a valid CPU architecture. Falling back to %PROCESSOR_ARCHITECTURE%.",
"_ProcessorArchitectureW6432Malformed.comment": "example of {arch} is 'x64'.\n",
"ResultsHeader": "RESULTS",
"_ResultsHeader.comment": "Displayed before a list of installation results.\n",
"ResultsLine": " {spec}: {build_result}: {elapsed}",
"_ResultsLine.comment": "A single instalation result.\nexample of {spec} is 'zlib:x64-windows'.\nexample of {build_result} is 'One of the BuildResultXxx messages (such as BuildResultSucceeded/SUCCEEDED)'.\nexample of {elapsed} is '3.532 min'.\n",
"SeeURL": "See {url} for more information.",
"_SeeURL.comment": "example of {url} is 'https://github.com/microsoft/vcpkg'.\n",
"SuggestNewVersionScheme": "Use the version scheme \"{new_scheme}\" instead of \"{old_scheme}\" in port \"{package_name}\".\nUse `--{option}` to disable this check.",
Expand Down
153 changes: 133 additions & 20 deletions src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,63 @@ namespace
};

static const NullBuildLogsRecorder null_build_logs_recorder_instance;

DECLARE_AND_REGISTER_MESSAGE(BuildResultSummaryHeader,
(msg::triplet),
"Displayed before a list of a summary installation results.",
"SUMMARY FOR {triplet}");
DECLARE_AND_REGISTER_MESSAGE(BuildResultSummaryLine,
(msg::build_result, msg::count),
"Displayed to show a count of results of a build_result in a summary.",
" {build_result}: {count}");

DECLARE_AND_REGISTER_MESSAGE(
BuildResultSucceeded,
(),
"Printed after the name of an installed entity to indicate that it was built and installed successfully.",
"SUCCEEDED");

DECLARE_AND_REGISTER_MESSAGE(BuildResultBuildFailed,
(),
"Printed after the name of an installed entity to indicate that it failed to build.",
"BUILD_FAILED");

DECLARE_AND_REGISTER_MESSAGE(
BuildResultFileConflicts,
(),
"Printed after the name of an installed entity to indicate that it conflicts with something already installed",
"FILE_CONFLICTS");

DECLARE_AND_REGISTER_MESSAGE(BuildResultPostBuildChecksFailed,
(),
"Printed after the name of an installed entity to indicate that it built "
"successfully, but that it failed post build checks.",
"POST_BUILD_CHECKS_FAILED");

DECLARE_AND_REGISTER_MESSAGE(BuildResultCascadeDueToMissingDependencies,
(),
"Printed after the name of an installed entity to indicate that it could not attempt "
"to be installed because one of its transitive dependencies failed to install.",
"CASCADED_DUE_TO_MISSING_DEPENDENCIES");

DECLARE_AND_REGISTER_MESSAGE(BuildResultExcluded,
(),
"Printed after the name of an installed entity to indicate that the user explicitly "
"requested it not be installed.",
"EXCLUDED");

DECLARE_AND_REGISTER_MESSAGE(
BuildResultCacheMissing,
(),
"Printed after the name of an installed entity to indicate that it was not present in the binary cache when "
"the user has requested that things may only be installed from the cache rather than built.",
"CACHE_MISSING");

DECLARE_AND_REGISTER_MESSAGE(BuildResultDownloaded,
(),
"Printed after the name of an installed entity to indicate that it was successfully "
"downloaded but no build or install was requested.",
"DOWNLOADED");
}

namespace vcpkg::Build
Expand Down Expand Up @@ -1337,36 +1394,92 @@ namespace vcpkg::Build
return result;
}

const std::string& to_string(const BuildResult build_result)
void BuildResultCounts::increment(const BuildResult build_result)
{
switch (build_result)
{
case BuildResult::NULLVALUE: ++null_value; return;
case BuildResult::SUCCEEDED: ++succeeded; return;
case BuildResult::BUILD_FAILED: ++build_failed; return;
case BuildResult::POST_BUILD_CHECKS_FAILED: ++post_build_checks_failed; return;
case BuildResult::FILE_CONFLICTS: ++file_conflicts; return;
case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: ++cascaded_due_to_missing_dependencies; return;
case BuildResult::EXCLUDED: ++excluded; return;
case BuildResult::CACHE_MISSING: ++cache_missing; return;
case BuildResult::DOWNLOADED: ++downloaded; return;
default: Checks::unreachable(VCPKG_LINE_INFO);
}
}

void BuildResultCounts::println(const Triplet& triplet) const
{
msg::println(msgBuildResultSummaryHeader, msg::triplet = triplet);
// NULLVALUE intentionally not printed
msg::println(msgBuildResultSummaryLine,
msg::build_result = msg::format(msgBuildResultSucceeded),
msg::count = succeeded);
msg::println(msgBuildResultSummaryLine,
msg::build_result = msg::format(msgBuildResultBuildFailed),
msg::count = build_failed);
msg::println(msgBuildResultSummaryLine,
msg::build_result = msg::format(msgBuildResultPostBuildChecksFailed),
msg::count = post_build_checks_failed);
msg::println(msgBuildResultSummaryLine,
msg::build_result = msg::format(msgBuildResultFileConflicts),
msg::count = file_conflicts);
msg::println(msgBuildResultSummaryLine,
msg::build_result = msg::format(msgBuildResultCascadeDueToMissingDependencies),
msg::count = cascaded_due_to_missing_dependencies);
msg::println(
msgBuildResultSummaryLine, msg::build_result = msg::format(msgBuildResultExcluded), msg::count = excluded);
msg::println(msgBuildResultSummaryLine,
msg::build_result = msg::format(msgBuildResultCacheMissing),
msg::count = cache_missing);
msg::println(msgBuildResultSummaryLine,
msg::build_result = msg::format(msgBuildResultDownloaded),
msg::count = downloaded);
}

StringLiteral to_string_locale_invariant(const BuildResult build_result)
{
static const std::string NULLVALUE_STRING = "vcpkg::Commands::Build::BuildResult_NULLVALUE";
static const std::string SUCCEEDED_STRING = "SUCCEEDED";
static const std::string BUILD_FAILED_STRING = "BUILD_FAILED";
static const std::string FILE_CONFLICTS_STRING = "FILE_CONFLICTS";
static const std::string POST_BUILD_CHECKS_FAILED_STRING = "POST_BUILD_CHECKS_FAILED";
static const std::string CASCADED_DUE_TO_MISSING_DEPENDENCIES_STRING = "CASCADED_DUE_TO_MISSING_DEPENDENCIES";
static const std::string EXCLUDED_STRING = "EXCLUDED";
static const std::string CACHE_MISSING_STRING = "CACHE_MISSING";
static const std::string DOWNLOADED_STRING = "DOWNLOADED";
switch (build_result)
{
case BuildResult::NULLVALUE: return "vcpkg::Commands::Build::BuildResult_NULLVALUE";
case BuildResult::SUCCEEDED: return "SUCCEEDED";
case BuildResult::BUILD_FAILED: return "BUILD_FAILED";
case BuildResult::POST_BUILD_CHECKS_FAILED: return "POST_BUILD_CHECKS_FAILED";
case BuildResult::FILE_CONFLICTS: return "FILE_CONFLICTS";
case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: return "CASCADED_DUE_TO_MISSING_DEPENDENCIES";
case BuildResult::EXCLUDED: return "EXCLUDED";
case BuildResult::CACHE_MISSING: return "CACHE_MISSING";
case BuildResult::DOWNLOADED: return "DOWNLOADED";
default: Checks::unreachable(VCPKG_LINE_INFO);
}
}

LocalizedString to_string(const BuildResult build_result)
{
switch (build_result)
{
case BuildResult::NULLVALUE: return NULLVALUE_STRING;
case BuildResult::SUCCEEDED: return SUCCEEDED_STRING;
case BuildResult::BUILD_FAILED: return BUILD_FAILED_STRING;
case BuildResult::POST_BUILD_CHECKS_FAILED: return POST_BUILD_CHECKS_FAILED_STRING;
case BuildResult::FILE_CONFLICTS: return FILE_CONFLICTS_STRING;
case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES: return CASCADED_DUE_TO_MISSING_DEPENDENCIES_STRING;
case BuildResult::EXCLUDED: return EXCLUDED_STRING;
case BuildResult::CACHE_MISSING: return CACHE_MISSING_STRING;
case BuildResult::DOWNLOADED: return DOWNLOADED_STRING;
case BuildResult::NULLVALUE:
return LocalizedString::from_string_unchecked(to_string_locale_invariant(BuildResult::NULLVALUE));
case BuildResult::SUCCEEDED: return msg::format(msgBuildResultSucceeded);
case BuildResult::BUILD_FAILED: return msg::format(msgBuildResultBuildFailed);
case BuildResult::POST_BUILD_CHECKS_FAILED: return msg::format(msgBuildResultPostBuildChecksFailed);
case BuildResult::FILE_CONFLICTS: return msg::format(msgBuildResultFileConflicts);
case BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES:
return msg::format(msgBuildResultCascadeDueToMissingDependencies);
case BuildResult::EXCLUDED: return msg::format(msgBuildResultExcluded);
case BuildResult::CACHE_MISSING: return msg::format(msgBuildResultCacheMissing);
case BuildResult::DOWNLOADED: return msg::format(msgBuildResultDownloaded);
default: Checks::unreachable(VCPKG_LINE_INFO);
}
}

std::string create_error_message(const BuildResult build_result, const PackageSpec& spec)
{
return Strings::format("Error: Building package %s failed with: %s", spec, Build::to_string(build_result));
return Strings::format(
"Error: Building package %s failed with: %s", spec, Build::to_string_locale_invariant(build_result));
}

std::string create_user_troubleshooting_message(const InstallPlanAction& action, const VcpkgPaths& paths)
Expand Down
Loading

0 comments on commit 725ec98

Please sign in to comment.