Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions include/vcpkg/base/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ namespace vcpkg
return std::chrono::duration_cast<TimeUnit>(m_duration);
}

ElapsedTime& operator+=(const ElapsedTime& other)
{
m_duration += other.m_duration;
return *this;
}

std::string to_string() const;
void to_string(std::string& into) const;

Expand Down Expand Up @@ -79,6 +85,8 @@ namespace vcpkg
mutable tm m_tm;
};

Optional<tm> to_utc_time(const std::time_t& t);

tm get_current_date_time();

tm get_current_date_time_local();
Expand Down
6 changes: 6 additions & 0 deletions include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ namespace vcpkg
m_data.append(s.begin(), s.end());
return *this;
}
template<class... Args>
LocalizedString& append_fmt_raw(fmt::string_view s, const Args&... args)
{
m_data.append(fmt::format(s, args...));
return *this;
}
LocalizedString& append(const LocalizedString& s)
{
m_data.append(s.m_data);
Expand Down
6 changes: 6 additions & 0 deletions include/vcpkg/base/xmlserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ namespace vcpkg
XmlSerializer& open_tag(StringLiteral sl);
XmlSerializer& start_complex_open_tag(StringLiteral sl);
XmlSerializer& text_attr(StringLiteral name, StringView content);
template<class T>
XmlSerializer& attr(StringLiteral name, const T& content)
{
return text_attr(name, Strings::concat_or_view(content));
}
XmlSerializer& finish_complex_open_tag();
XmlSerializer& finish_self_closing_complex_tag();
XmlSerializer& close_tag(StringLiteral sl);
XmlSerializer& text(StringView sv);
XmlSerializer& cdata(StringView sv);
XmlSerializer& simple_tag(StringLiteral tag, StringView content);
XmlSerializer& line_break();

Expand Down
4 changes: 1 addition & 3 deletions include/vcpkg/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace vcpkg::Build
{
enum class BuildResult
{
NULLVALUE = 0,
SUCCEEDED,
BUILD_FAILED,
POST_BUILD_CHECKS_FAILED,
Expand Down Expand Up @@ -197,7 +196,6 @@ namespace vcpkg::Build

struct BuildResultCounts
{
int null_value = 0;
int succeeded = 0;
int build_failed = 0;
int post_build_checks_failed = 0;
Expand Down Expand Up @@ -254,7 +252,7 @@ namespace vcpkg::Build

struct ExtendedBuildResult
{
ExtendedBuildResult(BuildResult code);
explicit ExtendedBuildResult(BuildResult code);
ExtendedBuildResult(BuildResult code, std::vector<FeatureSpec>&& unmet_deps);
ExtendedBuildResult(BuildResult code, std::unique_ptr<BinaryControlFile>&& bcf);

Expand Down
16 changes: 11 additions & 5 deletions include/vcpkg/install.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/base/chrono.h>
#include <vcpkg/base/optional.h>

#include <vcpkg/binaryparagraph.h>
#include <vcpkg/build.h>
#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/vcpkgpaths.h>

#include <chrono>
#include <set>
#include <string>
#include <vector>
Expand All @@ -25,15 +27,19 @@ namespace vcpkg::Install

struct SpecSummary
Copy link
Member Author

Choose a reason for hiding this comment

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

Long term, I think SpecSummary should be "freestanding" and not require the action plan that produced it to be held "alive" in order to be meaningful but that turned out to be more effort than I was willing to spend here. This at least goes somewhat in that direction.

{
SpecSummary(const PackageSpec& spec, const Dependencies::InstallPlanAction* action);
explicit SpecSummary(const Dependencies::InstallPlanAction& action);
explicit SpecSummary(const Dependencies::RemovePlanAction& action);

const BinaryParagraph* get_binary_paragraph() const;

PackageSpec spec;
Build::ExtendedBuildResult build_result;
const PackageSpec& get_spec() const { return m_spec; }
bool is_user_requested_install() const;
Optional<Build::ExtendedBuildResult> build_result;
vcpkg::ElapsedTime timing;
std::chrono::system_clock::time_point start_time;

const Dependencies::InstallPlanAction* action;
private:
const Dependencies::InstallPlanAction* m_install_action;
PackageSpec m_spec;
};

struct InstallSummary
Expand Down
18 changes: 4 additions & 14 deletions include/vcpkg/packagespec.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <vcpkg/base/fwd/format.h>
#include <vcpkg/base/fwd/parse.h>

#include <vcpkg/base/expected.h>
Expand Down Expand Up @@ -194,20 +195,6 @@ namespace vcpkg
Optional<ParsedQualifiedSpecifier> parse_qualified_specifier(ParserBase& parser);
}

template<class Char>
struct fmt::formatter<vcpkg::PackageSpec, Char>
{
constexpr auto parse(format_parse_context& ctx) const -> decltype(ctx.begin())
{
return vcpkg::basic_format_parse_impl(ctx);
}
template<class FormatContext>
auto format(const vcpkg::PackageSpec& spec, FormatContext& ctx) const -> decltype(ctx.out())
{
return fmt::formatter<std::string, Char>{}.format(spec.to_string(), ctx);
}
};

template<>
struct std::hash<vcpkg::PackageSpec>
{
Expand All @@ -230,3 +217,6 @@ struct std::hash<vcpkg::FeatureSpec>
return hash;
}
};

VCPKG_FORMAT_WITH_TO_STRING(vcpkg::PackageSpec);
VCPKG_FORMAT_WITH_TO_STRING(vcpkg::FeatureSpec);
4 changes: 4 additions & 0 deletions include/vcpkg/remove.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <vcpkg/fwd/vcpkgcmdarguments.h>
#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/base/messages.h>

#include <vcpkg/commands.interface.h>

namespace vcpkg::Remove
Expand All @@ -14,6 +16,8 @@ namespace vcpkg::Remove
YES
};

DECLARE_MESSAGE(RemovingPackage, (msg::spec), "", "Removing {spec}");

void perform_remove_plan_action(const VcpkgPaths& paths,
const Dependencies::RemovePlanAction& action,
const Purge purge,
Expand Down
11 changes: 11 additions & 0 deletions locales/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"AddTripletExpressionNotAllowed": "Error: triplet expressions are not allowed here. You may want to change `{package_name}:{triplet}` to `{package_name}` instead.",
"AllFormatArgsRawArgument": "format string \"{value}\" contains a raw format argument",
"AllFormatArgsUnbalancedBraces": "unbalanced brace in format string \"{value}\"",
"AlreadyInstalled": "{spec} is already installed",
"AlreadyInstalledNotHead": "{spec} is already installed -- not building from HEAD",
"AttemptingToFetchPackagesFromVendor": "Attempting to fetch {count} package(s) from {vendor}",
"BothYesAndNoOptionSpecifiedError": "error: cannot specify both --no-{option} and --{option}.",
"BuildResultBuildFailed": "BUILD_FAILED",
Expand All @@ -18,8 +20,11 @@
"BuildResultSucceeded": "SUCCEEDED",
"BuildResultSummaryHeader": "SUMMARY FOR {triplet}",
"BuildResultSummaryLine": " {build_result}: {count}",
"BuildingFromHead": "Building {spec} from HEAD...",
"BuildingPackage": "Building {spec}...",
"BuildingPackageFailed": "building {spec} failed with: {build_result}",
"BuildingPackageFailedDueToMissingDeps": "due to the following missing dependencies:",
"CMakeTargetsUsage": "{package_name} provides CMake targets:",
"ChecksFailedCheck": "vcpkg has crashed; no additional details are available.",
"ChecksUnreachableCode": "unreachable code was reached",
"ChecksUpdateVcpkg": "updating vcpkg by rerunning bootstrap-vcpkg may resolve this failure.",
Expand All @@ -30,8 +35,10 @@
"CmakeTargetsExcluded": "note: {count} additional targets are not displayed.",
"CouldNotDeduceNugetIdAndVersion": "Could not deduce nuget id and version from filename: {path}",
"CurlReportedUnexpectedResults": "curl has reported unexpected results to vcpkg and vcpkg cannot continue.\nPlease review the following text for sensitive information and open an issue on the Microsoft/vcpkg GitHub to help fix this problem!\ncmd: {command_line}\n=== curl output ===\n{actual}\n=== end curl output ===\n",
"DownloadedSources": "Downloaded sources for {spec}",
"DownloadingVcpkgCeBundle": "Downloading vcpkg-ce bundle {version}...",
"DownloadingVcpkgCeBundleLatest": "Downloading latest vcpkg-ce bundle...",
"ElapsedForPackage": "Elapsed time to handle {spec}: {elapsed}",
"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 All @@ -46,6 +53,7 @@
"ErrorRequirePackagesList": "Error: `vcpkg install` requires a list of packages to install in classic mode.",
"ErrorRequirePackagesToInstall": "Error: No packages were listed for installation and no manifest was found.",
"ErrorVcvarsUnsupported": "Error: in triplet {triplet}: Use of Visual Studio's Developer Prompt is unsupported on non-Windows hosts.\nDefine 'VCPKG_CMAKE_SYSTEM_NAME' or 'VCPKG_CHAINLOAD_TOOLCHAIN_FILE' in the triplet file.",
"ExcludedPackage": "Excluded {spec}",
"ExpectedCharacterHere": "expected '{expected}' here",
"ExpectedFailOrSkip": "expected 'fail' or 'skip' here",
"ExpectedPortName": "expected a port name here",
Expand All @@ -59,8 +67,10 @@
"GenerateMsgNoCommentValue": " {{{value}}} was used in the message, but not commented.",
"GraphCycleDetected": "Cycle detected within graph at {package_name}:",
"HashFileFailureToRead": "failed to read file '{path}' for hashing: {error}",
"HeaderOnlyUsage": "{package_name} is header-only and can be used from CMake via:",
"IllegalFeatures": "error: List of features is not allowed in this contect",
"IllegalPlatformSpec": "error: Platform qualifier is not allowed in this context",
"InstallingPackage": "Installing {spec}...",
"InternalErrorMessage": "internal error: ",
"InternalErrorMessageContact": "Please open an issue at https://github.com/microsoft/vcpkg/issues/new?template=other-type-of-bug-report.md&labels=category:vcpkg-bug with detailed steps to reproduce the problem.",
"LicenseExpressionContainsExtraPlus": "SPDX license expression contains an extra '+'. These are only allowed directly after a license identifier.",
Expand All @@ -87,6 +97,7 @@
"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%.",
"RemovingPackage": "Removing {spec}",
"RestoredPackagesFromVendor": "Restored {count} package(s) from {vendor} in {elapsed}",
"ResultsHeader": "RESULTS",
"SeeURL": "See {url} for more information.",
Expand Down
22 changes: 22 additions & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"_AllFormatArgsRawArgument.comment": "example of {value} is 'foo {} bar'\n",
"AllFormatArgsUnbalancedBraces": "unbalanced brace in format string \"{value}\"",
"_AllFormatArgsUnbalancedBraces.comment": "example of {value} is 'foo bar {'\n",
"AlreadyInstalled": "{spec} is already installed",
"_AlreadyInstalled.comment": "example of {spec} is 'zlib:x64-windows'.\n",
"AlreadyInstalledNotHead": "{spec} is already installed -- not building from HEAD",
"_AlreadyInstalledNotHead.comment": "'HEAD' means the most recent version of source code\nexample of {spec} is 'zlib:x64-windows'.\n",
"AttemptingToFetchPackagesFromVendor": "Attempting to fetch {count} package(s) from {vendor}",
"_AttemptingToFetchPackagesFromVendor.comment": "example of {count} is '42'.\nexample of {vendor} is 'Azure'.\n",
"BothYesAndNoOptionSpecifiedError": "error: cannot specify both --no-{option} and --{option}.",
Expand All @@ -36,10 +40,16 @@
"_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",
"BuildingFromHead": "Building {spec} from HEAD...",
"_BuildingFromHead.comment": "'HEAD' means the most recent version of source code\nexample of {spec} is 'zlib:x64-windows'.\n",
"BuildingPackage": "Building {spec}...",
"_BuildingPackage.comment": "example of {spec} is 'zlib:x64-windows'.\n",
"BuildingPackageFailed": "building {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",
"CMakeTargetsUsage": "{package_name} provides CMake targets:",
"_CMakeTargetsUsage.comment": "'targets' are a CMake and Makefile concept\nexample of {package_name} is 'zlib'.\n",
"ChecksFailedCheck": "vcpkg has crashed; no additional details are available.",
"ChecksUnreachableCode": "unreachable code was reached",
"ChecksUpdateVcpkg": "updating vcpkg by rerunning bootstrap-vcpkg may resolve this failure.",
Expand All @@ -56,10 +66,14 @@
"_CouldNotDeduceNugetIdAndVersion.comment": "example of {path} is '/foo/bar'.\n",
"CurlReportedUnexpectedResults": "curl has reported unexpected results to vcpkg and vcpkg cannot continue.\nPlease review the following text for sensitive information and open an issue on the Microsoft/vcpkg GitHub to help fix this problem!\ncmd: {command_line}\n=== curl output ===\n{actual}\n=== end curl output ===\n",
"_CurlReportedUnexpectedResults.comment": "{command_line} is the command line to call curl.exe, {actual} is the console output of curl.exe locale-invariant download results.\nexample of {command_line} is 'vcpkg install zlib'.\n",
"DownloadedSources": "Downloaded sources for {spec}",
"_DownloadedSources.comment": "example of {spec} is 'zlib:x64-windows'.\n",
"DownloadingVcpkgCeBundle": "Downloading vcpkg-ce bundle {version}...",
"_DownloadingVcpkgCeBundle.comment": "example of {version} is '1.3.8'.\n",
"DownloadingVcpkgCeBundleLatest": "Downloading latest vcpkg-ce bundle...",
"_DownloadingVcpkgCeBundleLatest.comment": "This message is normally displayed only in development.\n",
"ElapsedForPackage": "Elapsed time to handle {spec}: {elapsed}",
"_ElapsedForPackage.comment": "example of {spec} is 'zlib:x64-windows'.\nexample of {elapsed} is '3.532 min'.\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 All @@ -82,6 +96,8 @@
"ErrorRequirePackagesToInstall": "Error: No packages were listed for installation and no manifest was found.",
"ErrorVcvarsUnsupported": "Error: in triplet {triplet}: Use of Visual Studio's Developer Prompt is unsupported on non-Windows hosts.\nDefine 'VCPKG_CMAKE_SYSTEM_NAME' or 'VCPKG_CHAINLOAD_TOOLCHAIN_FILE' in the triplet file.",
"_ErrorVcvarsUnsupported.comment": "example of {triplet} is 'x64-windows'.\n",
"ExcludedPackage": "Excluded {spec}",
"_ExcludedPackage.comment": "example of {spec} is 'zlib:x64-windows'.\n",
"ExpectedCharacterHere": "expected '{expected}' here",
"_ExpectedCharacterHere.comment": "{expected} is a locale-invariant delimiter; for example, the ':' or '=' in 'zlib:x64-windows=skip'\n",
"ExpectedFailOrSkip": "expected 'fail' or 'skip' here",
Expand All @@ -103,8 +119,12 @@
"_GraphCycleDetected.comment": "A list of package names comprising the cycle will be printed after this message.\nexample of {package_name} is 'zlib'.\n",
"HashFileFailureToRead": "failed to read file '{path}' for hashing: {error}",
"_HashFileFailureToRead.comment": "example of {error} is 'no such file or directory'\nexample of {path} is '/foo/bar'.\n",
"HeaderOnlyUsage": "{package_name} is header-only and can be used from CMake via:",
"_HeaderOnlyUsage.comment": "'header' refers to C/C++ .h files\nexample of {package_name} is 'zlib'.\n",
"IllegalFeatures": "error: List of features is not allowed in this contect",
"IllegalPlatformSpec": "error: Platform qualifier is not allowed in this context",
"InstallingPackage": "Installing {spec}...",
"_InstallingPackage.comment": "example of {spec} is 'zlib:x64-windows'.\n",
"InternalErrorMessage": "internal error: ",
"InternalErrorMessageContact": "Please open an issue at https://github.com/microsoft/vcpkg/issues/new?template=other-type-of-bug-report.md&labels=category:vcpkg-bug with detailed steps to reproduce the problem.",
"LicenseExpressionContainsExtraPlus": "SPDX license expression contains an extra '+'. These are only allowed directly after a license identifier.",
Expand Down Expand Up @@ -144,6 +164,8 @@
"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",
"RemovingPackage": "Removing {spec}",
"_RemovingPackage.comment": "example of {spec} is 'zlib:x64-windows'.\n",
"RestoredPackagesFromVendor": "Restored {count} package(s) from {vendor} in {elapsed}",
"_RestoredPackagesFromVendor.comment": "example of {count} is '42'.\nexample of {elapsed} is '3.532 min'.\nexample of {vendor} is 'Azure'.\n",
"ResultsHeader": "RESULTS",
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/base/chrono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace vcpkg
return parts;
}

static Optional<tm> to_utc_time(const std::time_t& t)
Optional<tm> to_utc_time(const std::time_t& t)
{
tm parts{};
#if defined(_WIN32)
Expand Down
10 changes: 10 additions & 0 deletions src/vcpkg/base/xmlserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ namespace vcpkg
}
return *this;
}
XmlSerializer& XmlSerializer::cdata(StringView sv)
Copy link
Member Author

Choose a reason for hiding this comment

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

@ras0219-msft I think this CDATA thing was a workaround for not having real XmlSerializer available at the time; should this go through data() instead now that you have proper escapes implemented?

Copy link
Collaborator

@ras0219-msft ras0219-msft Apr 6, 2022

Choose a reason for hiding this comment

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

The spec actually says "as a CDATA block": https://xunit.net/docs/format-xml-v2

(for the <message> child of a <failure> node)

The failure message as a CDATA block.

I don't think it should matter, but I didn't want to substantially change the current output.

Copy link
Member Author

Choose a reason for hiding this comment

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

WOW!

{
emit_pending_indent();
Checks::check_exit(
VCPKG_LINE_INFO, Strings::search(sv, "]]>") == sv.end(), "]]> is not supported in a CDATA block");
buf.append("<![CDATA[");
buf.append(sv.begin(), sv.size());
buf.append("]]>");
return *this;
}
XmlSerializer& XmlSerializer::simple_tag(StringLiteral tag, StringView content)
{
return emit_pending_indent().open_tag(tag).text(content).close_tag(tag);
Expand Down
Loading