aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-11-13 13:25:10 +0100
committerbfredl <bjorn.linse@gmail.com>2024-11-21 12:41:15 +0100
commitbe89d520d7e9ad6c574c259a10f282177fb5dd4a (patch)
treea914be3ca2c3e4196a97bc072e4ea2cc55962333
parentf164e1e35c4144baa55dda1120be6c75fb250c4b (diff)
downloadrneovim-be89d520d7e9ad6c574c259a10f282177fb5dd4a.tar.gz
rneovim-be89d520d7e9ad6c574c259a10f282177fb5dd4a.tar.bz2
rneovim-be89d520d7e9ad6c574c259a10f282177fb5dd4a.zip
refactor(windows)!: only support UCRT, even for mingw
The newer UCRT runtime has native support for UTF-8, including forcing it as the active codepage even before `main()` is called. This means the c runtime will properly convert windows WCHAR:s into UTF-8 bytes, as early as the argv/argc params to `main()` . Whereas MSVCRT does not support this reliably and required us to use `wmain()`. Only MSVC supports using manifest files directly as source files. The solution for other Windows toolchains is to use a .rc file.
-rw-r--r--runtime/doc/news.txt4
-rw-r--r--src/nvim/CMakeLists.txt4
-rw-r--r--src/nvim/main.c15
-rw-r--r--src/nvim/os/nvim.rc2
-rw-r--r--test/functional/fixtures/CMakeLists.txt3
5 files changed, 11 insertions, 17 deletions
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index fc714526d4..c8d0df5c96 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -45,6 +45,10 @@ API
• Renamed `nvim__id_dictionary` (unsupported/experimental API) to
`nvim__id_dict`.
+BUILD
+
+On Windows, only building with the UCRT runtime is supported.
+
DEFAULTS
• |]d-default| and |[d-default| accept a count.
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index cb71144130..1b6827322d 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -120,8 +120,8 @@ elseif(MINGW)
# Use POSIX compatible stdio in Mingw
target_compile_definitions(main_lib INTERFACE __USE_MINGW_ANSI_STDIO)
- # Enable wmain
- target_link_libraries(nvim_bin PRIVATE -municode)
+ # wrapper for nvim.manifest
+ target_sources(main_lib INTERFACE ${CMAKE_CURRENT_LIST_DIR}/os/nvim.rc)
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(main_lib INTERFACE
-Wno-conversion
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 695bd4c95a..dc4969759d 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -111,6 +111,9 @@
#ifdef MSWIN
# include "nvim/os/os_win_console.h"
+# ifndef _UCRT
+# error UCRT is the only supported C runtime on windows
+# endif
#endif
#if defined(MSWIN) && !defined(MAKE_LIB)
@@ -241,22 +244,10 @@ void early_init(mparm_T *paramp)
#ifdef MAKE_LIB
int nvim_main(int argc, char **argv); // silence -Wmissing-prototypes
int nvim_main(int argc, char **argv)
-#elif defined(MSWIN)
-int wmain(int argc, wchar_t **argv_w) // multibyte args on Windows. #7060
#else
int main(int argc, char **argv)
#endif
{
-#if defined(MSWIN) && !defined(MAKE_LIB)
- char **argv = xmalloc((size_t)argc * sizeof(char *));
- for (int i = 0; i < argc; i++) {
- char *buf = NULL;
- utf16_to_utf8(argv_w[i], -1, &buf);
- assert(buf);
- argv[i] = buf;
- }
-#endif
-
argv0 = argv[0];
if (!appname_is_valid()) {
diff --git a/src/nvim/os/nvim.rc b/src/nvim/os/nvim.rc
new file mode 100644
index 0000000000..e838c93c16
--- /dev/null
+++ b/src/nvim/os/nvim.rc
@@ -0,0 +1,2 @@
+#include "winuser.h"
+2 RT_MANIFEST nvim.manifest
diff --git a/test/functional/fixtures/CMakeLists.txt b/test/functional/fixtures/CMakeLists.txt
index 150407fe46..a388f9cb33 100644
--- a/test/functional/fixtures/CMakeLists.txt
+++ b/test/functional/fixtures/CMakeLists.txt
@@ -1,7 +1,4 @@
add_library(test_lib INTERFACE)
-if(MINGW)
- target_link_libraries(test_lib INTERFACE -municode)
-endif()
if(WIN32)
target_compile_definitions(test_lib INTERFACE MSWIN)
endif()