mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
0b2f6a0cf4
This achieves several goals: * Less reliance on scripts so we have better portability to Windows (though we still have a ways to go for proper Windows support). Luajit, luarocks, moonscript, and busted are all installed via CMake now. * Trying to make use of pkg-config to get the correct libraries. The latest libuv is still broken in this regard, but we'll at least be in a position to use it. * Allow the use of Ninja or make. The former runs faster in many environments, and automatically makes use of parallel builds. This also allows for system installed dependencies--though not through the Makefile just yet--and adds support for FreeBSD. This also make us build libuv and luajit as static libraries only, since we're only concerned about having static libraries for our bundled dependencies.
60 lines
1.5 KiB
Plaintext
60 lines
1.5 KiB
Plaintext
ffi = require 'ffi'
|
|
|
|
-- load neovim shared library
|
|
testlib = os.getenv 'NVIM_TEST_LIB'
|
|
unless testlib
|
|
testlib = './build/src/libnvim-test.so'
|
|
|
|
libnvim = ffi.load testlib
|
|
|
|
-- Luajit ffi parser doesn't understand preprocessor directives, so
|
|
-- this helper function removes common directives before passing it the to ffi.
|
|
-- It will return a pointer to the library table, emulating 'requires'
|
|
cimport = (path) ->
|
|
header_file = io.open path, 'rb'
|
|
|
|
if not header_file
|
|
error "cannot find #{path}"
|
|
|
|
header = header_file\read '*a'
|
|
header_file.close!
|
|
header = string.gsub header, '#include[^\n]*\n', ''
|
|
header = string.gsub header, '#ifndef[^\n]*\n', ''
|
|
header = string.gsub header, '#define[^\n]*\n', ''
|
|
header = string.gsub header, '#endif[^\n]*\n', ''
|
|
ffi.cdef header
|
|
|
|
return libnvim
|
|
|
|
testinc = os.getenv 'TEST_INCLUDES'
|
|
unless testinc
|
|
testinc = './build/test/includes/post'
|
|
|
|
cppimport = (path) ->
|
|
return cimport testinc .. '/' .. path
|
|
|
|
cimport './src/types.h'
|
|
|
|
-- take a pointer to a C-allocated string and return an interned
|
|
-- version while also freeing the memory
|
|
internalize = (cdata) ->
|
|
ffi.gc cdata, ffi.C.free
|
|
return ffi.string cdata
|
|
|
|
cstr = ffi.typeof 'char[?]'
|
|
|
|
to_cstr = (string) ->
|
|
cstr (string.len string) + 1, string
|
|
|
|
return {
|
|
cimport: cimport
|
|
cppimport: cppimport
|
|
internalize: internalize
|
|
eq: (expected, actual) -> assert.are.same expected, actual
|
|
neq: (expected, actual) -> assert.are_not.same expected, actual
|
|
ffi: ffi
|
|
lib: libnvim
|
|
cstr: cstr
|
|
to_cstr: to_cstr
|
|
}
|