Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] print out the dependencies that were unmet #468

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ namespace vcpkg::Build

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 Expand Up @@ -264,6 +263,8 @@ namespace vcpkg::Build
std::unique_ptr<BinaryControlFile> binary_control_file;
};

LocalizedString create_error_message(const ExtendedBuildResult& build_result, const PackageSpec& spec);

ExtendedBuildResult build_package(const VcpkgCmdArguments& args,
const VcpkgPaths& paths,
const Dependencies::InstallPlanAction& config,
Expand Down
2 changes: 2 additions & 0 deletions locales/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"BuildResultSucceeded": "SUCCEEDED",
"BuildResultSummaryHeader": "SUMMARY FOR {triplet}",
"BuildResultSummaryLine": " {build_result}: {count}",
"BuildingPackageFailed": "building package {spec} failed with: {build_result}",
"BuildingPackageFailedDueToMissingDeps": "due to the following missing dependencies:",
"ChecksFailedCheck": "vcpkg has crashed; no additional details are available.",
"ChecksLineInfo": "{vcpkg_line_info}: ",
"ChecksUnreachableCode": "unreachable code was reached",
Expand Down
4 changes: 4 additions & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"_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",
"BuildingPackageFailed": "building package {spec} failed with: {build_result}",
"_BuildingPackageFailed.comment": "example of {spec} is 'zlib:x64-windows'.\nexample of {build_result} is 'One of the BuildResultXxx messages (such as BuildResultSucceeded/SUCCEEDED)'.\n",
"BuildingPackageFailedDueToMissingDeps": "due to the following missing dependencies:",
"_BuildingPackageFailedDueToMissingDeps.comment": "Printed after BuildingPackageFailed, and followed by a list of dependencies that were missing.\n",
"ChecksFailedCheck": "vcpkg has crashed; no additional details are available.",
"ChecksLineInfo": "{vcpkg_line_info}: ",
"_ChecksLineInfo.comment": "{Locked}",
Expand Down
30 changes: 27 additions & 3 deletions src/vcpkg/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ namespace
"Printed after the name of an installed entity to indicate that it was successfully "
"downloaded but no build or install was requested.",
"DOWNLOADED");

DECLARE_AND_REGISTER_MESSAGE(BuildingPackageFailed,
(msg::spec, msg::build_result),
"",
"building package {spec} failed with: {build_result}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"building package {spec} failed with: {build_result}");
"building {spec} failed with: {build_result}");

As an aside, I think "package foo" can always be better replaced with just "foo". I know this is a change from the status quo so feel free to say "that's another PR Bill"

DECLARE_AND_REGISTER_MESSAGE(
BuildingPackageFailedDueToMissingDeps,
(),
"Printed after BuildingPackageFailed, and followed by a list of dependencies that were missing.",
"due to the following missing dependencies:");
}

namespace vcpkg::Build
Expand Down Expand Up @@ -1462,10 +1472,24 @@ namespace vcpkg::Build
}
}

std::string create_error_message(const BuildResult build_result, const PackageSpec& spec)
LocalizedString create_error_message(const ExtendedBuildResult& build_result, const PackageSpec& spec)
{
return Strings::format(
"Error: Building package %s failed with: %s", spec, Build::to_string_locale_invariant(build_result));
auto res = msg::format(msg::msgErrorMessage)
.append(msgBuildingPackageFailed,
msg::spec = spec,
msg::build_result = to_string_locale_invariant(build_result.code));

if (build_result.code == BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES)
{
res.appendnl().append(msgBuildingPackageFailedDueToMissingDeps);
strega-nil-ms marked this conversation as resolved.
Show resolved Hide resolved

for (const auto& missing_spec : build_result.unmet_dependencies)
{
res.appendnl().append_indent().append_raw(missing_spec.to_string());
strega-nil-ms marked this conversation as resolved.
Show resolved Hide resolved
}
}

return res;
}

std::string create_user_troubleshooting_message(const InstallPlanAction& action, const VcpkgPaths& paths)
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ namespace vcpkg::Install

if (result.code != Build::BuildResult::SUCCEEDED)
{
print2(Color::error, Build::create_error_message(result.code, action.spec), "\n");
msg::println(Color::error, Build::create_error_message(result, action.spec));
return result;
}

Expand Down