2015-04-16 02:01:08 -07:00
|
|
|
# Luarocks recipe. Luarocks is only required when building Neovim, when
|
|
|
|
# cross compiling we still want to build for the HOST system, whenever
|
2015-09-01 18:47:20 -07:00
|
|
|
# writing a recipe that is meant for cross-compile, use the HOSTDEPS_* variables
|
2015-04-16 02:01:08 -07:00
|
|
|
# instead of DEPS_* - check the main CMakeLists.txt for a list.
|
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
|
|
|
# BuildLuarocks(CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...)
|
|
|
|
# Reusable function to build luarocks, wraps ExternalProject_Add.
|
|
|
|
# Failing to pass a command argument will result in no command being run
|
|
|
|
function(BuildLuarocks)
|
|
|
|
cmake_parse_arguments(_luarocks
|
|
|
|
""
|
|
|
|
""
|
2018-05-18 07:14:13 -07:00
|
|
|
"CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
|
2015-04-16 02:01:08 -07:00
|
|
|
${ARGN})
|
2015-03-10 03:04:06 -07:00
|
|
|
|
2015-04-16 02:01:08 -07:00
|
|
|
if(NOT _luarocks_CONFIGURE_COMMAND AND NOT _luarocks_BUILD_COMMAND
|
|
|
|
AND NOT _luarocks_INSTALL_COMMAND)
|
|
|
|
message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
ExternalProject_Add(luarocks
|
|
|
|
PREFIX ${DEPS_BUILD_DIR}
|
|
|
|
URL ${LUAROCKS_URL}
|
|
|
|
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/luarocks
|
|
|
|
DOWNLOAD_COMMAND ${CMAKE_COMMAND}
|
|
|
|
-DPREFIX=${DEPS_BUILD_DIR}
|
|
|
|
-DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/luarocks
|
|
|
|
-DURL=${LUAROCKS_URL}
|
|
|
|
-DEXPECTED_SHA256=${LUAROCKS_SHA256}
|
|
|
|
-DTARGET=luarocks
|
2015-09-08 03:09:44 -07:00
|
|
|
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
|
2015-04-16 02:01:08 -07:00
|
|
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
|
|
|
|
BUILD_IN_SOURCE 1
|
|
|
|
CONFIGURE_COMMAND "${_luarocks_CONFIGURE_COMMAND}"
|
|
|
|
BUILD_COMMAND "${_luarocks_BUILD_COMMAND}"
|
|
|
|
INSTALL_COMMAND "${_luarocks_INSTALL_COMMAND}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# The luarocks binary location
|
|
|
|
set(LUAROCKS_BINARY ${HOSTDEPS_BIN_DIR}/luarocks)
|
|
|
|
|
|
|
|
# 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
|
|
|
|
set(LUAROCKS_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
|
|
|
|
|
|
|
|
if(USE_BUNDLED_LUAJIT)
|
|
|
|
list(APPEND LUAROCKS_OPTS
|
|
|
|
--with-lua=${HOSTDEPS_INSTALL_DIR}
|
2018-02-01 07:23:33 -07:00
|
|
|
--with-lua-include=${HOSTDEPS_INSTALL_DIR}/include/luajit-2.0
|
|
|
|
--lua-suffix=jit)
|
|
|
|
elseif(USE_BUNDLED_LUA)
|
|
|
|
list(APPEND LUAROCKS_OPTS
|
|
|
|
--with-lua=${HOSTDEPS_INSTALL_DIR})
|
2019-06-23 23:48:54 -07:00
|
|
|
else()
|
|
|
|
find_package(LuaJit)
|
|
|
|
if(LUAJIT_FOUND)
|
|
|
|
list(APPEND LUAROCKS_OPTS
|
|
|
|
--lua-version=5.1
|
|
|
|
--with-lua-include=${LUAJIT_INCLUDE_DIRS}
|
|
|
|
--lua-suffix=jit)
|
|
|
|
endif()
|
2015-04-16 02:01:08 -07:00
|
|
|
endif()
|
2015-03-10 03:04:06 -07:00
|
|
|
|
2015-04-16 02:01:08 -07:00
|
|
|
BuildLuarocks(
|
|
|
|
CONFIGURE_COMMAND ${DEPS_BUILD_DIR}/src/luarocks/configure
|
|
|
|
--prefix=${HOSTDEPS_INSTALL_DIR} --force-config ${LUAROCKS_OPTS}
|
2018-03-08 16:36:17 -07:00
|
|
|
INSTALL_COMMAND ${MAKE_PRG} -j1 bootstrap)
|
2015-05-05 17:13:40 -07:00
|
|
|
elseif(MSVC OR MINGW)
|
|
|
|
|
|
|
|
if(MINGW)
|
2018-02-28 18:14:27 -07:00
|
|
|
set(COMPILER_FLAG /MW)
|
|
|
|
elseif(MSVC)
|
|
|
|
set(COMPILER_FLAG /MSVC)
|
2015-05-05 17:13:40 -07:00
|
|
|
endif()
|
2015-04-16 02:01:08 -07:00
|
|
|
|
|
|
|
# Ignore USE_BUNDLED_LUAJIT - always ON for native Win32
|
2018-05-18 07:14:13 -07:00
|
|
|
BuildLuarocks(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-06-24 09:04:57 -07:00
|
|
|
/INC ${DEPS_INSTALL_DIR}/include/luajit-2.0
|
|
|
|
/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()
|
|
|
|
|
|
|
|
list(APPEND THIRD_PARTY_DEPS luarocks)
|
2015-04-17 16:22:54 -07:00
|
|
|
|
2015-03-09 06:24:21 -07:00
|
|
|
if(USE_BUNDLED_LUAJIT)
|
|
|
|
add_dependencies(luarocks luajit)
|
2016-04-10 19:49:28 -07:00
|
|
|
if(MINGW AND CMAKE_CROSSCOMPILING)
|
|
|
|
add_dependencies(luarocks luajit_host)
|
|
|
|
endif()
|
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()
|
2019-07-04 18:55:08 -07:00
|
|
|
set(ROCKS_DIR ${HOSTDEPS_LIB_DIR}/luarocks/rocks)
|
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
|
2015-04-17 16:22:54 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
2019-06-29 13:25:00 -07:00
|
|
|
ARGS build mpack 1.0.8-0 ${LUAROCKS_BUILDARGS}
|
2015-04-17 16:02:28 -07:00
|
|
|
DEPENDS luarocks)
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_target(mpack DEPENDS ${ROCKS_DIR}/mpack)
|
2016-04-13 05:21:32 -07:00
|
|
|
list(APPEND THIRD_PARTY_DEPS 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
|
2015-04-17 16:22:54 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
2019-06-29 13:25:00 -07:00
|
|
|
ARGS build lpeg 1.0.2-1 ${LUAROCKS_BUILDARGS}
|
2016-04-13 05:21:32 -07:00
|
|
|
DEPENDS mpack)
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_target(lpeg DEPENDS ${ROCKS_DIR}/lpeg)
|
2015-04-16 02:01:08 -07:00
|
|
|
list(APPEND THIRD_PARTY_DEPS 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
|
2018-02-01 10:50:51 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
2018-02-26 06:09:00 -07:00
|
|
|
ARGS build luabitop 1.0.2-3 ${LUAROCKS_BUILDARGS}
|
2019-07-12 15:50:52 -07:00
|
|
|
DEPENDS lpeg)
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_target(luabitop DEPENDS ${ROCKS_DIR}/luabitop)
|
2018-02-01 10:50:51 -07:00
|
|
|
list(APPEND THIRD_PARTY_DEPS luabitop)
|
|
|
|
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)
|
|
|
|
set(PENLIGHT_DEPENDS luabitop)
|
|
|
|
else()
|
2019-07-12 15:50:52 -07:00
|
|
|
set(PENLIGHT_DEPENDS lpeg)
|
2018-02-01 10:50:51 -07:00
|
|
|
endif()
|
|
|
|
|
2019-07-04 19:04:00 -07:00
|
|
|
# penlight
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_command(OUTPUT ${ROCKS_DIR}/penlight
|
2016-08-15 02:45:28 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
2018-02-26 06:09:00 -07:00
|
|
|
ARGS build penlight 1.5.4-1 ${LUAROCKS_BUILDARGS}
|
2018-02-01 10:50:51 -07:00
|
|
|
DEPENDS ${PENLIGHT_DEPENDS})
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_target(penlight DEPENDS ${ROCKS_DIR}/penlight)
|
2016-08-15 02:45:28 -07:00
|
|
|
|
2019-07-04 19:04:00 -07:00
|
|
|
# busted
|
2016-03-19 10:54:14 -07:00
|
|
|
if(WIN32)
|
|
|
|
set(BUSTED_EXE "${HOSTDEPS_BIN_DIR}/busted.bat")
|
2018-01-24 02:29:30 -07:00
|
|
|
set(LUACHECK_EXE "${HOSTDEPS_BIN_DIR}/luacheck.bat")
|
2016-03-19 10:54:14 -07:00
|
|
|
else()
|
|
|
|
set(BUSTED_EXE "${HOSTDEPS_BIN_DIR}/busted")
|
2018-01-24 02:29:30 -07:00
|
|
|
set(LUACHECK_EXE "${HOSTDEPS_BIN_DIR}/luacheck")
|
2016-03-19 10:54:14 -07:00
|
|
|
endif()
|
|
|
|
add_custom_command(OUTPUT ${BUSTED_EXE}
|
2015-10-27 02:14:18 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
2019-07-16 00:15:50 -07:00
|
|
|
ARGS build busted 2.0.0 ${LUAROCKS_BUILDARGS}
|
2016-08-15 02:45:28 -07:00
|
|
|
DEPENDS penlight)
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_target(busted 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}
|
2015-11-17 05:16:33 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
2019-06-29 13:25:00 -07:00
|
|
|
ARGS build luacheck 0.23.0-1 ${LUAROCKS_BUILDARGS}
|
2015-11-17 05:16:33 -07:00
|
|
|
DEPENDS busted)
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_target(luacheck DEPENDS ${LUACHECK_EXE})
|
2019-06-21 18:43:31 -07:00
|
|
|
|
2019-07-04 19:04:00 -07:00
|
|
|
# luv
|
2019-06-22 19:17:13 -07:00
|
|
|
set(LUV_DEPS luacheck)
|
2019-06-21 18:43:31 -07:00
|
|
|
if(USE_BUNDLED_LUV)
|
2019-06-22 19:17:13 -07:00
|
|
|
list(APPEND LUV_DEPS luv-static lua-compat-5.3)
|
2019-06-21 18:43:31 -07:00
|
|
|
if(MINGW AND CMAKE_CROSSCOMPILING)
|
2019-06-22 19:17:13 -07:00
|
|
|
list(APPEND LUV_DEPS libuv_host)
|
2019-06-21 18:43:31 -07:00
|
|
|
endif()
|
|
|
|
set(LUV_ARGS "CFLAGS=-O0 -g3 -fPIC")
|
|
|
|
if(USE_BUNDLED_LIBUV)
|
|
|
|
list(APPEND LUV_ARGS LIBUV_DIR=${HOSTDEPS_INSTALL_DIR})
|
|
|
|
endif()
|
|
|
|
SET(LUV_PRIVATE_ARGS LUA_COMPAT53_INCDIR=${DEPS_BUILD_DIR}/src/lua-compat-5.3)
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_command(OUTPUT ${ROCKS_DIR}/luv
|
2019-06-21 18:43:31 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
|
|
|
ARGS make ${LUAROCKS_BUILDARGS} ${LUV_ARGS} ${LUV_PRIVATE_ARGS}
|
|
|
|
WORKING_DIRECTORY ${DEPS_BUILD_DIR}/src/luv
|
|
|
|
DEPENDS ${LUV_DEPS})
|
|
|
|
else()
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_command(OUTPUT ${ROCKS_DIR}/luv
|
2019-06-22 19:17:13 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
|
|
|
ARGS build luv ${LUV_VERSION} ${LUAROCKS_BUILDARGS}
|
|
|
|
DEPENDS ${LUV_DEPS})
|
2016-07-25 05:08:24 -07:00
|
|
|
endif()
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_target(luv DEPENDS ${ROCKS_DIR}/luv)
|
2016-04-10 19:49:23 -07:00
|
|
|
|
2019-07-04 19:04:00 -07:00
|
|
|
# nvim-client
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_command(OUTPUT ${ROCKS_DIR}/nvim-client
|
2015-04-17 16:22:54 -07:00
|
|
|
COMMAND ${LUAROCKS_BINARY}
|
2019-01-24 11:15:39 -07:00
|
|
|
ARGS build nvim-client 0.2.0-1 ${LUAROCKS_BUILDARGS}
|
2019-06-22 19:17:13 -07:00
|
|
|
DEPENDS luv)
|
2019-07-04 18:55:08 -07:00
|
|
|
add_custom_target(nvim-client DEPENDS ${ROCKS_DIR}/nvim-client)
|
2015-05-05 07:45:14 -07:00
|
|
|
|
2015-11-17 05:16:33 -07:00
|
|
|
list(APPEND THIRD_PARTY_DEPS busted luacheck nvim-client)
|
2015-04-17 16:02:28 -07:00
|
|
|
endif()
|