BuildTreesitterParsers.cmake 993 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Helper function to download treesitter parsers
  2. #
  3. # Single value arguments:
  4. # LANG - Parser language
  5. # CMAKE_FILE - Cmake file to build the parser with. Defaults to
  6. # TreesitterParserCMakeLists.txt.
  7. function(BuildTSParser)
  8. cmake_parse_arguments(TS
  9. ""
  10. "LANG;CMAKE_FILE"
  11. ""
  12. ${ARGN})
  13. if(NOT TS_CMAKE_FILE)
  14. set(TS_CMAKE_FILE TreesitterParserCMakeLists.txt)
  15. endif()
  16. set(NAME treesitter_${TS_LANG})
  17. get_externalproject_options(${NAME} ${DEPS_IGNORE_SHA})
  18. ExternalProject_Add(${NAME}
  19. DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/${NAME}
  20. PATCH_COMMAND ${CMAKE_COMMAND} -E copy
  21. ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TS_CMAKE_FILE}
  22. ${DEPS_BUILD_DIR}/src/${NAME}/CMakeLists.txt
  23. CMAKE_ARGS ${DEPS_CMAKE_ARGS}
  24. -D PARSERLANG=${TS_LANG}
  25. ${EXTERNALPROJECT_OPTIONS})
  26. endfunction()
  27. foreach(lang c lua vim vimdoc query)
  28. BuildTSParser(LANG ${lang})
  29. endforeach()
  30. BuildTSParser(LANG markdown CMAKE_FILE MarkdownParserCMakeLists.txt)