mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge PR #4398 'Update lua client'
This commit is contained in:
commit
982198143d
@ -367,7 +367,7 @@ endforeach()
|
||||
|
||||
# Find Lua interpreter
|
||||
include(LuaHelpers)
|
||||
set(LUA_DEPENDENCIES lpeg MessagePack bit)
|
||||
set(LUA_DEPENDENCIES lpeg mpack bit)
|
||||
if(NOT LUA_PRG)
|
||||
foreach(CURRENT_LUA_PRG luajit lua)
|
||||
# If LUA_PRG is set find_program() will not search
|
||||
|
@ -1,5 +1,5 @@
|
||||
lpeg = require('lpeg')
|
||||
msgpack = require('MessagePack')
|
||||
mpack = require('mpack')
|
||||
|
||||
-- lpeg grammar for building api metadata from a set of header files. It
|
||||
-- ignores comments and preprocessor commands and parses a very small subset
|
||||
@ -115,7 +115,7 @@ static const uint8_t msgpack_metadata[] = {
|
||||
]])
|
||||
-- serialize the API metadata using msgpack and embed into the resulting
|
||||
-- binary for easy querying by clients
|
||||
packed = msgpack.pack(functions)
|
||||
packed = mpack.pack(functions)
|
||||
for i = 1, #packed do
|
||||
output:write(string.byte(packed, i)..', ')
|
||||
if i % 10 == 0 then
|
||||
|
@ -753,6 +753,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
putchar(b->data[i]);
|
||||
}
|
||||
|
||||
msgpack_packer_free(p);
|
||||
mch_exit(0);
|
||||
} else if (STRICMP(argv[0] + argv_idx, "headless") == 0) {
|
||||
parmp->headless = true;
|
||||
|
@ -80,7 +80,7 @@ describe('vim_* functions', function()
|
||||
it('set_var returns the old value', function()
|
||||
local val1 = {1, 2, {['3'] = 1}}
|
||||
local val2 = {4, 7}
|
||||
eq(nil, nvim('set_var', 'lua', val1))
|
||||
eq(NIL, nvim('set_var', 'lua', val1))
|
||||
eq(val1, nvim('set_var', 'lua', val2))
|
||||
end)
|
||||
|
||||
|
@ -62,6 +62,9 @@ describe(':oldfiles!', function()
|
||||
_clear()
|
||||
execute('rshada! ' .. shada_file)
|
||||
|
||||
-- Ensure nvim is out of "Press ENTER..." screen
|
||||
feed('<cr>')
|
||||
|
||||
-- Ensure v:oldfiles isn't busted. Since things happen so fast,
|
||||
-- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood).
|
||||
-- Let's verify the contents and the length of v:oldfiles before moving on.
|
||||
|
@ -24,6 +24,6 @@ describe('u_* functions', function()
|
||||
'-c', 'set undodir=. undofile'})
|
||||
set_session(session)
|
||||
execute('echo "True"') -- Should not error out due to crashed Neovim
|
||||
session:exit(0)
|
||||
session:close()
|
||||
end)
|
||||
end)
|
||||
|
@ -9,7 +9,7 @@ describe(':wshada', function()
|
||||
|
||||
before_each(function()
|
||||
if session then
|
||||
session:exit(0)
|
||||
session:close()
|
||||
end
|
||||
|
||||
-- Override the default session because we need 'swapfile' for these tests.
|
||||
|
@ -1,9 +1,8 @@
|
||||
require('coxpcall')
|
||||
NIL = require('mpack').NIL
|
||||
local lfs = require('lfs')
|
||||
local assert = require('luassert')
|
||||
local Loop = require('nvim.loop')
|
||||
local MsgpackStream = require('nvim.msgpack_stream')
|
||||
local AsyncSession = require('nvim.async_session')
|
||||
local ChildProcessStream = require('nvim.child_process_stream')
|
||||
local Session = require('nvim.session')
|
||||
|
||||
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
|
||||
@ -59,6 +58,9 @@ end
|
||||
local session, loop_running, last_error
|
||||
|
||||
local function set_session(s)
|
||||
if session then
|
||||
session:close()
|
||||
end
|
||||
session = s
|
||||
end
|
||||
|
||||
@ -209,24 +211,17 @@ local function merge_args(...)
|
||||
end
|
||||
|
||||
local function spawn(argv, merge)
|
||||
local loop = Loop.new()
|
||||
local msgpack_stream = MsgpackStream.new(loop)
|
||||
local async_session = AsyncSession.new(msgpack_stream)
|
||||
local sess = Session.new(async_session)
|
||||
loop:spawn(merge and merge_args(prepend_argv, argv) or argv)
|
||||
return sess
|
||||
local child_stream = ChildProcessStream.spawn(merge and merge_args(prepend_argv, argv) or argv)
|
||||
return Session.new(child_stream)
|
||||
end
|
||||
|
||||
local function clear(extra_cmd)
|
||||
if session then
|
||||
session:exit(0)
|
||||
end
|
||||
local args = {unpack(nvim_argv)}
|
||||
if extra_cmd ~= nil then
|
||||
table.insert(args, '--cmd')
|
||||
table.insert(args, extra_cmd)
|
||||
end
|
||||
session = spawn(args)
|
||||
set_session(spawn(args))
|
||||
end
|
||||
|
||||
local function insert(...)
|
||||
|
@ -25,7 +25,7 @@ local session = nil
|
||||
|
||||
local reset = function(...)
|
||||
if session then
|
||||
session:exit(0)
|
||||
session:close()
|
||||
end
|
||||
session = spawn(nvim_argv(...))
|
||||
set_session(session)
|
||||
|
@ -4,7 +4,7 @@ local eq, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curbuf =
|
||||
helpers.funcs, helpers.feed, helpers.curbuf
|
||||
local neq = helpers.neq
|
||||
|
||||
local msgpack = require('MessagePack')
|
||||
local mpack = require('mpack')
|
||||
|
||||
local plugin_helpers = require('test.functional.plugin.helpers')
|
||||
local reset = plugin_helpers.reset
|
||||
@ -15,13 +15,13 @@ local get_shada_rw = shada_helpers.get_shada_rw
|
||||
local mpack_eq = function(expected, mpack_result)
|
||||
local mpack_keys = {'type', 'timestamp', 'length', 'value'}
|
||||
|
||||
local unpacker = msgpack.unpacker(mpack_result)
|
||||
local unpack = mpack.Unpacker()
|
||||
local actual = {}
|
||||
local cur
|
||||
local cur, val
|
||||
local i = 0
|
||||
while true do
|
||||
local off, val = unpacker()
|
||||
if not off then break end
|
||||
local off = 1
|
||||
while off <= #mpack_result do
|
||||
val, off = unpack(mpack_result, off)
|
||||
if i % 4 == 0 then
|
||||
cur = {}
|
||||
actual[#actual + 1] = cur
|
||||
@ -78,36 +78,6 @@ describe('In autoload/shada.vim', function()
|
||||
return ('{"_TYPE": v:msgpack_types.%s, "_VAL": %s}'):format(typ, val)
|
||||
end
|
||||
|
||||
local st_meta = {
|
||||
__pairs=function(table)
|
||||
local ret = {}
|
||||
local next_key = nil
|
||||
local num_keys = 0
|
||||
while true do
|
||||
next_key = next(table, next_key)
|
||||
if next_key == nil then
|
||||
break
|
||||
end
|
||||
num_keys = num_keys + 1
|
||||
ret[num_keys] = {next_key, table[next_key]}
|
||||
end
|
||||
table.sort(ret, function(a, b)
|
||||
return a[1] < b[1]
|
||||
end)
|
||||
local state = {i=0}
|
||||
return (function(state_, _)
|
||||
state_.i = state_.i + 1
|
||||
if ret[state_.i] then
|
||||
return table.unpack(ret[state_.i])
|
||||
end
|
||||
end), state
|
||||
end
|
||||
}
|
||||
|
||||
local st = function(table)
|
||||
return setmetatable(table, st_meta)
|
||||
end
|
||||
|
||||
describe('function shada#mpack_to_sd', function()
|
||||
local mpack2sd = function(arg)
|
||||
return ('shada#mpack_to_sd(%s)'):format(arg)
|
||||
@ -184,7 +154,7 @@ describe('In autoload/shada.vim', function()
|
||||
' + b 2',
|
||||
' + c column 3',
|
||||
' + d 4',
|
||||
}, {{type=1, timestamp=0, data=st({a=1, b=2, c=3, d=4})}})
|
||||
}, {{type=1, timestamp=0, data={a=1, b=2, c=3, d=4}}})
|
||||
sd2strings_eq({
|
||||
'Header with timestamp ' .. epoch .. ':',
|
||||
' % Key Value',
|
||||
@ -2848,3 +2818,4 @@ describe('syntax/shada.vim', function()
|
||||
eq(exp, act)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
@ -272,7 +272,7 @@ describe('ShaDa forward compatibility support code', function()
|
||||
eq(0, exc_exec(sdrcmd(true)))
|
||||
-- getreg may return empty list as list with NULL pointer which API
|
||||
-- translates into nil for some reason.
|
||||
eq({}, funcs.getreg('a', 1, 1) or {})
|
||||
eq(NIL, funcs.getreg('a', 1, 1) or {})
|
||||
eq('', funcs.getregtype('a'))
|
||||
nvim_command('wshada ' .. shada_fname)
|
||||
local found = 0
|
||||
|
@ -3,7 +3,7 @@ local spawn, set_session, meths, nvim_prog =
|
||||
helpers.spawn, helpers.set_session, helpers.meths, helpers.nvim_prog
|
||||
local write_file, merge_args = helpers.write_file, helpers.merge_args
|
||||
|
||||
local msgpack = require('MessagePack')
|
||||
local mpack = require('mpack')
|
||||
|
||||
local tmpname = os.tmpname()
|
||||
local additional_cmd = ''
|
||||
@ -20,14 +20,8 @@ local function nvim_argv()
|
||||
end
|
||||
end
|
||||
|
||||
local session = nil
|
||||
|
||||
local reset = function()
|
||||
if session then
|
||||
session:exit(0)
|
||||
end
|
||||
session = spawn(nvim_argv())
|
||||
set_session(session)
|
||||
set_session(spawn(nvim_argv()))
|
||||
meths.set_var('tmpname', tmpname)
|
||||
end
|
||||
|
||||
@ -66,13 +60,13 @@ local read_shada_file = function(fname)
|
||||
local fd = io.open(fname, 'r')
|
||||
local mstring = fd:read('*a')
|
||||
fd:close()
|
||||
local unpacker = msgpack.unpacker(mstring)
|
||||
local unpack = mpack.Unpacker()
|
||||
local ret = {}
|
||||
local cur
|
||||
local cur, val
|
||||
local i = 0
|
||||
while true do
|
||||
local off, val = unpacker()
|
||||
if not off then break end
|
||||
local off = 1
|
||||
while off <= #mstring do
|
||||
val, off = unpack(mstring, off)
|
||||
if i % 4 == 0 then
|
||||
cur = {}
|
||||
ret[#ret + 1] = cur
|
||||
|
@ -43,9 +43,9 @@ describe('ShaDa support code', function()
|
||||
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
|
||||
nvim_command('qall')
|
||||
reset()
|
||||
eq({nil, ''}, getreg('c'))
|
||||
eq({nil, ''}, getreg('l'))
|
||||
eq({nil, ''}, getreg('b'))
|
||||
eq({NIL, ''}, getreg('c'))
|
||||
eq({NIL, ''}, getreg('l'))
|
||||
eq({NIL, ''}, getreg('b'))
|
||||
end)
|
||||
|
||||
it('does restore registers with zero <', function()
|
||||
@ -67,9 +67,9 @@ describe('ShaDa support code', function()
|
||||
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
|
||||
nvim_command('qall')
|
||||
reset()
|
||||
eq({nil, ''}, getreg('c'))
|
||||
eq({nil, ''}, getreg('l'))
|
||||
eq({nil, ''}, getreg('b'))
|
||||
eq({NIL, ''}, getreg('c'))
|
||||
eq({NIL, ''}, getreg('l'))
|
||||
eq({NIL, ''}, getreg('b'))
|
||||
end)
|
||||
|
||||
it('does restore registers with zero "', function()
|
||||
@ -103,7 +103,7 @@ describe('ShaDa support code', function()
|
||||
nvim_command('qall')
|
||||
reset()
|
||||
eq({{'d'}, 'v'}, getreg('o'))
|
||||
eq({nil, ''}, getreg('t'))
|
||||
eq({NIL, ''}, getreg('t'))
|
||||
end)
|
||||
|
||||
it('does limit number of lines according to "', function()
|
||||
@ -113,7 +113,7 @@ describe('ShaDa support code', function()
|
||||
nvim_command('qall')
|
||||
reset()
|
||||
eq({{'d'}, 'v'}, getreg('o'))
|
||||
eq({nil, ''}, getreg('t'))
|
||||
eq({NIL, ''}, getreg('t'))
|
||||
end)
|
||||
|
||||
it('does limit number of lines according to < rather then "', function()
|
||||
@ -125,7 +125,7 @@ describe('ShaDa support code', function()
|
||||
reset()
|
||||
eq({{'d'}, 'v'}, getreg('o'))
|
||||
eq({{'a', 'b', 'cde'}, 'V'}, getreg('t'))
|
||||
eq({nil, ''}, getreg('h'))
|
||||
eq({NIL, ''}, getreg('h'))
|
||||
end)
|
||||
|
||||
it('dumps and loads register correctly when &encoding is not UTF-8',
|
||||
|
@ -8,7 +8,7 @@ local write_file, spawn, set_session, nvim_prog, exc_exec =
|
||||
local lfs = require('lfs')
|
||||
local paths = require('test.config.paths')
|
||||
|
||||
local msgpack = require('MessagePack')
|
||||
local mpack = require('mpack')
|
||||
|
||||
local shada_helpers = require('test.functional.shada.helpers')
|
||||
local reset, clear, get_shada_rw =
|
||||
@ -107,7 +107,7 @@ describe('ShaDa support code', function()
|
||||
end)
|
||||
|
||||
it('reads correctly various timestamps', function()
|
||||
local mpack = {
|
||||
local msgpack = {
|
||||
'\100', -- Positive fixnum 100
|
||||
'\204\255', -- uint 8 255
|
||||
'\205\010\003', -- uint 16 2563
|
||||
@ -116,23 +116,23 @@ describe('ShaDa support code', function()
|
||||
}
|
||||
local s = '\100'
|
||||
local e = '\001\192'
|
||||
wshada(s .. table.concat(mpack, e .. s) .. e)
|
||||
wshada(s .. table.concat(msgpack, e .. s) .. e)
|
||||
eq(0, exc_exec('wshada ' .. shada_fname))
|
||||
local found = 0
|
||||
local typ = select(2, msgpack.unpacker(s)())
|
||||
local typ = mpack.unpack(s)
|
||||
for _, v in ipairs(read_shada_file(shada_fname)) do
|
||||
if v.type == typ then
|
||||
found = found + 1
|
||||
eq(select(2, msgpack.unpacker(mpack[found])()), v.timestamp)
|
||||
eq(mpack.unpack(msgpack[found]), v.timestamp)
|
||||
end
|
||||
end
|
||||
eq(#mpack, found)
|
||||
eq(#msgpack, found)
|
||||
end)
|
||||
|
||||
it('does not write NONE file', function()
|
||||
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
|
||||
'--cmd', 'qall'}, true)
|
||||
session:exit(0)
|
||||
session:close()
|
||||
eq(nil, lfs.attributes('NONE'))
|
||||
eq(nil, lfs.attributes('NONE.tmp.a'))
|
||||
end)
|
||||
@ -143,7 +143,7 @@ describe('ShaDa support code', function()
|
||||
true)
|
||||
set_session(session)
|
||||
eq('', funcs.getreg('a'))
|
||||
session:exit(0)
|
||||
session:close()
|
||||
os.remove('NONE')
|
||||
end)
|
||||
|
||||
|
@ -59,7 +59,7 @@ describe('terminal cursor', function()
|
||||
]])
|
||||
end)
|
||||
|
||||
it('is positioned correctly when focused', function()
|
||||
pending('is positioned correctly when focused', function()
|
||||
feed('i')
|
||||
screen:expect([[
|
||||
1 tty ready |
|
||||
|
@ -138,7 +138,7 @@ do
|
||||
-- this is just a helper to get any canonical name of a color
|
||||
colornames[rgb] = name
|
||||
end
|
||||
session:exit(0)
|
||||
session:close()
|
||||
Screen.colors = colors
|
||||
Screen.colornames = colornames
|
||||
end
|
||||
|
8
third-party/CMakeLists.txt
vendored
8
third-party/CMakeLists.txt
vendored
@ -21,6 +21,7 @@ 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})
|
||||
option(USE_BUNDLED_LUV "Use the bundled version of luv." ${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)
|
||||
@ -100,6 +101,9 @@ set(LIBVTERM_SHA256 1a4272be91d9614dc183a503786df83b6584e4afaab7feaaa5409f841afb
|
||||
|
||||
set(JEMALLOC_URL https://github.com/jemalloc/jemalloc/releases/download/4.0.2/jemalloc-4.0.2.tar.bz2)
|
||||
set(JEMALLOC_SHA256 0d8a9c8a98adb6983e0ccb521d45d9db1656ef3e71d0b14fb333f2c8138f4611)
|
||||
|
||||
set(LUV_URL https://github.com/luvit/luv/archive/146f1ce4c08c3b67f604c9ee1e124b1cf5c15cf3.tar.gz)
|
||||
set(LUV_SHA256 3d537f8eb9fa5adb146a083eae22af886aee324ec268e2aa0fa75f2f1c52ca7a)
|
||||
|
||||
if(USE_BUNDLED_UNIBILIUM)
|
||||
include(BuildUnibilium)
|
||||
@ -137,6 +141,10 @@ if(USE_BUNDLED_JEMALLOC)
|
||||
include(BuildJeMalloc)
|
||||
endif()
|
||||
|
||||
if(USE_BUNDLED_LUV)
|
||||
include(BuildLuv)
|
||||
endif()
|
||||
|
||||
add_custom_target(clean-shared-libraries
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DREMOVE_FILE_GLOB=${DEPS_INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}*${CMAKE_SHARED_LIBRARY_SUFFIX}*
|
||||
|
2
third-party/cmake/BuildLua.cmake
vendored
2
third-party/cmake/BuildLua.cmake
vendored
@ -77,7 +77,7 @@ 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}
|
||||
COMMAND sed -e 's/^exec/exec $$LUA_DEBUGGER/' -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)
|
||||
|
35
third-party/cmake/BuildLuarocks.cmake
vendored
35
third-party/cmake/BuildLuarocks.cmake
vendored
@ -89,25 +89,26 @@ list(APPEND THIRD_PARTY_DEPS luarocks)
|
||||
|
||||
if(USE_BUNDLED_LUAJIT)
|
||||
add_dependencies(luarocks luajit)
|
||||
if(MINGW AND CMAKE_CROSSCOMPILING)
|
||||
add_dependencies(luarocks luajit_host)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Each target depends on the previous module, this serializes all calls to
|
||||
# luarocks since it is unhappy to be called in parallel.
|
||||
add_custom_command(OUTPUT ${HOSTDEPS_LIB_DIR}/luarocks/rocks/lua-messagepack
|
||||
add_custom_command(OUTPUT ${HOSTDEPS_LIB_DIR}/luarocks/rocks/mpack
|
||||
COMMAND ${LUAROCKS_BINARY}
|
||||
ARGS build lua-messagepack ${LUAROCKS_BUILDARGS}
|
||||
ARGS build mpack ${LUAROCKS_BUILDARGS}
|
||||
DEPENDS luarocks)
|
||||
add_custom_target(lua-messagepack
|
||||
DEPENDS ${HOSTDEPS_LIB_DIR}/luarocks/rocks/lua-messagepack)
|
||||
list(APPEND THIRD_PARTY_DEPS lua-messagepack)
|
||||
add_custom_target(mpack
|
||||
DEPENDS ${HOSTDEPS_LIB_DIR}/luarocks/rocks/mpack)
|
||||
list(APPEND THIRD_PARTY_DEPS mpack)
|
||||
|
||||
|
||||
# Like before, depend on lua-messagepack to ensure serialization of install
|
||||
# commands
|
||||
add_custom_command(OUTPUT ${HOSTDEPS_LIB_DIR}/luarocks/rocks/lpeg
|
||||
COMMAND ${LUAROCKS_BINARY}
|
||||
ARGS build lpeg ${LUAROCKS_BUILDARGS}
|
||||
DEPENDS lua-messagepack)
|
||||
DEPENDS mpack)
|
||||
add_custom_target(lpeg
|
||||
DEPENDS ${HOSTDEPS_LIB_DIR}/luarocks/rocks/lpeg)
|
||||
|
||||
@ -117,7 +118,7 @@ if(USE_BUNDLED_BUSTED)
|
||||
add_custom_command(OUTPUT ${HOSTDEPS_BIN_DIR}/busted
|
||||
COMMAND ${LUAROCKS_BINARY}
|
||||
ARGS build https://raw.githubusercontent.com/Olivine-Labs/busted/v2.0.rc11-0/busted-2.0.rc11-0.rockspec ${LUAROCKS_BUILDARGS}
|
||||
DEPENDS luarocks)
|
||||
DEPENDS lpeg)
|
||||
add_custom_target(busted
|
||||
DEPENDS ${HOSTDEPS_BIN_DIR}/busted)
|
||||
|
||||
@ -128,10 +129,22 @@ if(USE_BUNDLED_BUSTED)
|
||||
add_custom_target(luacheck
|
||||
DEPENDS ${HOSTDEPS_BIN_DIR}/luacheck)
|
||||
|
||||
set(LUV_DEPS luacheck luv-static)
|
||||
if(MINGW AND CMAKE_CROSSCOMPILING)
|
||||
set(LUV_DEPS ${LUV_DEPS} libuv_host)
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${HOSTDEPS_LIB_DIR}/luarocks/rocks/luv
|
||||
COMMAND ${LUAROCKS_BINARY}
|
||||
ARGS make ${LUAROCKS_BUILDARGS} LIBUV_DIR=${HOSTDEPS_INSTALL_DIR} CFLAGS='-O0 -g3 -fPIC'
|
||||
WORKING_DIRECTORY ${DEPS_BUILD_DIR}/src/luv
|
||||
DEPENDS ${LUV_DEPS})
|
||||
add_custom_target(luv
|
||||
DEPENDS ${HOSTDEPS_LIB_DIR}/luarocks/rocks/luv)
|
||||
|
||||
add_custom_command(OUTPUT ${HOSTDEPS_LIB_DIR}/luarocks/rocks/nvim-client
|
||||
COMMAND ${LUAROCKS_BINARY}
|
||||
ARGS build https://raw.githubusercontent.com/neovim/lua-client/0.0.1-14/nvim-client-0.0.1-14.rockspec ${LUAROCKS_BUILDARGS} LIBUV_DIR=${HOSTDEPS_INSTALL_DIR}
|
||||
DEPENDS luacheck libuv)
|
||||
ARGS build https://raw.githubusercontent.com/neovim/lua-client/0.0.1-24/nvim-client-0.0.1-24.rockspec ${LUAROCKS_BUILDARGS}
|
||||
DEPENDS luv)
|
||||
add_custom_target(nvim-client
|
||||
DEPENDS ${HOSTDEPS_LIB_DIR}/luarocks/rocks/nvim-client)
|
||||
|
||||
|
90
third-party/cmake/BuildLuv.cmake
vendored
Normal file
90
third-party/cmake/BuildLuv.cmake
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# BuildLuv(PATCH_COMMAND ... CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...)
|
||||
# Reusable function to build luv, wraps ExternalProject_Add.
|
||||
# Failing to pass a command argument will result in no command being run
|
||||
function(BuildLuv)
|
||||
cmake_parse_arguments(_luv
|
||||
""
|
||||
""
|
||||
"PATCH_COMMAND;CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
|
||||
${ARGN})
|
||||
|
||||
if(NOT _luv_CONFIGURE_COMMAND AND NOT _luv_BUILD_COMMAND
|
||||
AND NOT _luv_INSTALL_COMMAND)
|
||||
message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND")
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(luv-static
|
||||
PREFIX ${DEPS_BUILD_DIR}
|
||||
URL ${LUV_URL}
|
||||
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/luv
|
||||
DOWNLOAD_COMMAND ${CMAKE_COMMAND}
|
||||
-DPREFIX=${DEPS_BUILD_DIR}
|
||||
-DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/luv
|
||||
-DURL=${LUV_URL}
|
||||
-DEXPECTED_SHA256=${LUV_SHA256}
|
||||
-DTARGET=luv
|
||||
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
|
||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
|
||||
PATCH_COMMAND "${_luv_PATCH_COMMAND}"
|
||||
CONFIGURE_COMMAND "${_luv_CONFIGURE_COMMAND}"
|
||||
BUILD_COMMAND "${_luv_BUILD_COMMAND}"
|
||||
INSTALL_COMMAND "${_luv_INSTALL_COMMAND}")
|
||||
endfunction()
|
||||
|
||||
set(LUV_SRC_DIR ${DEPS_BUILD_DIR}/src/luv)
|
||||
set(LUV_INCLUDE_FLAGS
|
||||
"-I${DEPS_INSTALL_DIR}/include -I${DEPS_INSTALL_DIR}/include/luajit-2.0")
|
||||
|
||||
set(LUV_PATCH_COMMAND
|
||||
${CMAKE_COMMAND} -DLUV_SRC_DIR=${LUV_SRC_DIR}
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/PatchLuv.cmake)
|
||||
|
||||
set(LUV_CONFIGURE_COMMAND_COMMON
|
||||
${CMAKE_COMMAND} ${LUV_SRC_DIR}
|
||||
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
||||
-DLUA_BUILD_TYPE=System
|
||||
-DWITH_SHARED_LIBUV=ON
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
-DBUILD_MODULE=OFF)
|
||||
|
||||
if(MINGW AND CMAKE_CROSSCOMPILING)
|
||||
get_filename_component(TOOLCHAIN ${CMAKE_TOOLCHAIN_FILE} REALPATH)
|
||||
set(LUV_CONFIGURE_COMMAND
|
||||
${LUV_CONFIGURE_COMMAND_COMMON}
|
||||
# Pass toolchain
|
||||
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}
|
||||
"-DCMAKE_C_FLAGS:STRING=${LUV_INCLUDE_FLAGS} -D_WIN32_WINNT=0x0600"
|
||||
# Hack to avoid -rdynamic in Mingw
|
||||
-DCMAKE_SHARED_LIBRARY_LINK_C_FLAGS="")
|
||||
elseif(MSVC)
|
||||
set(LUV_CONFIGURE_COMMAND
|
||||
${LUV_CONFIGURE_COMMAND_COMMON}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
# Same as Unix without fPIC
|
||||
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} ${LUV_INCLUDE_FLAGS}"
|
||||
# Make sure we use the same generator, otherwise we may
|
||||
# accidentaly end up using different MSVC runtimes
|
||||
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
|
||||
# Use static runtime
|
||||
-DCMAKE_C_FLAGS_DEBUG="-MTd"
|
||||
-DCMAKE_C_FLAGS_RELEASE="-MT")
|
||||
else()
|
||||
set(LUV_CONFIGURE_COMMAND
|
||||
${LUV_CONFIGURE_COMMAND_COMMON}
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} ${LUV_INCLUDE_FLAGS} -fPIC")
|
||||
endif()
|
||||
|
||||
set(LUV_BUILD_COMMAND ${CMAKE_COMMAND} --build .)
|
||||
set(LUV_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install)
|
||||
|
||||
BuildLuv(PATCH_COMMAND ${LUV_PATCH_COMMAND}
|
||||
CONFIGURE_COMMAND ${LUV_CONFIGURE_COMMAND}
|
||||
BUILD_COMMAND ${LUV_BUILD_COMMAND}
|
||||
INSTALL_COMMAND ${LUV_INSTALL_COMMAND})
|
||||
|
||||
list(APPEND THIRD_PARTY_DEPS luv-static)
|
||||
add_dependencies(luv-static luajit)
|
||||
add_dependencies(luv-static libuv)
|
29
third-party/cmake/PatchLuv.cmake
vendored
Normal file
29
third-party/cmake/PatchLuv.cmake
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
# replace luv default rockspec with the alternate one under the "rockspecs"
|
||||
# directory
|
||||
file(GLOB LUV_ROCKSPEC RELATIVE ${LUV_SRC_DIR} ${LUV_SRC_DIR}/*.rockspec)
|
||||
file(RENAME ${LUV_SRC_DIR}/rockspecs/${LUV_ROCKSPEC} ${LUV_SRC_DIR}/${LUV_ROCKSPEC})
|
||||
|
||||
# Some versions of mingw are missing defines required by luv dns module, add
|
||||
# them now
|
||||
set(LUV_SRC_DNS_C_DEFS
|
||||
"#ifndef AI_NUMERICSERV
|
||||
# define AI_NUMERICSERV 0x0008
|
||||
#endif
|
||||
#ifndef AI_ALL
|
||||
# define AI_ALL 0x00000100
|
||||
#endif
|
||||
#ifndef AI_ADDRCONFIG
|
||||
# define AI_ADDRCONFIG 0x00000400
|
||||
#endif
|
||||
#ifndef AI_V4MAPPED
|
||||
# define AI_V4MAPPED 0x00000800
|
||||
#endif")
|
||||
|
||||
file(READ ${LUV_SRC_DIR}/src/dns.c LUV_SRC_DNS_C)
|
||||
string(REPLACE
|
||||
"\n#include <netdb.h>"
|
||||
"\n#include <netdb.h>\n#else\n${LUV_SRC_DNS_C_DEFS}"
|
||||
LUV_SRC_DNS_C_PATCHED
|
||||
"${LUV_SRC_DNS_C}")
|
||||
file(WRITE ${LUV_SRC_DIR}/src/dns.c "${LUV_SRC_DNS_C_PATCHED}")
|
||||
|
Loading…
Reference in New Issue
Block a user