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

Extract msg:: removal from #1210 #1227

Merged
merged 3 commits into from
Oct 10, 2023
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
6 changes: 3 additions & 3 deletions docs/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Messages in vcpkg are written in American English. They should not contain:
if you need to add more than one indentation, you can use `append_indent(N)`
- Any other interesting characters (like `- ` for lists, for example) should use `append_raw(...)`
* or for the prefixes:
- `"warning: "`, instead use `msg::format(msg::msgWarningMessage).append(msgMyWarning)`
- `"error: "`, instead use `msg::msgErrorMessage`
- `"internal error: "`, instead use `msg::msgInternalErrorMessage`.
- `"warning: "`, instead use `msg::format(msgWarningMessage).append(msgMyWarning)`
- `"error: "`, instead use `msgErrorMessage`
- `"internal error: "`, instead use `msgInternalErrorMessage`.

They should also not be simple, locale-invariant messages -- something like, for example,
`{file}:{line}:{column}: ` should be done with `LocalizedString::from_raw(fmt::format("{}:{}:{}", file, line, column))`.
Expand Down
10 changes: 0 additions & 10 deletions include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,4 @@ namespace vcpkg

#include <vcpkg/base/message-data.inc.h>
#undef DECLARE_MESSAGE

namespace msg
{
extern const decltype(vcpkg::msgErrorMessage) msgErrorMessage;
extern const decltype(vcpkg::msgWarningMessage) msgWarningMessage;
extern const decltype(vcpkg::msgNoteMessage) msgNoteMessage;
extern const decltype(vcpkg::msgSeeURL) msgSeeURL;
extern const decltype(vcpkg::msgInternalErrorMessage) msgInternalErrorMessage;
extern const decltype(vcpkg::msgInternalErrorMessageContact) msgInternalErrorMessageContact;
}
}
10 changes: 5 additions & 5 deletions src/vcpkg/base/checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ namespace vcpkg
if (!expression)
{
msg::println(Color::error,
msg::format(msg::msgInternalErrorMessage)
msg::format(msgInternalErrorMessage)
.append(locale_invariant_lineinfo(line_info))
.append(msgChecksFailedCheck)
.append_raw('\n')
.append(msg::msgInternalErrorMessageContact));
.append(msgInternalErrorMessageContact));
exit_fail(line_info);
}
}
Expand All @@ -103,11 +103,11 @@ namespace vcpkg
if (!expression)
{
msg::println(Color::error,
msg::format(msg::msgInternalErrorMessage)
msg::format(msgInternalErrorMessage)
.append(locale_invariant_lineinfo(line_info))
.append_raw(error_message)
.append_raw('\n')
.append(msg::msgInternalErrorMessageContact));
.append(msgInternalErrorMessageContact));
exit_fail(line_info);
}
}
Expand All @@ -122,7 +122,7 @@ namespace vcpkg

static void display_upgrade_message()
{
msg::println(Color::error, msg::format(msg::msgNoteMessage).append(msgChecksUpdateVcpkg));
msg::println(Color::error, msg::format(msgNoteMessage).append(msgChecksUpdateVcpkg));
}

[[noreturn]] void Checks::exit_maybe_upgrade(const LineInfo& line_info)
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/base/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ namespace vcpkg::Hash
auto file = fs.open_for_read(path, ec);
if (ec)
{
return msg::format(msg::msgErrorMessage)
return msg::format(msgErrorMessage)
.append(msgHashFileFailureToRead, msg::path = path)
.append_raw(ec.message());
}
Expand All @@ -582,7 +582,7 @@ namespace vcpkg::Hash
}
else if ((ec = file.error()))
{
return msg::format(msg::msgErrorMessage)
return msg::format(msgErrorMessage)
.append(msgHashFileFailureToRead, msg::path = path)
.append_raw(ec.message());
}
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/base/message_sinks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ namespace vcpkg

void MessageSink::println_warning(const LocalizedString& s)
{
println(Color::warning, format(msg::msgWarningMessage).append(s));
println(Color::warning, format(msgWarningMessage).append(s));
}

void MessageSink::println_error(const LocalizedString& s)
{
println(Color::error, format(msg::msgErrorMessage).append(s));
println(Color::error, format(msgErrorMessage).append(s));
}

MessageSink& null_sink = null_sink_instance;
Expand Down
11 changes: 0 additions & 11 deletions src/vcpkg/base/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,6 @@ namespace vcpkg

#include <vcpkg/base/message-data.inc.h>
#undef DECLARE_MESSAGE

