mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 09:56:31 +00:00
build: include tree-sitter-c parser in bundled build
This commit is contained in:
@@ -546,6 +546,11 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
set_target_properties(nvim_runtime_deps PROPERTIES FOLDER deps)
|
set_target_properties(nvim_runtime_deps PROPERTIES FOLDER deps)
|
||||||
|
|
||||||
|
file(COPY ${DEPS_PREFIX}/lib/nvim/parser DESTINATION ${PROJECT_BINARY_DIR}/lib/nvim/)
|
||||||
|
install(DIRECTORY ${PROJECT_BINARY_DIR}/lib/nvim/
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/nvim/
|
||||||
|
USE_SOURCE_PERMISSIONS)
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
libnvim
|
libnvim
|
||||||
STATIC
|
STATIC
|
||||||
|
8
third-party/CMakeLists.txt
vendored
8
third-party/CMakeLists.txt
vendored
@@ -42,6 +42,7 @@ option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED})
|
|||||||
#XXX(tarruda): Lua is only used for debugging the functional test client, no
|
#XXX(tarruda): Lua is only used for debugging the functional test client, no
|
||||||
# build it unless explicitly requested
|
# build it unless explicitly requested
|
||||||
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
||||||
|
option(USE_BUNDLED_TS_PARSERS "Use the bundled treesitter parsers." ${USE_BUNDLED})
|
||||||
|
|
||||||
if(USE_BUNDLED AND MSVC)
|
if(USE_BUNDLED AND MSVC)
|
||||||
option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." ON)
|
option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." ON)
|
||||||
@@ -199,6 +200,9 @@ set(LIBICONV_SHA256 ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc891
|
|||||||
set(UTF8PROC_URL https://github.com/JuliaStrings/utf8proc/archive/v2.2.0.tar.gz)
|
set(UTF8PROC_URL https://github.com/JuliaStrings/utf8proc/archive/v2.2.0.tar.gz)
|
||||||
set(UTF8PROC_SHA256 3f8fd1dbdb057ee5ba584a539d5cd1b3952141c0338557cb0bdf8cb9cfed5dbf)
|
set(UTF8PROC_SHA256 3f8fd1dbdb057ee5ba584a539d5cd1b3952141c0338557cb0bdf8cb9cfed5dbf)
|
||||||
|
|
||||||
|
set(TREESITTER_C_URL https://github.com/tree-sitter/tree-sitter-c/archive/6002fcd.tar.gz)
|
||||||
|
set(TREESITTER_C_SHA256 46f8d44fa886d9ddb92571bb6fa8b175992c8758eca749cb1217464e512b6e97)
|
||||||
|
|
||||||
if(USE_BUNDLED_UNIBILIUM)
|
if(USE_BUNDLED_UNIBILIUM)
|
||||||
include(BuildUnibilium)
|
include(BuildUnibilium)
|
||||||
endif()
|
endif()
|
||||||
@@ -254,6 +258,10 @@ if(USE_BUNDLED_UTF8PROC)
|
|||||||
include(BuildUtf8proc)
|
include(BuildUtf8proc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(USE_BUNDLED_TS_PARSERS)
|
||||||
|
include(BuildTreesitterParsers)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
include(GetBinaryDeps)
|
include(GetBinaryDeps)
|
||||||
|
|
||||||
|
28
third-party/cmake/BuildTreesitterParsers.cmake
vendored
Normal file
28
third-party/cmake/BuildTreesitterParsers.cmake
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
ExternalProject_Add(treesitter-c
|
||||||
|
PREFIX ${DEPS_BUILD_DIR}
|
||||||
|
URL ${TREESITER_C_URL}
|
||||||
|
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/treesitter-c
|
||||||
|
DOWNLOAD_COMMAND ${CMAKE_COMMAND}
|
||||||
|
-DPREFIX=${DEPS_BUILD_DIR}
|
||||||
|
-DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/treesitter-c
|
||||||
|
-DURL=${TREESITTER_C_URL}
|
||||||
|
-DEXPECTED_SHA256=${TREESITTER_C_SHA256}
|
||||||
|
-DTARGET=treesitter-c
|
||||||
|
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
|
||||||
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
|
||||||
|
BUILD_IN_SOURCE 1
|
||||||
|
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/TreesitterParserCMakeLists.txt
|
||||||
|
${DEPS_BUILD_DIR}/src/treesitter-c/CMakeLists.txt
|
||||||
|
COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/treesitter-c/CMakeLists.txt
|
||||||
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||||
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||||
|
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
|
||||||
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
||||||
|
# Pass toolchain
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||||
|
-DPARSERLANG=c
|
||||||
|
|
||||||
|
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
|
||||||
|
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
|
19
third-party/cmake/TreesitterParserCMakeLists.txt
vendored
Normal file
19
third-party/cmake/TreesitterParserCMakeLists.txt
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
# some parsers have c++ scanner, problem?
|
||||||
|
project(parser C) # CXX
|
||||||
|
|
||||||
|
add_library(parser
|
||||||
|
MODULE
|
||||||
|
src/parser.c
|
||||||
|
)
|
||||||
|
set_target_properties(
|
||||||
|
parser
|
||||||
|
PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
OUTPUT_NAME ${PARSERLANG}
|
||||||
|
PREFIX ""
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(src)
|
||||||
|
|
||||||
|
install(TARGETS parser LIBRARY DESTINATION lib/nvim/parser)
|
Reference in New Issue
Block a user