| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Small comments. The current test failure is due to test/message/node_run_non_existent.out.
After these small changes, I think we can ship it! Thank you for your contribution (and welcome!)
Sorry, something went wrong.
Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
Co-authored-by: Yagiz Nizipli <yagiz@nizipli.com>
Sorry, something went wrong.
Sorry, something went wrong.
|
Compilation error on Windows: node_task_runner.cc C:\workspace\node-compile-windows\node\src\node_task_runner.cc(210,27): error C2440: '=': cannot convert from 'const std::filesystem::path::value_type *' to 'const char *' [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(210,27): message : Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(259,21): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'const std::filesystem::path::value_type *' [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(259,21): message : consider using '%ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(259,21): message : consider using '%lls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(259,21): message : consider using '%Ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(259,21): message : consider using '%ws' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(276,21): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'const std::filesystem::path::value_type *' [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(276,21): message : consider using '%ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(276,21): message : consider using '%lls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(276,21): message : consider using '%Ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(276,21): message : consider using '%ws' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(285,15): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'const std::filesystem::path::value_type *' [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(285,15): message : consider using '%ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(285,15): message : consider using '%lls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(285,15): message : consider using '%Ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(285,15): message : consider using '%ws' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(288,23): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'const std::filesystem::path::value_type *' [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(288,23): message : consider using '%ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(288,23): message : consider using '%lls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(288,23): message : consider using '%Ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(288,23): message : consider using '%ws' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(297,21): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'const std::filesystem::path::value_type *' [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(297,21): message : consider using '%ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(297,21): message : consider using '%lls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(297,21): message : consider using '%Ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(297,21): message : consider using '%ws' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(308,15): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 3 has type 'const std::filesystem::path::value_type *' [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(308,15): message : consider using '%ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(308,15): message : consider using '%lls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(308,15): message : consider using '%Ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(308,15): message : consider using '%ws' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(314,15): warning C4477: 'fprintf' : format string '%s' requires an argument of type 'char *', but variadic argument 3 has type 'const std::filesystem::path::value_type *' [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(314,15): message : consider using '%ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(314,15): message : consider using '%lls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(314,15): message : consider using '%Ls' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] C:\workspace\node-compile-windows\node\src\node_task_runner.cc(314,15): message : consider using '%ws' in the format string [C:\workspace\node-compile-windows\node\libnode.vcxproj] |
Sorry, something went wrong.
|
I'll check these compilation errors. |
Sorry, something went wrong.
|
@StefanStojanovic I believe these likely came from removing some .c_str() calls |
Sorry, something went wrong.
|
The issue here is the character type of std::filesystem::path (value_type) differs on Windows, where it is a wchar_t, compared to other platforms where it is char (Source: https://en.cppreference.com/w/cpp/filesystem/path). So, since that is the reason I've added an ifdef _WIN32 and added code to convert data to the correct format. I was able to compile with this change locally. @bmeck if this change makes sense to you feel free to apply the patch I provided in this comment to your branch. From fc0f3ed6c020eb0180065bc89bce026b68e2216f Mon Sep 17 00:00:00 2001
From: StefanStojanovic <stefan.stojanovic@janeasystems.com>
Date: Tue, 9 Jul 2024 20:23:48 +0200
Subject: [PATCH 1/1] ProcessRunner::Run Windows fix
---
src/node_task_runner.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/node_task_runner.cc b/src/node_task_runner.cc
index cb2defee973..0c37b1072d6 100644
--- a/src/node_task_runner.cc
+++ b/src/node_task_runner.cc
@@ -207,7 +207,15 @@ void ProcessRunner::OnExit(int64_t exit_status, int term_signal) {
void ProcessRunner::Run() {
// keeps the string alive until destructor
auto cwd = package_json_path_.parent_path();
+#ifdef _WIN32
+ std::wstring cwd_wstr = cwd.wstring();
+ int size = WideCharToMultiByte(CP_UTF8, 0, cwd_wstr.c_str(), -1, nullptr, 0, nullptr, nullptr);
+ std::string cwd_string(size, 0);
+ WideCharToMultiByte(CP_UTF8, 0, cwd_wstr.c_str(), -1, &cwd_string[0], size, nullptr, nullptr);
+ options_.cwd = cwd_string.c_str();
+#else
options_.cwd = cwd.c_str();
+#endif
if (int r = uv_spawn(loop_, &process_, &options_)) {
fprintf(stderr, "Error: %s\n", uv_strerror(r));
}
--
2.45.2.windows.1
|
Sorry, something went wrong.
|
@StefanStojanovic I'm ok with an ifdef but we would want to add it to quite a few places according to above |
Sorry, something went wrong.
If you are referring to the #53600 (comment), other logs are just warnings so at least the compilation would succeed. A potential problem is that those logs would be unusable. The good thing is that all of the warnings are from the same function RunTask and most of them (all except one) use the same value, so it shouldn't be too hard to fix them all in one place, or simply use %ls instead of %s on Windows. One question I have though - what would be the easiest way to reproduce showing some of these logs? |
Sorry, something went wrong.
|
You can run path.string() and convert the filesystem path to a std::string. It will create an unnecessary string and copy operation but it will work for both operating systems without any ifdef. |
Sorry, something went wrong.
|
@StefanStojanovic is currently on vacation so I will be handling this in the meantime. Thanks @anonrig, I've used the function that you've provided. @bmeck I'm able to compile with the patch below locally. If this fix makes sense to you, feel free to apply it. diff --git a/src/node_task_runner.cc b/src/node_task_runner.cc
index cb2defee973..429b72e3e5f 100644
--- a/src/node_task_runner.cc
+++ b/src/node_task_runner.cc
@@ -207,7 +207,7 @@ void ProcessRunner::OnExit(int64_t exit_status, int term_signal) {
void ProcessRunner::Run() {
// keeps the string alive until destructor
auto cwd = package_json_path_.parent_path();
- options_.cwd = cwd.c_str();
+ options_.cwd = cwd.string().c_str();
if (int r = uv_spawn(loop_, &process_, &options_)) {
fprintf(stderr, "Error: %s\n", uv_strerror(r));
}
@@ -256,7 +256,7 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
auto package_json = FindPackageJson(cwd);
if (!package_json.has_value()) {
- fprintf(stderr, "Can't find package.json for directory %s\n", cwd.c_str());
+ fprintf(stderr, "Can't find package.json for directory %s\n", cwd.string().c_str());
result->exit_code_ = ExitCode::kGenericUserError;
return;
}
@@ -273,7 +273,7 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
simdjson::error_code error = json_parser.iterate(raw_json).get(document);
if (error) {
- fprintf(stderr, "Can't parse %s\n", path.c_str());
+ fprintf(stderr, "Can't parse %s\n", path.string().c_str());
result->exit_code_ = ExitCode::kGenericUserError;
return;
}
@@ -283,9 +283,9 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
if (root_error == simdjson::error_code::INCORRECT_TYPE) {
fprintf(stderr,
"Root value unexpected not an object for %s\n\n",
- path.c_str());
+ path.string().c_str());
} else {
- fprintf(stderr, "Can't parse %s\n", path.c_str());
+ fprintf(stderr, "Can't parse %s\n", path.string().c_str());
}
result->exit_code_ = ExitCode::kGenericUserError;
return;
@@ -294,7 +294,7 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
// If package_json object doesn't have "scripts" field, throw an error.
simdjson::ondemand::object scripts_object;
if (main_object["scripts"].get_object().get(scripts_object)) {
- fprintf(stderr, "Can't find \"scripts\" field in %s\n", path.c_str());
+ fprintf(stderr, "Can't find \"scripts\" field in %s\n", path.string().c_str());
result->exit_code_ = ExitCode::kGenericUserError;
return;
}
@@ -308,13 +308,13 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
"Script \"%.*s\" is unexpectedly not a string for %s\n\n",
static_cast<int>(command_id.size()),
command_id.data(),
- path.c_str());
+ path.string().c_str());
} else {
fprintf(stderr,
"Missing script: \"%.*s\" for %s\n\n",
static_cast<int>(command_id.size()),
command_id.data(),
- path.c_str());
+ path.string().c_str());
fprintf(stderr, "Available scripts are:\n");
// Reset the object to iterate over it again
|
Sorry, something went wrong.
|
Needs to be rebased with new CI runs. Removed the author ready and commit queue labels. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
No description provided.