namespace msg
{
const decltype(vcpkg::msgErrorMessage) msgErrorMessage = vcpkg::msgErrorMessage;
const decltype(vcpkg::msgWarningMessage) msgWarningMessage = vcpkg::msgWarningMessage;
const decltype(vcpkg::msgNoteMessage) msgNoteMessage = vcpkg::msgNoteMessage;
const decltype(vcpkg::msgSeeURL) msgSeeURL = vcpkg::msgSeeURL;
const decltype(vcpkg::msgInternalErrorMessage) msgInternalErrorMessage = vcpkg::msgInternalErrorMessage;
const decltype(vcpkg::msgInternalErrorMessageContact) msgInternalErrorMessageContact =
vcpkg::msgInternalErrorMessageContact;
}
}
namespace vcpkg::msg
{
Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/base/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ namespace vcpkg
res = LocalizedString::from_raw(fmt::format("{}:{}:{}: ", origin, location.row, location.column));
if (kind == MessageKind::Warning)
{
res.append(msg::msgWarningMessage);
res.append(msgWarningMessage);
}
else
{
res.append(msg::msgErrorMessage);
res.append(msgErrorMessage);
}
res.append(message);

Expand Down
12 changes: 6 additions & 6 deletions src/vcpkg/binarycaching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2307,23 +2307,23 @@ ExpectedL<DownloadManagerConfig> vcpkg::parse_download_configuration(const Optio
{
return LocalizedString::from_raw(err->to_string()) // note that this already contains error:
.append_raw('\n')
.append(msg::msgNoteMessage)
.append(msg::msgSeeURL, msg::url = docs::assetcaching_url);
.append(msgNoteMessage)
.append(msgSeeURL, msg::url = docs::assetcaching_url);
}

if (s.azblob_templates_to_put.size() > 1)
{
return msg::format_error(msgAMaximumOfOneAssetWriteUrlCanBeSpecified)
.append_raw('\n')
.append(msg::msgNoteMessage)
.append(msg::msgSeeURL, msg::url = docs::assetcaching_url);
.append(msgNoteMessage)
.append(msgSeeURL, msg::url = docs::assetcaching_url);
}
if (s.url_templates_to_get.size() > 1)
{
return msg::format_error(msgAMaximumOfOneAssetReadUrlCanBeSpecified)
.append_raw('\n')
.append(msg::msgNoteMessage)
.append(msg::msgSeeURL, msg::url = docs::assetcaching_url);
.append(msgNoteMessage)
.append(msgSeeURL, msg::url = docs::assetcaching_url);
}

Optional<std::string> get_url;
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/commands.add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace vcpkg
if (!pmanifest_scf)
{
print_error_message(maybe_manifest_scf.error());
msg::println(Color::error, msg::msgSeeURL, msg::url = docs::manifests_url);
msg::println(Color::error, msgSeeURL, msg::url = docs::manifests_url);
Checks::exit_fail(VCPKG_LINE_INFO);
}

Expand Down
4 changes: 2 additions & 2 deletions src/vcpkg/commands.build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace vcpkg
msg::print(msgElapsedForPackage, msg::spec = spec, msg::elapsed = build_timer);
if (result.code == BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES)
{
LocalizedString errorMsg = msg::format(msg::msgErrorMessage).append(msgBuildDependenciesMissing);
LocalizedString errorMsg = msg::format(msgErrorMessage).append(msgBuildDependenciesMissing);
for (const auto& p : result.unmet_dependencies)
{
errorMsg.append_raw('\n').append_indent().append_raw(p.to_string());
Expand Down Expand Up @@ -339,7 +339,7 @@ namespace vcpkg
msg::arch = target_architecture,
msg::path = toolset.visual_studio_root_path,
msg::list = toolset_list);
msg::println(msg::msgSeeURL, msg::url = docs::vcpkg_visual_studio_path_url);
msg::println(msgSeeURL, msg::url = docs::vcpkg_visual_studio_path_url);
Checks::exit_maybe_upgrade(VCPKG_LINE_INFO);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/commands.install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ namespace vcpkg
if (!options.command_arguments.empty())
{
msg::println_error(msgErrorIndividualPackagesUnsupported);
msg::println(Color::error, msg::msgSeeURL, msg::url = docs::manifests_url);
msg::println(Color::error, msgSeeURL, msg::url = docs::manifests_url);
failure = true;
}
if (use_head_version)
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/portfileprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ namespace vcpkg
}
else
{
return msg::format(msg::msgErrorMessage)
return msg::format(msgErrorMessage)
.append(msgVersionSpecMismatch,
msg::path = path->path,
msg::expected_version = version_spec,
Expand Down
16 changes: 8 additions & 8 deletions src/vcpkg/registries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,30 +665,30 @@ namespace
fs.create_directories(destination_parent, ec);
if (ec)
{
return {msg::format(msg::msgErrorMessage)
return {msg::format(msgErrorMessage)
.append(format_filesystem_call_error(ec, "create_directories", {destination_parent}))
.append_raw('\n')
.append(msg::msgNoteMessage)
.append(msgNoteMessage)
.append(msgWhileCheckingOutBaseline, msg::commit_sha = commit_sha),
expected_right_tag};
}
fs.write_contents(destination_tmp, *contents, ec);
if (ec)
{
return {msg::format(msg::msgErrorMessage)
return {msg::format(msgErrorMessage)
.append(format_filesystem_call_error(ec, "write_contents", {destination_tmp}))
.append_raw('\n')
.append(msg::msgNoteMessage)
.append(msgNoteMessage)
.append(msgWhileCheckingOutBaseline, msg::commit_sha = commit_sha),
expected_right_tag};
}
fs.rename(destination_tmp, destination, ec);
if (ec)
{
return {msg::format(msg::msgErrorMessage)
return {msg::format(msgErrorMessage)
.append(format_filesystem_call_error(ec, "rename", {destination_tmp, destination}))
.append_raw('\n')
.append(msg::msgNoteMessage)
.append(msgNoteMessage)
.append(msgWhileCheckingOutBaseline, msg::commit_sha = commit_sha),
expected_right_tag};
}
Expand Down Expand Up @@ -1124,7 +1124,7 @@ namespace
{
return format_version_git_entry_missing(port_name, version, port_versions)
.append_raw('\n')
.append(msg::msgNoteMessage)
.append(msgNoteMessage)
.append(msgChecksUpdateVcpkg);
}

Expand Down Expand Up @@ -1544,7 +1544,7 @@ namespace vcpkg
ExpectedL<Optional<Version>> RegistrySet::baseline_for_port(StringView port_name) const
{
auto impl = registry_for_port(port_name);
if (!impl) return msg::format(msg::msgErrorMessage).append(msgNoRegistryForPort, msg::package_name = port_name);
if (!impl) return msg::format(msgErrorMessage).append(msgNoRegistryForPort, msg::package_name = port_name);
return impl->get_baseline_version(port_name);
}

Expand Down
6 changes: 3 additions & 3 deletions src/vcpkg/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ namespace vcpkg
}

// If no acceptable tool was found and downloading was unavailable, emit an error message
LocalizedString s = msg::format(msg::msgErrorMessage);
LocalizedString s = msg::format(msgErrorMessage);
s.append(msgToolFetchFailed, msg::tool_name = tool.tool_data_name());
if (env_force_system_binaries && download_available)
{
Expand Down Expand Up @@ -908,7 +908,7 @@ namespace vcpkg
const auto tools = fs.find_from_PATH(Tools::TAR);
if (tools.empty())
{
return msg::format(msg::msgErrorMessage)
return msg::format(msgErrorMessage)
.append(msgToolFetchFailed, msg::tool_name = Tools::TAR)
#if defined(_WIN32)
.append(msgToolInWin10)
Expand Down Expand Up @@ -948,7 +948,7 @@ namespace vcpkg
}
#endif

return msg::format(msg::msgErrorMessage)
return msg::format(msgErrorMessage)
.append(msgToolFetchFailed, msg::tool_name = Tools::CMAKE)
#if !defined(_WIN32)
.append(msgInstallWithSystemManager)
Expand Down
6 changes: 3 additions & 3 deletions src/vcpkg/vcpkgpaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ namespace vcpkg

return std::move(maybe_tree)
.error()
.append(msg::msgNoteMessage)
.append(msgNoteMessage)
.append(msgWhileCheckingOutPortTreeIsh, msg::package_name = port_name, msg::commit_sha = git_tree);
}

Expand Down Expand Up @@ -1009,7 +1009,7 @@ namespace vcpkg
.append_raw('\n')
.append(std::move(maybe_output).error())
.append_raw('\n')
.append(msg::msgNoteMessage)
.append(msgNoteMessage)
.append(msgWhileGettingLocalTreeIshObjectsForPorts);
}

Expand Down Expand Up @@ -1194,7 +1194,7 @@ namespace vcpkg
fs.rename_with_retry(git_tree_temp, destination, ec);
if (ec)
{
return msg::format(msg::msgErrorMessage)
return msg::format(msgErrorMessage)
.append(format_filesystem_call_error(ec, "rename_with_retry", {git_tree_temp, destination}));
}

Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/versions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace vcpkg

static LocalizedString format_invalid_date_version(StringView version)
{
return msg::format(msg::msgErrorMessage).append(msg::format(msgVersionInvalidDate, msg::version = version));
return msg::format(msgErrorMessage).append(msg::format(msgVersionInvalidDate, msg::version = version));
}

ExpectedL<DateVersion> DateVersion::try_parse(StringView version)
Expand Down