-
Notifications
You must be signed in to change notification settings - Fork 124
/
Makefile
214 lines (191 loc) · 6.89 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# Use LuaJIT where possible, as some plugins assume it's available. Arches
# that can't use LuaJIT have to use the system Lua (and some plugins may not
# work).
.if ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "aarch64" || \
${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || \
${MACHINE_ARCH} == "powerpc"
EMBED_LUAJIT = Yes
.else
EMBED_LUAJIT = No
.endif
COMMENT = continuation and extension of Vim
DIST_TUPLE = github neovim neovim v0.10.2 .
REVISION = 0
# embedded luajit
USE_NOBTCFI = Yes
CATEGORIES = editors devel
HOMEPAGE = https://neovim.io
MAINTAINER = Edd Barrett <[email protected]>
# The versions listed here must match those in cmake.deps/deps.txt.
STATIC_DEPS_WRKSRC = ${WRKDIST}/static-deps/
DIST_TUPLE += github luvit luv 1.48.0-2 ${STATIC_DEPS_WRKSRC}/luv
DIST_TUPLE += github LuaJIT LuaJIT 75e92777988017fe47c5eb290998021bbf972d1f \
${STATIC_DEPS_WRKSRC}/luajit
DIST_TUPLE += github keplerproject lua-compat-5.3 v0.13 \
${STATIC_DEPS_WRKSRC}/lua-compat-5.3
DIST_TUPLE += github tree-sitter tree-sitter-c v0.21.3 \
${STATIC_DEPS_WRKSRC}/parsers/treesitter_c
DIST_TUPLE += github tree-sitter-grammars tree-sitter-lua v0.1.0 \
${STATIC_DEPS_WRKSRC}/parsers/treesitter_lua
DIST_TUPLE += github neovim tree-sitter-vim v0.4.0 \
${STATIC_DEPS_WRKSRC}/parsers/treesitter_vim
DIST_TUPLE += github neovim tree-sitter-vimdoc v3.0.0 \
${STATIC_DEPS_WRKSRC}/parsers/treesitter_vimdoc
DIST_TUPLE += github tree-sitter-grammars tree-sitter-query v0.4.0 \
${STATIC_DEPS_WRKSRC}/parsers/treesitter_query
DIST_TUPLE += github MDeiml tree-sitter-markdown v0.2.3 \
${STATIC_DEPS_WRKSRC}/parsers/treesitter_markdown
# Neovim: Apache 2.0 + Vim License
# LuaJIT: MIT + public domain
# libluv: Apache 2.0
PERMIT_PACKAGE = Yes
DEBUG_PACKAGES = ${BUILD_PACKAGES}
WANTLIB += c iconv intl m msgpack-c pthread
WANTLIB += tree-sitter unibilium util uv vterm
.if ${EMBED_LUAJIT} != "Yes"
WANTLIB += ${MODLUA_WANTLIB}
.endif
COMPILER = base-clang ports-gcc
MODULES = devel/cmake \
lang/lua \
textproc/intltool
# LuaJIT is binary compatible with Lua-5.1 extension modules, so we can use
# them directly, even on architectures where we will be embedding LuaJIT.
# https://luajit.org/extensions.html
MODLUA_VERSION = 5.1
BUILD_DEPENDS = ${RUN_DEPENDS} \
devel/gperf \
devel/lpeg \
devel/lua-bitop
LIB_DEPENDS = devel/gettext,-runtime \
devel/libuv \
devel/libvterm>=0.3.3 \
devel/msgpack \
devel/unibilium \
textproc/tree-sitter>=0.20.9
RUN_DEPENDS += devel/libmpack/lua \
devel/libmpack/main \
devel/lpeg \
devel/desktop-file-utils \
devel/lua-compat53 \
x11/gtk+4,-guic
SEPARATE_BUILD = Yes
CONFIGURE_ARGS += -DUSE_BUNDLED=OFF \
-DLUV_INCLUDE_DIR=${STATIC_DEPS_INST}/include \
-DLUV_LIBRARY=${STATIC_DEPS_INST}/lib/libluv.a
.if ${EMBED_LUAJIT} == "Yes"
CONFIGURE_ARGS += -DLUA_PRG=${STATIC_DEPS_INST}/bin/luajit \
-DLUAJIT_INCLUDE_DIR=${STATIC_DEPS_INST}/include/luajit-2.1 \
-DLUAJIT_LIBRARY=${STATIC_DEPS_INST}/lib/libluajit-5.1.a
.else
CONFIGURE_ARGS += -DPREFER_LUA=ON \
-DLUA_PRG=${MODLUA_BIN} \
-DLUA_INCLUDE_DIR=${MODLUA_INCL_DIR} \
-DLUA_LIBRARIES=${MODLUA_LIB}
.endif
MAKE_ENV = CCACHE_DISABLE=true
# Tests need gmake
USE_GMAKE = Yes
# `test_startup_utf8.vim' requires either bash or zsh
MODULES += lang/python
MODPY_RUNDEP = No
MODPY_BUILDDEP =No
TEST_DEPENDS = shells/bash \
editors/py-neovim \
editors/py-neovim${MODPY_FLAVOR}
# Build LuaJIT (if required) and libluv as static libraries.
#
# We opted not to create a libluv port because it must be built for a specific
# Lua version and we don't know what version future ports might need. Currently
# no other port requires libluv, so it's simpler to build a static library
# here.
#
# Most of the libluv target is lifted from ${MODCMAKE_configure} in
# cmake.port.mk. Unfortunately we can't use it directly, as some of the
# arguments make assumptions that can't work for us here.
#
# Neovim plugins expect a very specific version of LuaJIT, so it only really
# makes sense to embed it.
STATIC_DEPS_WRKBUILD=${WRKBUILD}/static-deps-build
STATIC_DEPS_INST=${WRKBUILD}/static-deps-inst
PARSERS_WRKBUILD=${STATIC_DEPS_WRKBUILD}/parsers
.include <bsd.port.arch.mk>
.if ${PROPERTIES:Mclang}
LUAJIT_TARGET_LIBS = "-lc++abi -lpthread"
WANTLIB += c++abi pthread
.endif
pre-configure:
mkdir -p ${STATIC_DEPS_WRKBUILD} ${STATIC_DEPS_PREFIX}
.if ${EMBED_LUAJIT} == "Yes"
# Build LuaJIT.
# We can't build LuaJIT out of its src dir, so copy it so that we can
# support SEPARATE_BUILD.
cp -r ${STATIC_DEPS_WRKSRC}/luajit ${STATIC_DEPS_WRKBUILD}/luajit
cd ${STATIC_DEPS_WRKBUILD}/luajit/src && \
${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} \
PREFIX=${STATIC_DEPS_INST} CC=${CC} CCOPT="${CFLAGS}" \
CCOPT_x86="" Q="" TARGET_LIBS=${LUAJIT_TARGET_LIBS} \
BUILDMODE=static
cd ${STATIC_DEPS_WRKBUILD}/luajit && \
${SETENV} ${MAKE_ENV} Q="" ${MAKE_PROGRAM} install \
PREFIX=${STATIC_DEPS_INST}
.endif
# Build libluv.
mkdir -p ${STATIC_DEPS_WRKBUILD}/luv
cd ${STATIC_DEPS_WRKBUILD}/luv && \
${SETENV} CC="${CC}" \
CXX="${CXX}" \
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
${CONFIGURE_ENV} \
${LOCALBASE}/bin/cmake \
-DBUILD_MODULE=OFF \
-DBUILD_STATIC_LIBS=ON \
-DCMAKE_COLOR_MAKEFILE=OFF \
-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON \
-DCMAKE_SUPPRESS_REGENERATION=ON \
-DCMAKE_INSTALL_PREFIX=${STATIC_DEPS_INST} \
-DLUA_BUILD_TYPE=System \
-DLUA_INCLUDE_DIR=${MODLUA_INCL_DIR} \
-DLUA_LIBRARIES=${MODLUA_LIBDIR} \
-DWITH_SHARED_LIBUV=ON \
-DLUA_COMPAT53_DIR=${STATIC_DEPS_WRKSRC}/lua-compat-5.3 \
-DWITH_LUA_ENGINE=Lua \
${STATIC_DEPS_WRKSRC}/luv
cd ${STATIC_DEPS_WRKBUILD}/luv && \
${SETENV} ${MAKE_ENV} VERBOSE=1 \
${MAKE_PROGRAM}
cd ${STATIC_DEPS_WRKBUILD}/luv && \
${SETENV} ${MAKE_ENV} VERBOSE=1 \
${MAKE_PROGRAM} install
# Build the treesitter parsers.
#
# For this we borrow a trick from FreeBSD and re-use just the part of
# upstream's build system that builds the parsers.
mkdir -p ${PARSERS_WRKBUILD}/build/src
for i in ${STATIC_DEPS_WRKSRC}/parsers/*; do \
cp -r $${i} ${PARSERS_WRKBUILD}/build/src/$$(basename $$i); \
done
${MAKE_ENV} ${LOCALBASE}/bin/cmake -S ${WRKSRC}/cmake.deps \
-B ${PARSERS_WRKBUILD} ${CONFIGURE_ARGS} \
-DUSE_BUNDLED_TS_PARSERS=ON \
-DUSE_EXISTING_SRC_DIR:BOOL=ON
# The following line both builds *and* installs the parsers.
${MAKE_ENV} ${LOCALBASE}/bin/cmake --build ${PARSERS_WRKBUILD}
mkdir -p ${WRKBUILD}/lib/nvim/parser
cp -r ${PARSERS_WRKBUILD}/usr/lib/nvim/parser/*.so \
${WRKBUILD}/lib/nvim/parser/
# These are the "old tests". There is also a new suite, but we would need the
# "busted" test suite for Lua, which is not yet ported.
#
# Test_language_cmd fails due to:
# https://github.com/neovim/neovim/issues/19331
#
# Test_linebreak_list test fails (test_breakindent.vim)
#
do-test:
true
${SETENV} LC_CTYPE=en_US.UTF-8 \
${MAKE_PROGRAM} -C ${WRKSRC}/test/old/testdir \
HOME=${WRKBUILD} NVIM_PRG=${WRKBUILD}/bin/nvim ${MAKE_FLAGS}
.include <bsd.port.mk>