diff options
-rw-r--r-- | src/nvim/CMakeLists.txt | 5 | ||||
-rw-r--r-- | third-party/CMakeLists.txt | 8 | ||||
-rw-r--r-- | third-party/cmake/BuildTreesitterParsers.cmake | 28 | ||||
-rw-r--r-- | third-party/cmake/TreesitterParserCMakeLists.txt | 19 |
4 files changed, 60 insertions, 0 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 089dd537e9..29427c7d08 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -546,6 +546,11 @@ else() endif() 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( libnvim STATIC diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index af3ed0c5b3..4b905b7dcb 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -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 # build it unless explicitly requested 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) 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_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) include(BuildUnibilium) endif() @@ -254,6 +258,10 @@ if(USE_BUNDLED_UTF8PROC) include(BuildUtf8proc) endif() +if(USE_BUNDLED_TS_PARSERS) + include(BuildTreesitterParsers) +endif() + if(WIN32) include(GetBinaryDeps) diff --git a/third-party/cmake/BuildTreesitterParsers.cmake b/third-party/cmake/BuildTreesitterParsers.cmake new file mode 100644 index 0000000000..690a8fbed1 --- /dev/null +++ b/third-party/cmake/BuildTreesitterParsers.cmake @@ -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}) diff --git a/third-party/cmake/TreesitterParserCMakeLists.txt b/third-party/cmake/TreesitterParserCMakeLists.txt new file mode 100644 index 0000000000..2808a9ee14 --- /dev/null +++ b/third-party/cmake/TreesitterParserCMakeLists.txt @@ -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) |