2023-05-13 03:12:29 -07:00
|
|
|
# Luarocks recipe. Luarocks is only required when testing Neovim.
|
2019-07-04 19:04:00 -07:00
|
|
|
# NOTE: LuaRocks rocks need to "DEPENDS" on the previous module, because
|
|
|
|
# running luarocks in parallel will break, e.g. when some rocks have
|
2023-04-15 13:39:30 -07:00
|
|
|
# the same dependency.
|
2015-04-17 16:02:28 -07:00
|
|
|
|
2015-04-16 02:01:08 -07:00
|
|
|
# The luarocks binary location
|
2022-09-14 03:03:19 -07:00
|
|
|
set(LUAROCKS_BINARY ${DEPS_BIN_DIR}/luarocks)
|
2015-04-16 02:01:08 -07:00
|
|
|
|
|
|
|
# Arguments for calls to 'luarocks build'
|
2015-12-19 21:50:20 -07:00
|
|
|
if(NOT MSVC)
|
|
|
|
# In MSVC don't pass the compiler/linker to luarocks, the bundled
|
2015-04-16 02:01:08 -07:00
|
|
|
# version already knows, and passing them here breaks the build
|
2022-09-14 03:03:19 -07:00
|
|
|
set(LUAROCKS_BUILDARGS CC=${DEPS_C_COMPILER} LD=${DEPS_C_COMPILER})
|
2015-04-16 02:01:08 -07:00
|
|
|
endif()
|
|
|
|
|
2022-06-12 15:11:14 -07:00
|
|
|
if(UNIX)
|
2023-05-21 11:57:39 -07:00
|
|
|
if(PREFER_LUA)
|
|
|
|
find_package(Lua 5.1 EXACT REQUIRED)
|
|
|
|
get_filename_component(LUA_ROOT ${LUA_INCLUDE_DIR} DIRECTORY)
|
2018-02-01 07:23:33 -07:00
|
|
|
list(APPEND LUAROCKS_OPTS
|
2023-05-21 11:57:39 -07:00
|
|
|
--with-lua=${LUA_ROOT})
|
2019-06-23 23:48:54 -07:00
|
|
|
else()
|
2023-05-21 11:57:39 -07:00
|
|
|
find_package(Luajit REQUIRED)
|
|
|
|
get_filename_component(LUA_ROOT ${LUAJIT_INCLUDE_DIR} DIRECTORY)
|
|
|
|
get_filename_component(LUA_ROOT ${LUA_ROOT} DIRECTORY)
|
|
|
|
list(APPEND LUAROCKS_OPTS
|
|
|
|
--with-lua=${LUA_ROOT}
|
|
|
|
--with-lua-include=${LUAJIT_INCLUDE_DIR}
|
|
|
|
--with-lua-interpreter=luajit)
|
2015-04-16 02:01:08 -07:00
|
|
|
endif()
|
2015-03-10 03:04:06 -07:00
|
|
|
|
2022-08-29 07:57:46 -07:00
|
|
|
set(LUAROCKS_CONFIGURE_COMMAND ${DEPS_BUILD_DIR}/src/luarocks/configure
|
2022-09-14 03:03:19 -07:00
|
|
|
--prefix=${DEPS_INSTALL_DIR} --force-config ${LUAROCKS_OPTS})
|
2022-08-29 07:57:46 -07:00
|
|
|
set(LUAROCKS_INSTALL_COMMAND ${MAKE_PRG} -j1 bootstrap)
|
2022-05-17 06:08:24 -07:00
|
|
|
elseif(MSVC OR MINGW)
|
|
|
|
if(MINGW)
|
|
|
|
set(COMPILER_FLAG /MW)
|
|
|
|
elseif(MSVC)
|
|
|
|
set(COMPILER_FLAG /MSVC)
|
|
|
|
endif()
|
2015-04-16 02:01:08 -07:00
|
|
|
|
2023-05-21 11:57:39 -07:00
|
|
|
find_package(Luajit REQUIRED)
|
|
|
|
# Always assume bundled luajit for native Win32
|
2022-08-29 07:57:46 -07:00
|
|
|
set(LUAROCKS_INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
|
2023-05-21 11:57:39 -07:00
|
|
|
/LUA ${DEPS_PREFIX}
|
|
|
|
/INC ${LUAJIT_INCLUDE_DIR}
|
|
|
|
/P ${DEPS_INSTALL_DIR}/luarocks
|
|
|
|
/TREE ${DEPS_INSTALL_DIR}
|
2015-04-16 02:01:08 -07:00
|
|
|
/SCRIPTS ${DEPS_BIN_DIR}
|
2023-05-21 11:57:39 -07:00
|
|
|
${COMPILER_FLAG})
|
2015-04-16 02:01:08 -07:00
|
|
|
|
2019-06-24 09:04:57 -07:00
|
|
|
set(LUAROCKS_BINARY ${DEPS_INSTALL_DIR}/luarocks/luarocks.bat)
|
2015-04-16 02:01:08 -07:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Trying to build luarocks in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
|
|
|
|
endif()
|
|
|
|
|
2022-08-29 07:57:46 -07:00
|
|
|
ExternalProject_Add(luarocks
|
2023-05-21 11:57:39 -07:00
|
|
|
URL https://github.com/luarocks/luarocks/archive/v3.9.2.tar.gz
|
|
|
|
URL_HASH SHA256=a0b36cd68586cd79966d0106bb2e5a4f5523327867995fd66bee4237062b3e3b
|
2022-09-29 12:46:14 -07:00
|
|
|
DOWNLOAD_NO_PROGRESS TRUE
|
2022-08-29 07:57:46 -07:00
|
|
|
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/luarocks
|
|
|
|
BUILD_IN_SOURCE 1
|
|
|
|
CONFIGURE_COMMAND "${LUAROCKS_CONFIGURE_COMMAND}"
|
|
|
|
BUILD_COMMAND ""
|
2023-05-21 11:57:39 -07:00
|
|
|
INSTALL_COMMAND "${LUAROCKS_INSTALL_COMMAND}"
|
|
|
|
EXCLUDE_FROM_ALL TRUE)
|
2022-08-29 07:57:46 -07:00
|
|
|
|
2023-05-21 11:57:39 -07:00
|
|
|
set(ROCKS_DIR ${DEPS_LIB_DIR}/luarocks/rocks)
|
2015-03-09 06:24:21 -07:00
|
|
|
|
2023-04-05 10:49:16 -07:00
|
|
|
if(MSVC)
|
|
|
|
# Workaround for luarocks failing to find the md5sum.exe it is shipped with.
|
|
|
|
list(APPEND LUAROCKS_BUILDARGS MD5SUM=md5sum)
|
|
|
|
set(PATH PATH=${DEPS_INSTALL_DIR}/luarocks/tools;$ENV{PATH})
|
|
|
|
endif()
|
|
|
|
|
2023-04-12 12:26:06 -07:00
|
|
|
set(CURRENT_DEP luarocks)
|
|
|
|
|
|
|
|
function(Download ROCK VER)
|
|
|
|
if(ARGV2)
|
|
|
|
set(OUTPUT ${ARGV2})
|
|
|
|
else()
|
|
|
|
set(OUTPUT ${ROCKS_DIR}/${ROCK})
|
|
|
|
endif()
|
|
|
|
add_custom_command(OUTPUT ${OUTPUT}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env "${PATH}" ${LUAROCKS_BINARY} build ${ROCK} ${VER} ${LUAROCKS_BUILDARGS}
|
|
|
|
DEPENDS ${CURRENT_DEP})
|
2023-05-21 11:57:39 -07:00
|
|
|
add_custom_target(${ROCK} DEPENDS ${OUTPUT})
|
2023-04-12 12:26:06 -07:00
|
|
|
set(CURRENT_DEP ${ROCK} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2023-05-08 08:24:19 -07:00
|
|
|
if(WIN32)
|
|
|
|
set(BUSTED_EXE "${DEPS_BIN_DIR}/busted.bat")
|
|
|
|
set(LUACHECK_EXE "${DEPS_BIN_DIR}/luacheck.bat")
|
|
|
|
else()
|
|
|
|
set(BUSTED_EXE "${DEPS_BIN_DIR}/busted")
|
|
|
|
set(LUACHECK_EXE "${DEPS_BIN_DIR}/luacheck")
|
|
|
|
endif()
|
2015-05-05 07:45:14 -07:00
|
|
|
|
2023-05-21 11:57:39 -07:00
|
|
|
add_custom_target(test_deps)
|
|
|
|
|
2023-05-08 08:24:19 -07:00
|
|
|
Download(luacheck 1.1.0-1 ${LUACHECK_EXE})
|
2019-06-21 18:43:31 -07:00
|
|
|
|
2023-05-21 11:57:39 -07:00
|
|
|
Download(busted 2.1.1 ${BUSTED_EXE})
|
|
|
|
add_dependencies(test_deps busted)
|
|
|
|
|
|
|
|
if(PREFER_LUA)
|
2023-05-08 08:24:19 -07:00
|
|
|
Download(coxpcall 1.17.0-1)
|
2023-05-21 11:57:39 -07:00
|
|
|
add_dependencies(test_deps coxpcall)
|
2015-04-17 16:02:28 -07:00
|
|
|
endif()
|