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()
|
|
|
|
|
2023-03-05 10:45:34 -07:00
|
|
|
set(NAME treesitter-${TS_LANG})
|
2023-04-04 10:27:21 -07:00
|
|
|
string(TOUPPER "TREESITTER_${TS_LANG}_URL" URL_VARNAME)
|
|
|
|
set(URL ${${URL_VARNAME}})
|
|
|
|
string(TOUPPER "TREESITTER_${TS_LANG}_SHA256" HASH_VARNAME)
|
|
|
|
set(HASH ${${HASH_VARNAME}})
|
|
|
|
|
2021-08-16 06:37:01 -07:00
|
|
|
ExternalProject_Add(${NAME}
|
2023-04-04 10:27:21 -07:00
|
|
|
URL ${URL}
|
|
|
|
URL_HASH SHA256=${HASH}
|
2022-09-29 12:46:14 -07:00
|
|
|
DOWNLOAD_NO_PROGRESS TRUE
|
|
|
|
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-01-25 06:36:17 -07:00
|
|
|
CMAKE_CACHE_ARGS ${DEPS_CMAKE_CACHE_ARGS})
|
2021-08-16 06:37:01 -07:00
|
|
|
endfunction()
|
2020-01-31 15:40:02 -07:00
|
|
|
|
2023-07-01 02:19:31 -07:00
|
|
|
foreach(lang c lua vim vimdoc query python)
|
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)
|