CMakeLists.txt 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. set(SYN_VIM_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/genvimvim.lua)
  2. set(GENERATED_RUNTIME_DIR ${PROJECT_BINARY_DIR}/runtime)
  3. set(GENERATED_SYN_VIM ${GENERATED_RUNTIME_DIR}/syntax/vim/generated.vim)
  4. set(GENERATED_HELP_TAGS ${GENERATED_RUNTIME_DIR}/doc/tags)
  5. set(GENERATED_PACKAGE_DIR ${GENERATED_RUNTIME_DIR}/pack/dist/opt)
  6. set(FUNCS_DATA ${PROJECT_BINARY_DIR}/funcs_data.mpack)
  7. file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR})
  8. file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax)
  9. file(MAKE_DIRECTORY ${GENERATED_RUNTIME_DIR}/syntax/vim)
  10. add_custom_command(OUTPUT ${GENERATED_SYN_VIM}
  11. COMMAND ${LUA_PRG} ${SYN_VIM_GENERATOR}
  12. ${PROJECT_SOURCE_DIR}/src/nvim ${GENERATED_SYN_VIM} ${FUNCS_DATA}
  13. DEPENDS
  14. ${SYN_VIM_GENERATOR}
  15. ${PROJECT_SOURCE_DIR}/src/nvim/ex_cmds.lua
  16. ${PROJECT_SOURCE_DIR}/src/nvim/auevents.lua
  17. ${PROJECT_SOURCE_DIR}/src/nvim/options.lua
  18. ${PROJECT_SOURCE_DIR}/src/nvim/eval.c
  19. ${FUNCS_DATA}
  20. )
  21. glob_wrapper(PACKAGES ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*)
  22. set(GENERATED_PACKAGE_TAGS)
  23. foreach(PACKAGE ${PACKAGES})
  24. get_filename_component(PACKNAME ${PACKAGE} NAME)
  25. glob_wrapper("${PACKNAME}_DOC_FILES" ${PACKAGE}/doc/*.txt)
  26. if(${PACKNAME}_DOC_FILES)
  27. file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME})
  28. add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
  29. COMMAND ${CMAKE_COMMAND} -E copy_directory
  30. ${PACKAGE} ${GENERATED_PACKAGE_DIR}/${PACKNAME}
  31. COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
  32. -u NONE -i NONE -e --headless -c "helptags doc" -c quit
  33. DEPENDS
  34. nvim
  35. nvim_runtime_deps
  36. WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
  37. )
  38. set("${PACKNAME}_DOC_NAMES")
  39. foreach(DF "${${PACKNAME}_DOC_FILES}")
  40. get_filename_component(F ${DF} NAME)
  41. list(APPEND "${PACKNAME}_DOC_NAMES" ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/${F})
  42. endforeach()
  43. install_helper(
  44. FILES ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags "${${PACKNAME}_DOC_NAMES}"
  45. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/pack/dist/opt/${PACKNAME}/doc)
  46. list(APPEND GENERATED_PACKAGE_TAGS "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags")
  47. endif()
  48. endforeach()
  49. glob_wrapper(DOCFILES ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
  50. set(BUILDDOCFILES)
  51. foreach(DF ${DOCFILES})
  52. get_filename_component(F ${DF} NAME)
  53. list(APPEND BUILDDOCFILES ${GENERATED_RUNTIME_DIR}/doc/${F})
  54. endforeach()
  55. add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
  56. COMMAND ${CMAKE_COMMAND} -E remove doc/*
  57. COMMAND ${CMAKE_COMMAND} -E copy_directory
  58. ${PROJECT_SOURCE_DIR}/runtime/doc doc
  59. COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
  60. -u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
  61. DEPENDS
  62. nvim
  63. nvim_runtime_deps
  64. WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
  65. )
  66. # TODO: This doesn't work. wait for "nvim -l" to land?
  67. add_custom_target(doc_html
  68. COMMAND "${PROJECT_BINARY_DIR}/bin/nvim"
  69. -V1 -es --clean -c "lua require('scripts.gen_help_html').gen('./build/runtime/doc', './build/doc_html', nil, 'todo_commit_id')" -c "0cq"
  70. DEPENDS
  71. ${GENERATED_HELP_TAGS}
  72. WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}/doc"
  73. )
  74. add_custom_target(
  75. runtime ALL
  76. DEPENDS
  77. ${GENERATED_SYN_VIM}
  78. ${GENERATED_HELP_TAGS}
  79. ${GENERATED_PACKAGE_TAGS}
  80. )
  81. # CMake is painful here. It will create the destination using the user's
  82. # current umask, and we don't want that. And we don't just want to install
  83. # the target directory, as it will mess with existing permissions. So this
  84. # seems like the best compromise. If we create it, then everyone can see it.
  85. # If it's preexisting, leave it alone.
  86. install_helper(
  87. FILES ${GENERATED_HELP_TAGS} ${BUILDDOCFILES}
  88. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/doc)
  89. install_helper(
  90. FILES ${GENERATED_SYN_VIM}
  91. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/syntax/vim)
  92. if(NOT APPLE)
  93. install_helper(
  94. FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.desktop
  95. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
  96. install_helper(
  97. FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.png
  98. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
  99. endif()
  100. globrecurse_wrapper(RUNTIME_PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR} *.awk *.sh *.bat)
  101. foreach(PROG ${RUNTIME_PROGRAMS})
  102. get_filename_component(BASEDIR ${PROG} DIRECTORY)
  103. install_helper(PROGRAMS ${PROG}
  104. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
  105. endforeach()
  106. globrecurse_wrapper(RUNTIME_FILES ${CMAKE_CURRENT_SOURCE_DIR}
  107. *.vim *.lua *.scm *.dict *.py *.rb *.ps *.spl *.tutor *.tutor.json)
  108. foreach(F ${RUNTIME_FILES})
  109. get_filename_component(BASEDIR ${F} DIRECTORY)
  110. install_helper(FILES ${F}
  111. DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/${BASEDIR})
  112. endforeach()