Skip to content

Commit e6824f0

Browse files
authored
Merge pull request #564 from metacall/feature/msvc-2022
MSVC 2022 and 2025 support
2 parents 1afb052 + 96df3a3 commit e6824f0

File tree

29 files changed

+208
-82
lines changed

29 files changed

+208
-82
lines changed

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
strategy:
100100
fail-fast: false
101101
matrix:
102-
os: [windows-2019]
102+
os: [windows-2022, windows-2025]
103103

104104
env:
105105
LTTNG_UST_REGISTER_TIMEOUT: 0

.github/workflows/windows-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ concurrency:
1717
jobs:
1818
windows-test:
1919
name: Windows MSVC Test
20-
runs-on: ${{ matrix.os }}
20+
runs-on: windows-${{ matrix.os }}
2121

2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
os: [windows-2019, windows-2022, windows-2025]
25+
os: [2022, 2025]
2626
options: [
2727
{build: debug, sanitizer: without-sanitizer},
2828
{build: debug, sanitizer: address-sanitizer},
@@ -32,7 +32,7 @@ jobs:
3232
# {build: debug, sanitizer: memory-sanitizer},
3333

3434
# TODO: https://github.com/metacall/core/issues/461
35-
# {build: release, sanitizer: without-sanitizer}
35+
{build: release, sanitizer: without-sanitizer}
3636
]
3737

3838
steps:

cmake/CompileOptions.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,14 @@ if(WIN32 AND MSVC)
319319
add_compile_options(/Oy)
320320

321321
# TODO: Disable runtime checks (not compatible with O2)
322-
# foreach(FLAG_VAR
322+
# foreach(COMPILER_FLAGS
323323
# CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE
324324
# CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
325325
# CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE
326326
# CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
327327
# )
328-
# string(REGEX REPLACE "/RTC[^ ]*" "" ${FLAG_VAR} "${${FLAG_VAR}}")
329-
# endforeach(FLAG_VAR)
328+
# string(REGEX REPLACE "/RTC[^ ]*" "" ${COMPILER_FLAGS} "${${COMPILER_FLAGS}}")
329+
# endforeach(COMPILER_FLAGS)
330330

331331
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
332332
# Enable debug symbols
@@ -348,6 +348,7 @@ if(WIN32 AND MSVC)
348348
add_compile_options(/fsanitize=leak)
349349
add_link_options(/INCREMENTAL:NO)
350350
endif()
351+
351352
endif()
352353

353354
if (PROJECT_OS_FAMILY MATCHES "unix" OR PROJECT_OS_FAMILY MATCHES "macos")

cmake/FindNodeJS.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,9 @@ if(NOT NodeJS_LIBRARY)
453453
endif()
454454

455455
# Check for Visual Studio Version and configure the build command
456-
if(MSVC_VERSION GREATER 1916)
456+
if(MSVC_VERSION GREATER_EQUAL 1930)
457+
set(NodeJS_MSVC_VER vs2022)
458+
elseif(MSVC_VERSION GREATER_EQUAL 1920)
457459
set(NodeJS_MSVC_VER vs2019)
458460
elseif(MSVC_VERSION GREATER 1900)
459461
set(NodeJS_MSVC_VER vs2017)

cmake/InstallGTest.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ if(NOT GTEST_FOUND OR USE_BUNDLED_GTEST)
3535
set(GTEST_DISABLE_PTHREADS OFF)
3636
endif()
3737

