Skip to content

Commit

Permalink
Merge pull request #502 from metacall/fix/node-multithread-deadlock
Browse files Browse the repository at this point in the history
First PoC for solving threading issues in node loader.
  • Loading branch information
viferga authored May 23, 2024
2 parents 4768980 + a2ee85a commit e3a6bab
Show file tree
Hide file tree
Showing 9 changed files with 1,047 additions and 1,742 deletions.
36 changes: 26 additions & 10 deletions cmake/FindNodeJS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,17 @@ if(NodeJS_INCLUDE_DIR)
# Get node module version
find_file(NodeJS_VERSION_FILE_PATH node_version.h
PATHS ${NodeJS_INCLUDE_DIR}
PATH_SUFFIXES ${NodeJS_INCLUDE_SUFFIXES}
DOC "NodeJS JavaScript Version Header"
)

if(NOT NodeJS_VERSION_FILE_PATH)
find_file(NodeJS_VERSION_FILE_PATH node_version.h
PATHS ${NodeJS_INCLUDE_DIR}
PATH_SUFFIXES ${NodeJS_INCLUDE_SUFFIXES}
DOC "NodeJS JavaScript Version Header"
)
endif()

if(NodeJS_VERSION_FILE_PATH)
file(READ ${NodeJS_VERSION_FILE_PATH} NodeJS_VERSION_FILE)

Expand Down Expand Up @@ -367,21 +374,30 @@ if(NodeJS_MODULE_VERSION)
if(NOT NodeJS_BUILD_FROM_SOURCE)
message(STATUS "Searching NodeJS library version ${NodeJS_MODULE_VERSION}")

if(WIN32)
set(NodeJS_LIBRARY_PATH "C:/Program Files/nodejs")
else()
set(NodeJS_LIBRARY_PATH "/usr/local/lib")
endif()

set(NodeJS_SYSTEM_LIBRARY_PATH "/lib/x86_64-linux-gnu" "/usr/lib/x86_64-linux-gnu") # TODO: Add others

# Find library
find_library(NodeJS_LIBRARY
NAMES ${NodeJS_LIBRARY_NAMES}
PATHS ${NodeJS_LIBRARY_PATH} ${NodeJS_SYSTEM_LIBRARY_PATH}
HINTS ${NodeJS_PATHS}
PATH_SUFFIXES lib
DOC "NodeJS JavaScript Runtime Library"
)

if(NOT NodeJS_LIBRARY)
if(WIN32)
set(NodeJS_LIBRARY_PATH "C:/Program Files/nodejs")
else()
set(NodeJS_LIBRARY_PATH "/usr/local/lib" "/usr/lib")
endif()

set(NodeJS_SYSTEM_LIBRARY_PATH "/lib/x86_64-linux-gnu" "/usr/lib/x86_64-linux-gnu") # TODO: Add others

find_library(NodeJS_LIBRARY
NAMES ${NodeJS_LIBRARY_NAMES}
PATHS ${NodeJS_LIBRARY_PATH} ${NodeJS_SYSTEM_LIBRARY_PATH}
DOC "NodeJS JavaScript Runtime Library"
)
endif()

if(NodeJS_LIBRARY)
message(STATUS "NodeJS Library Found")
endif()
Expand Down
2 changes: 1 addition & 1 deletion source/cli/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ add_subdirectory(cli_core_plugin)
# NodeJS added util.parseArgs([config]) in versions v18.3.0, v16.17.0
# Check for compatibility, otherwise use fallback command parser in the CLI
if(NOT (NodeJS_VERSION VERSION_GREATER_EQUAL "18.3.0" OR (NodeJS_VERSION_MAJOR LESS 18 AND NodeJS_VERSION VERSION_GREATER_EQUAL "16.17.0")))
message(WARNING "NodeJS version ${NodeJS_VERSION} does not support ${target}, at least v18.3.0 or v16.17.0 are required, using fallback command parser")
message(WARNING "NodeJS version ${NodeJS_VERSION} does not support CLI command line plugins, at least v18.3.0 or v16.17.0 are required, using fallback command parser")
return()
endif()

Expand Down
Loading

0 comments on commit e3a6bab

Please sign in to comment.