2022-12-02 03:35:40 +08:00
|
|
|
TEST_FILE?=$(realpath tests)
|
2023-02-18 21:44:28 +08:00
|
|
|
|
|
|
|
NVIM_PATH=deps/nvim_multiversion
|
|
|
|
# relative to ${NVIM_PATH} and relative to this makefile.
|
|
|
|
NVIM_MASTER_PATH_REL=worktree_master
|
|
|
|
NVIM_0.7_PATH_REL=worktree_0.7
|
2023-09-20 22:42:05 +08:00
|
|
|
NVIM_0.9_PATH_REL=worktree_0.9
|
2023-02-18 21:44:28 +08:00
|
|
|
NVIM_MASTER_PATH=${NVIM_PATH}/${NVIM_MASTER_PATH_REL}
|
|
|
|
NVIM_0.7_PATH=${NVIM_PATH}/${NVIM_0.7_PATH_REL}
|
2023-09-20 22:42:05 +08:00
|
|
|
NVIM_0.9_PATH=${NVIM_PATH}/${NVIM_0.9_PATH_REL}
|
2023-02-18 21:44:28 +08:00
|
|
|
|
|
|
|
# directory as target.
|
|
|
|
${NVIM_PATH}:
|
2023-09-20 22:42:05 +08:00
|
|
|
# fetch current master and 0.7.0 (the minimum version we support) and 0.9.0
|
|
|
|
# (the minimum version for treesitter-postfix to work).
|
2023-02-18 21:44:28 +08:00
|
|
|
git clone --bare --depth 1 https://github.com/neovim/neovim ${NVIM_PATH}
|
|
|
|
git -C ${NVIM_PATH} fetch --depth 1 origin tag v0.7.0
|
2023-09-20 22:42:05 +08:00
|
|
|
git -C ${NVIM_PATH} fetch --depth 1 origin tag v0.9.0
|
2023-02-18 21:44:28 +08:00
|
|
|
# create one worktree for master, and one for 0.7.
|
|
|
|
# The rationale behind this is that switching from 0.7 to master (and
|
|
|
|
# vice-versa) requires a `make distclean`, and full clean build, which takes
|
|
|
|
# a lot of time.
|
|
|
|
# The most straightforward solution seems to be too keep two worktrees, one
|
2023-09-20 22:42:05 +08:00
|
|
|
# for master, one for 0.7, and one for 0.9 which are used for the
|
|
|
|
# respective builds/tests.
|
2023-02-18 21:44:28 +08:00
|
|
|
git -C ${NVIM_PATH} worktree add ${NVIM_MASTER_PATH_REL} master
|
|
|
|
git -C ${NVIM_PATH} worktree add ${NVIM_0.7_PATH_REL} v0.7.0
|
2023-09-20 22:42:05 +08:00
|
|
|
git -C ${NVIM_PATH} worktree add ${NVIM_0.9_PATH_REL} v0.9.0
|
2023-02-18 21:44:28 +08:00
|
|
|
|
|
|
|
# |: don't update `nvim` if `${NVIM_PATH}` is changed.
|
|
|
|
nvim: | ${NVIM_PATH}
|
|
|
|
# only update master
|
2023-05-19 21:17:46 +08:00
|
|
|
git -C ${NVIM_MASTER_PATH} fetch origin master --depth 1
|
|
|
|
git -C ${NVIM_MASTER_PATH} checkout FETCH_HEAD
|
2021-10-01 21:19:27 +08:00
|
|
|
|
2023-06-30 04:52:44 +08:00
|
|
|
LUASNIP_DETECTED_OS?=$(shell uname)
|
|
|
|
ifeq ($(LUASNIP_DETECTED_OS),Darwin)
|
2023-06-15 03:22:45 +08:00
|
|
|
# flags for dynamic linking on macos, from luarocks
|
|
|
|
# (https://github.com/luarocks/luarocks/blob/9a3c5a879849f4f411a96cf1bdc0c4c7e26ade42/src/luarocks/core/cfg.lua#LL468C37-L468C80)
|
|
|
|
# remove -bundle, should be equivalent to the -shared hardcoded by jsregexp.
|
|
|
|
LUA_LDLIBS=-undefined dynamic_lookup -all_load
|
2022-09-02 01:08:44 +08:00
|
|
|
endif
|
2023-11-30 06:01:28 +08:00
|
|
|
|
2022-07-11 01:46:59 +08:00
|
|
|
JSREGEXP_PATH=deps/jsregexp
|
2023-11-30 06:01:28 +08:00
|
|
|
JSREGEXP005_PATH=deps/jsregexp005
|
2022-07-11 01:46:59 +08:00
|
|
|
jsregexp:
|
2022-08-22 15:24:59 +08:00
|
|
|
git submodule init
|
|
|
|
git submodule update
|
2024-06-27 13:15:00 +08:00
|
|
|
"$(MAKE)" "CC=$(CC)" "INCLUDE_DIR=-I'$(shell pwd)/deps/lua51_include/'" LDLIBS="${LUA_LDLIBS}" -C "${JSREGEXP_PATH}"
|
|
|
|
"$(MAKE)" "CC=$(CC)" "INCLUDE_DIR=-I'$(shell pwd)/deps/lua51_include/'" LDLIBS="${LUA_LDLIBS}" -C "${JSREGEXP005_PATH}"
|
2022-08-22 15:24:59 +08:00
|
|
|
|
|
|
|
install_jsregexp: jsregexp
|
2023-11-30 06:01:28 +08:00
|
|
|
# remove old binary.
|
|
|
|
rm "$(shell pwd)/lua/luasnip-jsregexp.so" || true
|
|
|
|
# there is some additional trickery to make this work with jsregexp-0.0.6 in
|
|
|
|
# util/jsregexp.lua.
|
|
|
|
cp "$(shell pwd)/${JSREGEXP_PATH}/jsregexp.lua" "$(shell pwd)/lua/luasnip-jsregexp.lua"
|
|
|
|
# just move out of jsregexp-directory, so it is not accidentially deleted.
|
|
|
|
cp "$(shell pwd)/${JSREGEXP_PATH}/jsregexp.so" "$(shell pwd)/deps/luasnip-jsregexp.so"
|
2022-07-11 01:46:59 +08:00
|
|
|
|
2022-08-28 01:05:07 +08:00
|
|
|
uninstall_jsregexp:
|
2023-11-30 06:01:28 +08:00
|
|
|
# also remove binaries of older version.
|
2024-04-05 14:49:06 +08:00
|
|
|
rm -f "$(shell pwd)/lua/luasnip-jsregexp.so"
|
|
|
|
rm -f "$(shell pwd)/deps/luasnip-jsregexp.so"
|
|
|
|
rm -f "$(shell pwd)/lua/luasnip-jsregexp.lua"
|
2022-08-28 01:05:07 +08:00
|
|
|
|
2023-03-23 05:42:34 +08:00
|
|
|
TEST_07?=true
|
2023-09-20 22:42:05 +08:00
|
|
|
TEST_09?=true
|
2023-03-23 05:42:34 +08:00
|
|
|
TEST_MASTER?=true
|
2021-10-01 21:19:27 +08:00
|
|
|
# Expects to be run from repo-location (eg. via `make -C path/to/luasnip`).
|
2023-11-30 06:01:28 +08:00
|
|
|
test: nvim install_jsregexp
|
2023-02-18 21:44:28 +08:00
|
|
|
# unset PATH and CPATH to prevent system-env leaking into the neovim-build,
|
|
|
|
# add our helper-functions to lpath.
|
2023-03-23 05:42:34 +08:00
|
|
|
# exit as soon as an error occurs.
|
2023-02-18 21:44:28 +08:00
|
|
|
unset LUA_PATH LUA_CPATH; \
|
|
|
|
export LUASNIP_SOURCE=$(shell pwd); \
|
2023-11-30 06:01:28 +08:00
|
|
|
export JSREGEXP_ABS_PATH=$(shell pwd)/${JSREGEXP_PATH}; \
|
|
|
|
export JSREGEXP005_ABS_PATH=$(shell pwd)/${JSREGEXP005_PATH}; \
|
2023-02-18 21:44:28 +08:00
|
|
|
export TEST_FILE=$(realpath ${TEST_FILE}); \
|
|
|
|
export BUSTED_ARGS=--lpath=$(shell pwd)/tests/?.lua; \
|
2023-03-23 05:42:34 +08:00
|
|
|
set -e; \
|
2024-06-27 13:15:00 +08:00
|
|
|
if ${TEST_07}; then "$(MAKE)" -C ${NVIM_0.7_PATH} functionaltest DEPS_CMAKE_FLAGS=-DUSE_BUNDLED_GPERF=OFF; fi; \
|
|
|
|
if ${TEST_09}; then "$(MAKE)" -C ${NVIM_0.9_PATH} functionaltest; fi; \
|
|
|
|
if ${TEST_MASTER}; then "$(MAKE)" -C ${NVIM_MASTER_PATH} functionaltest; fi;
|