38+
if(MSVC AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
39+
if(OPTION_BUILD_THREAD_SANITIZER)
40+
set(SANITIZER_FLAGS -DCMAKE_CXX_FLAGS=/fsanitize=thread -DCMAKE_C_FLAGS=/fsanitize=thread)
41+
endif()
42+
if(OPTION_BUILD_ADDRESS_SANITIZER)
43+
set(SANITIZER_FLAGS -DCMAKE_CXX_FLAGS=/fsanitize=address -DCMAKE_C_FLAGS=/fsanitize=address)
44+
endif()
45+
if(OPTION_BUILD_MEMORY_SANITIZER)
46+
set(SANITIZER_FLAGS -DCMAKE_CXX_FLAGS="/fsanitize=memory /fsanitize=leak" -DCMAKE_C_FLAGS="/fsanitize=memory /fsanitize=leak")
47+
endif()
48+
endif()
49+
3850
# Import Google Test Framework
3951
ExternalProject_Add(google-test-depends
4052
GIT_REPOSITORY https://github.com/google/googletest.git
@@ -48,6 +60,7 @@ if(NOT GTEST_FOUND OR USE_BUNDLED_GTEST)
4860
-DINSTALL_GTEST=OFF
4961
-DBUILD_GMOCK=ON
5062
-Dgmock_build_tests=OFF
63+
${SANITIZER_FLAGS}
5164
PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
5265
UPDATE_COMMAND ""
5366
INSTALL_COMMAND ""

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,8 @@ Where `script.js` is a script contained in host folder `$HOME/metacall` that wil
862862
| :-----------------: | :--------------------------------------------------: |
863863
| **`ubuntu-latest`** | https://metacall.github.io/core/bench/ubuntu-latest/ |
864864
| **`macos-latest`** | https://metacall.github.io/core/bench/macos-latest/ |
865-
| **`windows-2019`** | https://metacall.github.io/core/bench/windows-2019/ |
865+
| **`windows-2022`** | https://metacall.github.io/core/bench/windows-2022/ |
866+
| **`windows-2025`** | https://metacall.github.io/core/bench/windows-2025/ |
866867

867868
## 9. License
868869

source/cli/metacallcli/source/application.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,19 @@ bool application::cmd(std::vector<std::string> &arguments)
134134
/* Initialize CMD descriptors */
135135
std::string plugin_path(metacall_plugin_path());
136136

137-
void *args[] = {
137+
void *command_initialize_args[] = {
138138
metacall_value_create_string(plugin_path.c_str(), plugin_path.length())
139139
};
140140

141-
void *command_initialize_ret = metacallhv_s(plugin_cli_handle, "command_initialize", args, sizeof(args) / sizeof(args[0]));
141+
void *command_initialize_ret = metacallhv_s(plugin_cli_handle, "command_initialize", command_initialize_args, sizeof(command_initialize_args) / sizeof(command_initialize_args[0]));
142142

143143
check_for_exception(command_initialize_ret);
144144

145+
for (void *arg : command_initialize_args)
146+
{
147+
metacall_value_destroy(arg);
148+
}
149+
145150
/* Convert all arguments into metacall value strings */
146151
std::vector<void *> arguments_values;
147152
arguments_values.reserve(arguments.size());
@@ -179,11 +184,11 @@ bool application::cmd(std::vector<std::string> &arguments)
179184
{
180185
void **command_pair = metacall_value_to_array(command_map[iterator]);
181186

182-
void *args[] = {
187+
void *command_args[] = {
183188
command_pair[0]
184189
};
185190

186-
void *command_func = metacallfv_s(command_function_func, args, sizeof(args) / sizeof(args[0]));
191+
void *command_func = metacallfv_s(command_function_func, command_args, sizeof(command_args) / sizeof(command_args[0]));
187192

188193
if (metacall_value_id(command_func) == METACALL_FUNCTION)
189194
{

source/extensions/plugin_extension/source/plugin_extension.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace fs = std::experimental::filesystem;
4040

4141
static void *extension_loader = NULL;
4242

43-
void *plugin_load_from_path(size_t argc, void *args[], void *data)
43+
static void *plugin_load_from_path(size_t argc, void *args[], void *data)
4444
{
4545
/* TODO: Improve return values with throwable in the future */
4646
(void)data;

source/loader/include/loader/loader_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ LOADER_API loader_impl loader_impl_create(const loader_tag tag);
4545

4646
LOADER_API loader_impl loader_impl_create_host(const loader_tag tag);
4747

48-
LOADER_API int loader_impl_dependencies(loader_impl impl, detour d);
48+
LOADER_API int loader_impl_dependencies(loader_impl impl, detour d, const loader_tag tag);
4949

5050
LOADER_API int loader_impl_link(plugin p, loader_impl impl);
5151

source/loader/source/loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ plugin loader_get_impl_plugin_options(const loader_tag tag, value options)
250250
loader_impl_set_options(impl, options);
251251

252252
/* Dynamic link loader dependencies if it is not host */
253-
if (loader_impl_dependencies(impl, plugin_manager_impl_type(&loader_manager, loader_manager_impl)->d) != 0)
253+
if (loader_impl_dependencies(impl, plugin_manager_impl_type(&loader_manager, loader_manager_impl)->d, tag) != 0)
254254
{
255255
goto plugin_manager_create_error;
256256
}

0 commit comments

Comments
 (0)