Add Lua 5.1 as a third party dep

Also add a functionaltest-lua target to run the functional tests using the lua
interpreter and corresponding helper to top-level Makefile
This commit is contained in:
Thiago de Arruda 2016-03-07 00:42:49 -03:00
parent 96af115c71
commit 646ab30858
4 changed files with 119 additions and 1 deletions

View File

@ -390,6 +390,7 @@ message(STATUS "Using the Lua interpreter ${LUA_PRG}.")
# Setup busted.
find_program(BUSTED_PRG busted)
find_program(BUSTED_LUA_PRG busted-lua)
if(NOT BUSTED_OUTPUT_TYPE)
set(BUSTED_OUTPUT_TYPE "utfTerminal")
endif()
@ -501,6 +502,20 @@ if(BUSTED_PRG)
DEPENDS ${BENCHMARK_PREREQS})
endif()
if(BUSTED_LUA_PRG)
add_custom_target(functionaltest-lua
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_LUA_PRG}
-DNVIM_PRG=$<TARGET_FILE:nvim>
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=functional
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
DEPENDS ${FUNCTIONALTEST_PREREQS})
endif()
if(LUACHECK_PRG)
add_custom_target(testlint
COMMAND ${CMAKE_COMMAND}

View File

@ -45,6 +45,11 @@ ifneq (,$(USE_BUNDLED_DEPS))
BUNDLED_CMAKE_FLAG := -DUSE_BUNDLED=$(USE_BUNDLED_DEPS)
endif
ifneq (,$(findstring functionaltest-lua,$(MAKECMDGOALS)))
BUNDLED_LUA_CMAKE_FLAG := -DUSE_BUNDLED_LUA=ON
$(shell [ -x .deps/usr/bin/lua ] || rm build/.ran-*)
endif
# For use where we want to make sure only a single job is run. This does issue
# a warning, but we need to keep SCRIPTS argument.
SINGLE_MAKE = export MAKEFLAGS= ; $(MAKE)
@ -74,7 +79,7 @@ build/.ran-third-party-cmake:
ifeq ($(call filter-true,$(USE_BUNDLED_DEPS)),)
mkdir -p .deps
cd .deps && \
cmake -G '$(BUILD_TYPE)' $(BUNDLED_CMAKE_FLAG) \
cmake -G '$(BUILD_TYPE)' $(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) \
$(DEPS_CMAKE_FLAGS) ../third-party
endif
mkdir -p build
@ -86,6 +91,9 @@ oldtest: | nvim
functionaltest: | nvim
+$(BUILD_CMD) -C build functionaltest
functionaltest-lua: | nvim
+$(BUILD_CMD) -C build functionaltest-lua
testlint: | nvim
$(BUILD_CMD) -C build testlint

View File

@ -21,6 +21,9 @@ option(USE_BUNDLED_LIBUV "Use the bundled libuv." ${USE_BUNDLED})
option(USE_BUNDLED_MSGPACK "Use the bundled msgpack." ${USE_BUNDLED})
option(USE_BUNDLED_LUAJIT "Use the bundled version of luajit." ${USE_BUNDLED})
option(USE_BUNDLED_LUAROCKS "Use the bundled version of luarocks." ${USE_BUNDLED})
#XXX(tarruda): Lua is only used for debugging the functional test client, no
# build it unless explicitly requested
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
@ -80,6 +83,9 @@ set(MSGPACK_SHA256 afda64ca445203bb7092372b822bae8b2539fdcebbfc3f753f393628c2bcf
set(LUAJIT_URL https://github.com/neovim/deps/raw/master/opt/LuaJIT-2.0.4.tar.gz)
set(LUAJIT_SHA256 620fa4eb12375021bef6e4f237cbd2dd5d49e56beb414bee052c746beef1807d)
set(LUA_URL https://github.com/lua/lua/archive/5.1.5.tar.gz)
set(LUA_SHA256 1cd642c4c39778306a14e62ccddace5c7a4fb2257b0b06f43bc81cf305c7415f)
set(LUAROCKS_URL https://github.com/keplerproject/luarocks/archive/5d8a16526573b36d5b22aa74866120c998466697.tar.gz)
set(LUAROCKS_SHA256 cae709111c5701235770047dfd7169f66b82ae1c7b9b79207f9df0afb722bfd9)
@ -119,6 +125,10 @@ if(USE_BUNDLED_LUAJIT)
include(BuildLuajit)
endif()
if(USE_BUNDLED_LUA AND NOT CMAKE_CROSSCOMPILING)
include(BuildLua)
endif()
if(USE_BUNDLED_LUAROCKS)
include(BuildLuarocks)
endif()

85
third-party/cmake/BuildLua.cmake vendored Normal file
View File

@ -0,0 +1,85 @@
include(CMakeParseArguments)
# BuildLua(CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...)
# Reusable function to build lua, wraps ExternalProject_Add.
# Failing to pass a command argument will result in no command being run
function(BuildLua)
cmake_parse_arguments(_lua
""
""
"CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
${ARGN})
if(NOT _lua_CONFIGURE_COMMAND AND NOT _lua_BUILD_COMMAND
AND NOT _lua_INSTALL_COMMAND)
message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND")
endif()
ExternalProject_Add(lua
PREFIX ${DEPS_BUILD_DIR}
URL ${LUA_URL}
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/lua
DOWNLOAD_COMMAND ${CMAKE_COMMAND}
-DPREFIX=${DEPS_BUILD_DIR}
-DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/lua
-DURL=${LUA_URL}
-DEXPECTED_SHA256=${LUA_SHA256}
-DTARGET=lua
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
CONFIGURE_COMMAND "${_lua_CONFIGURE_COMMAND}"
BUILD_IN_SOURCE 1
BUILD_COMMAND "${_lua_BUILD_COMMAND}"
INSTALL_COMMAND "${_lua_INSTALL_COMMAND}")
endfunction()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(LUA_TARGET linux)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(LUA_TARGET macosx)
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(LUA_TARGET freebsd)
elseif(CMAKE_SYSTEM_NAME MATCHES "BSD")
set(CMAKE_LUA_TARGET bsd)
elseif(SYSTEM_NAME MATCHES "^MINGW")
set(CMAKE_LUA_TARGET mingw)
else()
if(UNIX)
set(LUA_TARGET posix)
else()
set(LUA_TARGET generic)
endif()
endif()
set(LUA_CONFIGURE_COMMAND
sed -e "/^CC/s@gcc@${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}@"
-e "/^CFLAGS/s@-O2@-g3@"
-e "s@-lreadline@@g"
-e "s@-lhistory@@g"
-e "s@-lncurses@@g"
-i ${DEPS_BUILD_DIR}/src/lua/src/Makefile &&
sed -e "/#define LUA_USE_READLINE/d"
-i ${DEPS_BUILD_DIR}/src/lua/src/luaconf.h)
set(LUA_BUILD_COMMAND
${MAKE_PRG} ${LUA_TARGET})
set(LUA_INSTALL_COMMAND
${MAKE_PRG} INSTALL_TOP=${DEPS_INSTALL_DIR} install)
message(STATUS "Lua target is ${LUA_TARGET}")
BuildLua(CONFIGURE_COMMAND ${LUA_CONFIGURE_COMMAND}
BUILD_COMMAND ${LUA_BUILD_COMMAND}
INSTALL_COMMAND ${LUA_INSTALL_COMMAND})
list(APPEND THIRD_PARTY_DEPS lua)
add_dependencies(lua busted)
set(BUSTED ${DEPS_INSTALL_DIR}/bin/busted)
set(BUSTED_LUA ${BUSTED}-lua)
add_custom_command(OUTPUT ${BUSTED_LUA}
COMMAND sed -e 's/jit//g' < ${BUSTED} > ${BUSTED_LUA} && chmod +x ${BUSTED_LUA}
DEPENDS lua)
add_custom_target(busted-lua
DEPENDS ${DEPS_INSTALL_DIR}/bin/busted-lua)
list(APPEND THIRD_PARTY_DEPS busted-lua)