From ad3cdd64c6c9958e1248ca612aebd138252103fa Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 10 Oct 2023 19:09:40 +0000 Subject: [PATCH 1/3] Extract msg:: removal from #1210 --- docs/localization.md | 2 +- include/vcpkg/base/messages.h | 10 ---------- src/vcpkg/base/checks.cpp | 10 +++++----- src/vcpkg/base/hash.cpp | 4 ++-- src/vcpkg/base/message_sinks.cpp | 4 ++-- src/vcpkg/base/messages.cpp | 11 ----------- src/vcpkg/base/parse.cpp | 4 ++-- src/vcpkg/binarycaching.cpp | 12 ++++++------ src/vcpkg/commands.add.cpp | 2 +- src/vcpkg/commands.build.cpp | 4 ++-- src/vcpkg/commands.install.cpp | 2 +- src/vcpkg/portfileprovider.cpp | 2 +- src/vcpkg/registries.cpp | 16 ++++++++-------- src/vcpkg/tools.cpp | 6 +++--- src/vcpkg/vcpkgpaths.cpp | 12 ++++++------ src/vcpkg/versions.cpp | 2 +- 16 files changed, 41 insertions(+), 62 deletions(-) diff --git a/docs/localization.md b/docs/localization.md index 6d55420d8a..c4662f277f 100644 --- a/docs/localization.md +++ b/docs/localization.md @@ -51,7 +51,7 @@ Messages in vcpkg are written in American English. They should not contain: - 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` + - `"error: "`, instead use `msgErrorMessage` - `"internal error: "`, instead use `msg::msgInternalErrorMessage`. They should also not be simple, locale-invariant messages -- something like, for example, diff --git a/include/vcpkg/base/messages.h b/include/vcpkg/base/messages.h index 980df1b6d7..767784602b 100644 --- a/include/vcpkg/base/messages.h +++ b/include/vcpkg/base/messages.h @@ -267,14 +267,4 @@ namespace vcpkg #include #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; - } } diff --git a/src/vcpkg/base/checks.cpp b/src/vcpkg/base/checks.cpp index 020e45e1bb..6e7c5fc7b5 100644 --- a/src/vcpkg/base/checks.cpp +++ b/src/vcpkg/base/checks.cpp @@ -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); } } @@ -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); } } @@ -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) diff --git a/src/vcpkg/base/hash.cpp b/src/vcpkg/base/hash.cpp index 81608efe6a..c0103db4ec 100644 --- a/src/vcpkg/base/hash.cpp +++ b/src/vcpkg/base/hash.cpp @@ -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()); } @@ -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()); } diff --git a/src/vcpkg/base/message_sinks.cpp b/src/vcpkg/base/message_sinks.cpp index 62ffcebed2..c1f92349d0 100644 --- a/src/vcpkg/base/message_sinks.cpp +++ b/src/vcpkg/base/message_sinks.cpp @@ -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; diff --git a/src/vcpkg/base/messages.cpp b/src/vcpkg/base/messages.cpp index c2ca00e5d3..374cae96da 100644 --- a/src/vcpkg/base/messages.cpp +++ b/src/vcpkg/base/messages.cpp @@ -276,17 +276,6 @@ namespace vcpkg #include #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 { diff --git a/src/vcpkg/base/parse.cpp b/src/vcpkg/base/parse.cpp index 2b1bedc5d3..363ab554c7 100644 --- a/src/vcpkg/base/parse.cpp +++ b/src/vcpkg/base/parse.cpp @@ -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); diff --git a/src/vcpkg/binarycaching.cpp b/src/vcpkg/binarycaching.cpp index fcb035a278..ad78d9c761 100644 --- a/src/vcpkg/binarycaching.cpp +++ b/src/vcpkg/binarycaching.cpp @@ -2307,23 +2307,23 @@ ExpectedL 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 get_url; diff --git a/src/vcpkg/commands.add.cpp b/src/vcpkg/commands.add.cpp index ecb43ddc91..b194314c87 100644 --- a/src/vcpkg/commands.add.cpp +++ b/src/vcpkg/commands.add.cpp @@ -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); } diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 95915895a7..27e7f6b216 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -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()); @@ -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 diff --git a/src/vcpkg/commands.install.cpp b/src/vcpkg/commands.install.cpp index f273cad255..8ccd17875d 100644 --- a/src/vcpkg/commands.install.cpp +++ b/src/vcpkg/commands.install.cpp @@ -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) diff --git a/src/vcpkg/portfileprovider.cpp b/src/vcpkg/portfileprovider.cpp index 5eb0174f7e..472037ed91 100644 --- a/src/vcpkg/portfileprovider.cpp +++ b/src/vcpkg/portfileprovider.cpp @@ -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, diff --git a/src/vcpkg/registries.cpp b/src/vcpkg/registries.cpp index b02ec1f785..26f464e16c 100644 --- a/src/vcpkg/registries.cpp +++ b/src/vcpkg/registries.cpp @@ -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}; } @@ -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); } @@ -1544,7 +1544,7 @@ namespace vcpkg ExpectedL> 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); } diff --git a/src/vcpkg/tools.cpp b/src/vcpkg/tools.cpp index 8b0762a752..c4cd4a2c62 100644 --- a/src/vcpkg/tools.cpp +++ b/src/vcpkg/tools.cpp @@ -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) { @@ -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) @@ -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) diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 5289bc985d..0129ba561a 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -76,9 +76,9 @@ namespace auto manifest_opt = Json::parse_file(fs, manifest_path, ec); if (ec) { - Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, - msg::format(msgFailedToLoadManifest, msg::path = manifest_dir) - .append_raw('\n') + Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, + msg::format(msgFailedToLoadManifest, msg::path = manifest_dir) + .append_raw('\n') .append_raw(ec.message())); } @@ -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); } @@ -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); } @@ -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})); } diff --git a/src/vcpkg/versions.cpp b/src/vcpkg/versions.cpp index 7cfbcc400e..7b09d4df50 100644 --- a/src/vcpkg/versions.cpp +++ b/src/vcpkg/versions.cpp @@ -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::try_parse(StringView version) From f56d766079ebdd88becd2a34290c4f48af934ffa Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 10 Oct 2023 19:11:13 +0000 Subject: [PATCH 2/3] Fixup localization.md --- docs/localization.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/localization.md b/docs/localization.md index c4662f277f..95407b4321 100644 --- a/docs/localization.md +++ b/docs/localization.md @@ -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)` + - `"warning: "`, instead use `msg::format(msgWarningMessage).append(msgMyWarning)` - `"error: "`, instead use `msgErrorMessage` - - `"internal error: "`, instead use `msg::msgInternalErrorMessage`. + - `"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))`. From 076c480ca6b9d3e24e5c2db1966d3e6a8113c7fc Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Tue, 10 Oct 2023 15:06:38 -0700 Subject: [PATCH 3/3] clang-format --- src/vcpkg/vcpkgpaths.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index 0129ba561a..96226e1680 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -76,9 +76,9 @@ namespace auto manifest_opt = Json::parse_file(fs, manifest_path, ec); if (ec) { - Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, - msg::format(msgFailedToLoadManifest, msg::path = manifest_dir) - .append_raw('\n') + Checks::msg_exit_maybe_upgrade(VCPKG_LINE_INFO, + msg::format(msgFailedToLoadManifest, msg::path = manifest_dir) + .append_raw('\n') .append_raw(ec.message())); }