2022-09-14 03:03:19 -07:00
|
|
|
# Luarocks recipe. Luarocks is only required when building 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
|
|
|
|
# the same dependency..
|
2015-04-17 16:02:28 -07:00
|
|
|
|
2016-03-19 10:54:14 -07:00
|
|
|
option(USE_BUNDLED_BUSTED "Use the bundled version of busted to run tests." ON)
|
2015-03-10 03:04:06 -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})
|
2023-04-03 12:12:42 -07:00
|
|
|
else()
|
|
|
|
# Workaround for luarocks failing to find the md5sum.exe it is shipped with.
|
|
|
|
set(LUAROCKS_BUILDARGS MD5SUM=md5sum)
|
2015-04-16 02:01:08 -07:00
|
|
|
endif()
|
|
|
|
|
2019-11-19 11:10:30 -07:00
|
|
|
# Lua version, used with rocks directories.
|
|
|
|
# Defaults to 5.1 for bundled LuaJIT/Lua.
|
|
|
|
set(LUA_VERSION "5.1")
|
|
|
|
|
2022-06-12 15:11:14 -07:00
|
|
|
if(UNIX)
|
2015-04-16 02:01:08 -07:00
|
|
|
|
|
|
|
if(USE_BUNDLED_LUAJIT)
|
|
|
|
list(APPEND LUAROCKS_OPTS
|
2022-09-14 03:03:19 -07:00
|
|
|
--with-lua=${DEPS_INSTALL_DIR}
|
|
|
|
--with-lua-include=${DEPS_INSTALL_DIR}/include/luajit-2.1
|
2019-11-19 11:10:30 -07:00
|
|
|
--with-lua-interpreter=luajit)
|
2018-02-01 07:23:33 -07:00
|
|
|
elseif(USE_BUNDLED_LUA)
|
|
|
|
list(APPEND LUAROCKS_OPTS
|
2022-09-14 03:03:19 -07:00
|
|
|
--with-lua=${DEPS_INSTALL_DIR})
|
2019-06-23 23:48:54 -07:00
|
|
|
else()
|
2023-03-02 14:50:43 -07:00
|
|
|
find_package(Luajit)
|
2019-06-23 23:48:54 -07:00
|
|
|
if(LUAJIT_FOUND)
|
|
|
|
list(APPEND LUAROCKS_OPTS
|
|
|
|
--with-lua-include=${LUAJIT_INCLUDE_DIRS}
|
2019-11-19 11:10:30 -07:00
|
|
|
--with-lua-interpreter=luajit)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Get LUA_VERSION used with rocks output.
|
|
|
|
if(LUAJIT_FOUND)
|
|
|
|
set(LUA_EXE "luajit")
|
|
|
|
else()
|
|
|
|
set(LUA_EXE "lua")
|
|
|
|
endif()
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${LUA_EXE} -e "print(string.sub(_VERSION, 5))"
|
|
|
|
OUTPUT_VARIABLE LUA_VERSION
|
|
|
|
ERROR_VARIABLE ERR
|
|
|
|
RESULT_VARIABLE RES)
|
|
|
|
if(NOT RES EQUAL 0)
|
|
|
|
message(FATAL_ERROR "Could not get LUA_VERSION with ${LUA_EXE}: ${ERR}")
|
2019-06-23 23:48:54 -07:00
|
|
|
endif()
|
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)
|
2015-05-05 17:13:40 -07:00
|
|
|
|
2022-05-17 06:08:24 -07:00
|
|
|
if(MINGW)
|
|
|
|
set(COMPILER_FLAG /MW)
|
|
|
|
elseif(MSVC)
|
|
|
|
set(COMPILER_FLAG /MSVC)
|
|
|
|
endif()
|
2015-04-16 02:01:08 -07:00
|
|
|
|
|
|
|
# Ignore USE_BUNDLED_LUAJIT - always ON for native Win32
|
2022-08-29 07:57:46 -07:00
|
|
|
set(LUAROCKS_INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
|
2015-04-16 02:01:08 -07:00
|
|
|
/LUA ${DEPS_INSTALL_DIR}
|
|
|
|
/LIB ${DEPS_LIB_DIR}
|
|
|
|
/BIN ${DEPS_BIN_DIR}
|
2019-09-30 03:50:22 -07:00
|
|
|
/INC ${DEPS_INSTALL_DIR}/include/luajit-2.1
|
2019-06-24 09:04:57 -07:00
|
|
|
/P ${DEPS_INSTALL_DIR}/luarocks /TREE ${DEPS_INSTALL_DIR}
|
2015-04-16 02:01:08 -07:00
|
|
|
/SCRIPTS ${DEPS_BIN_DIR}
|
|
|
|
/CMOD ${DEPS_BIN_DIR}
|
2018-02-28 18:14:27 -07:00
|
|
|
${COMPILER_FLAG}
|
2015-04-16 02:01:08 -07:00
|
|
|
/LUAMOD ${DEPS_BIN_DIR}/lua)
|
|
|
|
|
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
|
|
|
|
URL ${LUAROCKS_URL}
|
2022-09-29 12:46:14 -07:00
|
|
|
URL_HASH SHA256=${LUAROCKS_SHA256}
|
|
|
|
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 ""
|
|
|
|
INSTALL_COMMAND "${LUAROCKS_INSTALL_COMMAND}")
|
|
|
|
|
2015-03-09 06:24:21 -07:00
|
|
|
if(USE_BUNDLED_LUAJIT)
|
|
|
|
add_dependencies(luarocks luajit)
|
2018-02-01 07:23:33 -07:00
|
|
|
elseif(USE_BUNDLED_LUA)
|
|
|
|
add_dependencies(luarocks lua)
|
2015-03-09 06:24:21 -07:00
|
|
|
endif()
|
2022-09-14 03:03:19 -07:00
|
|
|
set(ROCKS_DIR ${DEPS_LIB_DIR}/luarocks/rocks-${LUA_VERSION})
|
2015-03-09 06:24:21 -07:00
|
|
|
|
2019-07-04 19:04:00 -07:00
|
|
|
# mpack
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_command(OUTPUT ${ROCKS_DIR}/mpack
|
2023-03-16 17:03:56 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY} build mpack 1.0.10-0 ${LUAROCKS_BUILDARGS}
|
2015-04-17 16:02:28 -07:00
|
|
|
DEPENDS luarocks)
|
2023-02-19 13:11:27 -07:00
|
|
|
add_custom_target(mpack ALL DEPENDS ${ROCKS_DIR}/mpack)
|
2015-04-16 02:01:08 -07:00
|
|
|
|
2019-07-04 19:04:00 -07:00
|
|
|
# lpeg
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_command(OUTPUT ${ROCKS_DIR}/lpeg
|
2022-08-06 09:26:43 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY} build lpeg 1.0.2-1 ${LUAROCKS_BUILDARGS}
|
2016-04-13 05:21:32 -07:00
|
|
|
DEPENDS mpack)
|
2023-02-19 13:11:27 -07:00
|
|
|
add_custom_target(lpeg ALL DEPENDS ${ROCKS_DIR}/lpeg)
|
2015-03-09 06:24:21 -07:00
|
|
|
|
2018-02-01 10:50:51 -07:00
|
|
|
if((NOT USE_BUNDLED_LUAJIT) AND USE_BUNDLED_LUA)
|
2019-07-04 19:04:00 -07:00
|
|
|
# luabitop
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_command(OUTPUT ${ROCKS_DIR}/luabitop
|
2022-08-06 09:26:43 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY} build luabitop 1.0.2-3 ${LUAROCKS_BUILDARGS}
|
2019-07-12 15:50:52 -07:00
|
|
|
DEPENDS lpeg)
|
2023-02-19 13:11:27 -07:00
|
|
|
add_custom_target(luabitop ALL DEPENDS ${ROCKS_DIR}/luabitop)
|
2018-02-01 10:50:51 -07:00
|
|
|
endif()
|
|
|
|
|
2015-04-17 16:02:28 -07:00
|
|
|
if(USE_BUNDLED_BUSTED)
|
2018-02-01 10:50:51 -07:00
|
|
|
if((NOT USE_BUNDLED_LUAJIT) AND USE_BUNDLED_LUA)
|
2023-02-19 14:27:12 -07:00
|
|
|
set(BUSTED_DEPENDS luabitop)
|
2018-02-01 10:50:51 -07:00
|
|
|
else()
|
2023-02-19 14:27:12 -07:00
|
|
|
set(BUSTED_DEPENDS lpeg)
|
2018-02-01 10:50:51 -07:00
|
|
|
endif()
|
|
|
|
|
2019-07-04 19:04:00 -07:00
|
|
|
# busted
|
2016-03-19 10:54:14 -07:00
|
|
|
if(WIN32)
|
2022-09-14 03:03:19 -07:00
|
|
|
set(BUSTED_EXE "${DEPS_BIN_DIR}/busted.bat")
|
|
|
|
set(LUACHECK_EXE "${DEPS_BIN_DIR}/luacheck.bat")
|
2016-03-19 10:54:14 -07:00
|
|
|
else()
|
2022-09-14 03:03:19 -07:00
|
|
|
set(BUSTED_EXE "${DEPS_BIN_DIR}/busted")
|
|
|
|
set(LUACHECK_EXE "${DEPS_BIN_DIR}/luacheck")
|
2016-03-19 10:54:14 -07:00
|
|
|
endif()
|
|
|
|
add_custom_command(OUTPUT ${BUSTED_EXE}
|
2023-01-30 02:01:06 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY} build busted 2.1.1 ${LUAROCKS_BUILDARGS}
|
2023-02-19 14:27:12 -07:00
|
|
|
DEPENDS ${BUSTED_DEPENDS})
|
2023-02-19 13:11:27 -07:00
|
|
|
add_custom_target(busted ALL DEPENDS ${BUSTED_EXE})
|
2015-05-05 07:45:14 -07:00
|
|
|
|
2019-07-04 19:04:00 -07:00
|
|
|
# luacheck
|
2018-01-24 02:29:30 -07:00
|
|
|
add_custom_command(OUTPUT ${LUACHECK_EXE}
|
2023-03-15 10:40:50 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY} build luacheck 1.1.0-1 ${LUAROCKS_BUILDARGS}
|
2015-11-17 05:16:33 -07:00
|
|
|
DEPENDS busted)
|
2023-02-19 13:11:27 -07:00
|
|
|
add_custom_target(luacheck ALL DEPENDS ${LUACHECK_EXE})
|
2019-06-21 18:43:31 -07:00
|
|
|
|
2022-11-28 14:43:10 -07:00
|
|
|
if (USE_BUNDLED_LUA OR NOT USE_BUNDLED_LUAJIT)
|
2023-01-31 15:35:04 -07:00
|
|
|
# coxpcall
|
|
|
|
add_custom_command(OUTPUT ${ROCKS_DIR}/coxpcall
|
2023-03-15 10:37:08 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY} build coxpcall 1.17.0-1 ${LUAROCKS_BUILDARGS}
|
2023-01-31 15:35:04 -07:00
|
|
|
DEPENDS luarocks)
|
2023-02-19 13:11:27 -07:00
|
|
|
add_custom_target(coxpcall ALL DEPENDS ${ROCKS_DIR}/coxpcall)
|
2016-07-25 05:08:24 -07:00
|
|
|
endif()
|
2015-04-17 16:02:28 -07:00
|
|
|
endif()
|