mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
688b961d13
Problem: Installing treesitter parser is hard (harder than climbing to heaven). Solution: Add optional support for wasm parsers with `wasmtime`. Notes: * Needs to be enabled by setting `ENABLE_WASMTIME` for tree-sitter and Neovim. Build with `make CMAKE_EXTRA_FLAGS=-DENABLE_WASMTIME=ON DEPS_CMAKE_FLAGS=-DENABLE_WASMTIME=ON` * Adds optional Rust (obviously) and C11 dependencies. * Wasmtime comes with a lot of features that can negatively affect Neovim performance due to library and symbol table size. Make sure to build with minimal features and full LTO. * To reduce re-compilation times, install `sccache` and build with `RUSTC_WRAPPER=<path/to/sccache> make ...`
23 lines
913 B
CMake
23 lines
913 B
CMake
find_path2(WASMTIME_INCLUDE_DIR wasmtime.h)
|
|
find_library2(WASMTIME_LIBRARY wasmtime)
|
|
|
|
if(WASMTIME_INCLUDE_DIR AND EXISTS "${WASMTIME_INCLUDE_DIR}/wasmtime.h")
|
|
file(STRINGS ${WASMTIME_INCLUDE_DIR}/wasmtime.h WASMTIME_VERSION REGEX "#define WASMTIME_VERSION")
|
|
string(REGEX MATCH "[0-9]+\.[0-9]\.[0-9]" WASMTIME_VERSION ${WASMTIME_VERSION})
|
|
endif()
|
|
|
|
find_package_handle_standard_args(Wasmtime
|
|
REQUIRED_VARS WASMTIME_INCLUDE_DIR WASMTIME_LIBRARY
|
|
VERSION_VAR WASMTIME_VERSION)
|
|
|
|
add_library(wasmtime INTERFACE)
|
|
target_include_directories(wasmtime SYSTEM BEFORE INTERFACE ${WASMTIME_INCLUDE_DIR})
|
|
target_link_libraries(wasmtime INTERFACE ${WASMTIME_LIBRARY})
|
|
|
|
if(MSVC)
|
|
target_compile_options(wasmtime INTERFACE -DWASM_API_EXTERN= -DWASI_API_EXTERN=)
|
|
target_link_libraries(wasmtime INTERFACE ws2_32 advapi32 userenv ntdll shell32 ole32 bcrypt)
|
|
endif()
|
|
|
|
mark_as_advanced(WASMTIME_INCLUDE_DIR WASMTIME_LIBRARY)
|