2023-04-04 10:27:21 -07:00
|
|
|
# Helper function to download treesitter parsers
|
|
|
|
#
|
|
|
|
# Single value arguments:
|
|
|
|
# LANG - Parser language
|
|
|
|
# CMAKE_FILE - Cmake file to build the parser with. Defaults to
|
|
|
|
# TreesitterParserCMakeLists.txt.
|
2023-03-05 10:45:34 -07:00
|
|
|
function(BuildTSParser)
|
|
|
|
cmake_parse_arguments(TS
|
|
|
|
""
|
2023-04-04 10:27:21 -07:00
|
|
|
"LANG;CMAKE_FILE"
|
2023-03-05 10:45:34 -07:00
|
|
|
""
|
|
|
|
${ARGN})
|
|
|
|
|
2023-04-04 10:27:21 -07:00
|
|
|
if(NOT TS_CMAKE_FILE)
|
|
|
|
set(TS_CMAKE_FILE TreesitterParserCMakeLists.txt)
|
|
|
|
endif()
|
|
|
|
|
2024-03-18 04:23:53 -07:00
|
|
|
set(NAME treesitter_${TS_LANG})
|
2023-04-04 10:27:21 -07:00
|
|
|
|
2024-03-18 04:23:53 -07:00
|
|
|
get_externalproject_options(${NAME} ${DEPS_IGNORE_SHA})
|
2021-08-16 06:37:01 -07:00
|
|
|
ExternalProject_Add(${NAME}
|
2022-09-29 12:46:14 -07:00
|
|
|
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/${NAME}
|
|
|
|
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
|
2021-08-16 06:37:01 -07:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TS_CMAKE_FILE}
|
|
|
|
${DEPS_BUILD_DIR}/src/${NAME}/CMakeLists.txt
|
2023-01-25 06:36:17 -07:00
|
|
|
CMAKE_ARGS ${DEPS_CMAKE_ARGS}
|
2023-03-05 10:45:34 -07:00
|
|
|
-D PARSERLANG=${TS_LANG}
|
2023-11-20 04:42:54 -07:00
|
|
|
${EXTERNALPROJECT_OPTIONS})
|
2021-08-16 06:37:01 -07:00
|
|
|
endfunction()
|
2020-01-31 15:40:02 -07:00
|
|
|
|
2023-07-01 02:22:19 -07:00
|
|
|
foreach(lang c lua vim vimdoc query python bash)
|
2023-04-04 10:27:21 -07:00
|
|
|
BuildTSParser(LANG ${lang})
|
|
|
|
endforeach()
|
2023-07-01 02:08:06 -07:00
|
|
|
BuildTSParser(LANG markdown CMAKE_FILE MarkdownParserCMakeLists.txt)
|