File: LuaHelpers.cmake

package info (click to toggle)
neovim 0.1.7-4%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 39,060 kB
  • sloc: ansic: 176,052; python: 2,091; awk: 709; sh: 528; perl: 374; makefile: 295; exp: 33; ruby: 8
file content (38 lines) | stat: -rw-r--r-- 1,126 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#
# Functions to help checking for a Lua interpreter
#

# Check if a module is available in Lua
function(check_lua_module LUA_PRG_PATH MODULE RESULT_VAR)
  execute_process(COMMAND ${LUA_PRG_PATH} -e "require('${MODULE}')"
    RESULT_VARIABLE module_missing
    ERROR_QUIET)
  if(module_missing)
    set(${RESULT_VAR} False PARENT_SCOPE)
  else()
    set(${RESULT_VAR} True PARENT_SCOPE)
  endif()
endfunction()

# Check Lua interpreter for dependencies
function(check_lua_deps LUA_PRG_PATH MODULES RESULT_VAR)
  # Check if the lua interpreter at the given path
  # satisfies all Neovim dependencies
  message(STATUS "Checking Lua interpreter ${LUA_PRG_PATH}")
  if(NOT EXISTS ${LUA_PRG_PATH})
    message(STATUS
      "[${LUA_PRG_PATH}] file not found")
  endif()

  foreach(module ${MODULES})
    check_lua_module(${LUA_PRG_PATH} ${module} has_module)
    if(NOT has_module)
      message(STATUS
        "[${LUA_PRG_PATH}] The '${module}' lua package is required for building Neovim")
      set(${RESULT_VAR} False PARENT_SCOPE)
      return()
    endif()
  endforeach()

  set(${RESULT_VAR} True PARENT_SCOPE)
endfunction()