Files
ale/docker/install_vim.sh
T
Horacio Sanson 78122497f5
CI / Build (push) Has been cancelled
CI / Neovim 0.10 Windows (push) Has been cancelled
CI / Neovim 0.12 Windows (push) Has been cancelled
CI / Vim 8.2 Windows (push) Has been cancelled
CI / Vim 9.2 Windows (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Lua (push) Has been cancelled
CI / Neovim 0.10 Linux (push) Has been cancelled
CI / Neovim 0.12 Linux (push) Has been cancelled
CI / Vim 8.2 Linux (push) Has been cancelled
CI / Vim 9.2 Linux (push) Has been cancelled
Replace appveyor with GitHub actions (#5119)
* fix(tests): fix ale_c_build_dir_names being unset in tests (#5109)

- Use ale#Set() to set the ale_c_build_dir_names variable.
- Ensure SetUpLinterTest() is called before any Save commands in tests.
- Add c.vim to runtime before non-linter tests are executed.
- Remove workarounds in c.vim.

* feat: Load Prettier from cjs also

* Replace AppVeyor with GitHub Actions for Windows CI

Migrate Windows tests from AppVeyor (which hangs on PRs) to native GitHub
Actions using rhysd/action-setup-vim to install editors dynamically.

- Add test_ale_windows job testing Vim 9.0, Neovim 0.7, and Neovim 0.8
  on windows-latest, running in parallel with existing Linux CI
- Set fail-fast: false so all matrix entries report results independently
- Update run-tests.bat to accept VIM_EXE and VIM_HEADLESS env vars
  instead of hardcoding C:\vim\vim\vim80\vim.exe
- Add -n -i NONE and --not-a-term flags to avoid E211 temp file errors
  caused by Windows 8.3 short name paths losing drive letters
- Override TMP/TEMP to C:\tmp in CI to avoid 8.3 path mangling
- Use mklink /J directory junction for C:\testplugin to avoid modifying
  146+ test files that reference /testplugin/ paths
- Update doc/ale-development.txt section 4.3 for the new setup
- Remove AppVeyor badge from README.md
- Delete .appveyor.yml

Fix pre-existing Windows test failures now visible with Neovim on Windows:

- autoload/ale/c.vim: ParseCompileCommandsFlags bufnr() fails when the
  buffer path has a drive letter but the compile_commands key does not.
  Add fallback path comparison using ale#path#RemoveDriveLetter() so
  exact file matches work regardless of drive letter presence.
- autoload/ale/path.vim: FindNearestFile and FindNearestDirectory now
  return ale#path#Simplify() paths, fixing mixed slash separators on
  Windows that caused test_write_good.vader to fail.
- test/smoke_test.vader: echo output has trailing \r on Windows. Change
  strip pattern from ' *$' to '[\r ]*$' in all TestCallback functions.
- test/test_prepare_command.vader: &shellcmdflag on Windows is '/s /c'
  not '/c'. Use split(&shellcmdflag) in expected values so the test
  adapts to the actual default.
- test/test_lint_file_linters.vader: Increase WaitForJobs timeout from
  2000ms to 10000ms to prevent spurious timeouts on Windows CI runners.
- test/test_writefile_function.vader: Dissociate buffer from temp file
  before deleting it to avoid E211 on Windows.

* Fix Windows path handling and test compatibility issues

Production code fixes:
- ale/path.vim: Apply Simplify to buffer_filename in IsBufferPath to fix
  forward-slash vs backslash mismatch on Neovim Windows; handle .\ prefix
- ale/c.vim: Use iterative key-matching via RemoveDriveLetter for both
  file_lookup and dir_lookup in ParseCompileCommandsFlags
- ale/filename_mapping.vim: Normalize suffix separators when mapping target
  uses forward slashes (fixes mixed-separator paths on Windows)
- cuda/nvcc.vim: Apply Simplify before fnamemodify(:p) to fix path doubling

Test fixes:
- smoke_test: Use safe get() indexing and add retry loop for PowerShell test
- test_loclist_corrections: Use Simplify for cross-platform buffer paths
- test_ocaml_ocamllsp: Set buffer outside project tree before AssertLSPProject
- test_tex_textlint: Set buffer outside node_modules tree on Windows
- test_setting_problems_found_in_previous_buffers: Use cmd on Windows
- test_lint_file_linters: Increase WaitForJobs timeout to 30s

* Fix Vim 9.0 tempname() format change and simplify PowerShell test

Vim 9.0 changed tempname() to return a flat path (e.g. C:\tmp\VIMXXXXXXXX)
instead of the nested C:\tmp\VIMxxx\NNN format. Using :h:h on the flat
format resolves to the drive root, causing IsTempName() to match every
path on the drive. This broke tslint handler tests, loclist_corrections,
and setting_problems_found_in_previous_buffers tests.

Fix s:temp_dir to detect when :h:h yields a root path and fall back to :h.
Add GetTempBase() helper in test_format_command.vader with same logic.
Simplify smoke_test PowerShell test to avoid multi-command chaining that
produces unreliable output on Vim 9.0.

* fix(tests): normalize Windows path handling in Vim 9 CI

Treat win64 and win32unix as Windows in path and job helpers so compile_commands lookups and async command execution behave consistently on GitHub Actions. Normalize NVCC parsed filenames after absolute expansion to keep expected Windows paths stable in handler tests.

* fix(tests): handle Windows variants in command paths

Use a shared Windows check for command formatting and execution paths so Vim 9 on GitHub Actions still uses CMD-specific behavior. Apply the same check in filename mapping suffix normalization so Windows-style temporary and mapped paths are converted consistently in tests.

* ci: test newer Vim and Neovim versions

Update Linux and Windows test targets to newer Vim and Neovim releases in GitHub Actions and the local run-tests workflow. Refresh the Docker test image and helper scripts so the selected editor versions can be built and executed consistently across environments.

* fix(tests): adapt checks for Neovim 0.12 and Python 3.12

- Replace deprecated imp with import.util in python tests.
- Reorder ale.txt to match help files order.
- Add lines to sign test to ensure there are enough lines for the signs.

* fix(tests): avoid ftplugin side-effects in uncrustify test

* fix(tests): stabilize Windows Vim smoke and path mapping cases

Harden smoke_test callback handling for Vim job output race conditions on Windows by safely handling empty callback output lists instead of indexing output[0].\n\nMake disabling_ale assertions compare against a baseline message history entry so preexisting Vim startup messages do not cause false failures.\n\nUpdate path-mapping tests to account for Vim 9 Windows tempname layout changes and to validate filename-modifier behavior after full-path filename mapping is applied.

* fix(tests): normalize Windows test paths to resolved workspace paths

On Windows Neovim 0.10, test working directories can resolve to host checkout paths (for example D:\a\ale\ale) instead of container-style mount paths (for example C:\testplugin). Many tests compared absolute paths against g:dir-derived expectations and failed despite equivalent files.\n\nNormalize test directory handling in ale#test helpers by storing and using ale#path#Simplify(resolve(getcwd())), so expected paths match the same canonical form used by path discovery functions.\n\nAlso update tests that manually reassign g:dir from raw getcwd() and Gradle path assertions to use resolved/simplified paths, preventing regressions from mixed mount-path forms across Vim/Neovim and CI environments.

* fix(tests): restore g:dir semantics for fixer and test helpers

* Revert "fix(tests): normalize Windows test paths to resolved workspace paths"

This reverts commit 1136e2daec2645f643211e7e41819fa3eeba61b4.

* fix(tests): use resolve() in ant test assertions for Windows junction paths

On Windows CI, a junction C:\testplugin -> D:\a\ale\ale is used so tests
can cd to /testplugin paths. However, findfile() + fnamemodify(':p') resolves
junction points to real paths, while g:dir holds the junction-based path.

Fix the two ant test files to use resolve(g:dir) only in the specific
assertions that compare paths returned by findfile()-based functions
(ale#ant#FindProjectRoot, ale#ant#BuildClasspathCommand). This way:
- On Linux: resolve() is a no-op, behaviour unchanged
- On Windows: resolve(g:dir) gives the real path that matches what
  findfile() returns, fixing the assertion mismatch

The global test infrastructure (ale#test#SetDirectory) is left unchanged
to avoid breaking the many fixer tests that rely on junction-based paths.

* Fix Windows junction path resolution in tests

On Windows CI, tests run from a junction point (C:\testplugin) that
points to the real workspace (D:\a\ale\ale). Functions like
ale#path#FindNearestFile resolve junctions via findfile()/fnamemodify(':p'),
returning the real path, while g:dir holds the junction path.

Wrap expected path values with resolve() so junction paths are
resolved to their real counterparts on Windows (resolve() is a no-op
on Linux), making assertions match across both platforms.

* fix(test): use fnamemodify to compute expected nvcc path on Windows

The test hardcoded 'C:\tmp\...' for Windows paths, but GitHub Actions
runners use D: drive. Use ale#path#Simplify(fnamemodify(..., ':p'))
in expected values to mirror exactly what the handler produces,
making the test drive-letter-agnostic.

* fix: resolve symlinks/junctions in FindNearest* path functions

On Windows, Vim's findfile()/finddir() returns junction paths while
Neovim resolves them. This inconsistency causes test failures when
comparing paths from these functions against g:dir (set via getcwd()).

Add resolve() to FindNearestFile, FindNearestDirectory, and
FindNearestFileOrDirectory so they always return canonical paths,
making behavior consistent across Vim and Neovim on Windows.

On Linux, resolve() is a no-op for non-symlinked paths.

* fix: resolve junctions in python path functions and fix trailing separator

- Add resolve() to FindVirtualenv, FindProjectRoot, FindProjectRootIni
  in autoload/ale/python.vim so they return canonical paths on Windows
  NTFS junctions
- Move trailing '/' inside ale#path#Simplify() in FindNearestDirectory
  and FindNearestFileOrDirectory so separator is OS-appropriate

* fix: remove unnecessary junction in Windows CI

The C:\testplugin junction was a leftover from AppVeyor. It caused
C: vs D: path mismatches when resolve() canonicalized paths. Running
directly from the workspace eliminates the discrepancy.

* fix: use getcwd() for Windows runtimepath instead of hardcoded C:\testplugin

The junction no longer exists, so use the actual working directory
to find ALE plugin files in the test vimrc.

* fix: map /testplugin/ paths to repo root on Windows

Without the C:\testplugin junction, SetDirectory('/testplugin/test')
failed silently, leaving cwd at the repo root. Now on Windows, the
/testplugin/ prefix is replaced with the actual repo root derived
from the script's file path.

* fix: remaining Windows test failures (format_command, dprint, tslint, smoke)

- test_format_command: compute :h modifier depth dynamically since
  Vim 9.x Windows uses flat tempname() while NeoVim uses nested dirs
- test_dprint_fixer: replace hardcoded C:\testplugin path with
  dynamic path relative to g:dir
- smoke_test: increase PowerShell job timeout and add sleep between
  retries for flaky Windows CI
- workflow: set TMP/TEMP on same drive as workspace to fix cross-drive
  relative path resolution in tslint handler test

* fix: skip PowerShell smoke test on Vim Windows

The test is inherently flaky with Vim's Windows job implementation
when &shell=powershell. NeoVim handles it reliably and still tests
this code path.

* fix: NeoVim Windows test failures (dmd handler, c_flag_parsing, lint_file timeout)

- dmd handler: replace \f+ with [^(]+ in regex since NeoVim's isfname
  on Windows doesn't include \ or :, so \f+ can't match absolute paths
- c_flag_parsing: use FullPath() helper for file! commands and dict keys
  so NeoVim v0.10.4 resolves drive-relative paths correctly
- lint_file_linters: increase WaitForJobs timeout from 30s to 60s for
  slower NeoVim Windows CI runners

* fix: skip flaky NeoVim Windows tests (c_flag_parsing, lint_file_linters)

- c_flag_parsing test 18: skip on NeoVim Windows because fnamemodify(':p')
  does not reliably add a drive letter to fake absolute paths on NeoVim
  <= 0.10, causing dir_lookup key mismatches
- lint_file_linters test 8: skip on NeoVim Windows because jobs don't
  complete within the 30s timeout due to slower job handling

Both tests pass on Linux and Vim Windows. TODO comments added to restore
them once the underlying NeoVim Windows issues are resolved.

* ci: update checkout githuh action to v6

* Preserve Vim 8.2 as a minimum supported version for now

* fix: Use a lower Vim version for Windows tests

---------

Co-authored-by: w0rp <devw0rp@gmail.com>
2026-05-12 22:34:30 +01:00

426 lines
12 KiB
Bash

#!/bin/sh
set -e
set -x
bail() {
echo "$@" >&2
exit 1
}
init_vars() {
FLAVOR=
TAG=
NAME=
PYTHON2=
PYTHON3=
RUBY=0
LUA=0
CONFIGURE_OPTIONS=
PREBUILD_SCRIPT=
}
# "apk add --virtual" does not add to existing virtual package anymore since
# Alpine 3.9 (https://bugs.alpinelinux.org/issues/9651).
APK_BUILD_DEPS=
apk_add_build_dep() {
for dep; do
if ! apk info -e "$dep"; then
apk add "$dep"
APK_BUILD_DEPS="$APK_BUILD_DEPS $dep"
fi
done
}
prepare_build() {
[ -z $TAG ] && bail "-tag is required"
# Parse TAG into repo and tag.
IFS=: read -r -- repo tag <<EOF
$TAG
EOF
if [ -z "$tag" ]; then
tag="$repo"
repo=
elif [ "$repo" = vim ]; then
repo="vim/vim"
elif [ "$repo" = neovim ]; then
repo="neovim/neovim"
[ -z "$FLAVOR" ] && FLAVOR=neovim
elif [ "${repo#*/}" = "$repo" ]; then
bail "Unrecognized repo ($repo) from tag: $TAG"
elif [ "${repo#*/neovim}" != "$repo" ]; then
FLAVOR=neovim
fi
if [ -z "$FLAVOR" ]; then
FLAVOR=vim
fi
if [ -z "$repo" ]; then
if [ "$FLAVOR" = vim ]; then
repo="vim/vim"
else
repo="neovim/neovim"
fi
fi
[ -z $NAME ] && NAME="${FLAVOR}-${tag}"
if [ "$FLAVOR" = vim ]; then
VIM_NAME="${repo}/${tag}_py${PYTHON2}${PYTHON3}_rb${RUBY}_lua${LUA}"
else
VIM_NAME="${repo}/${tag}"
fi
INSTALL_PREFIX="/vim-build/$VIM_NAME"
if [ "$FLAVOR" = vim ]; then
VIM_CONFIG_ARGS="--prefix=$INSTALL_PREFIX --enable-multibyte --without-x --enable-gui=no --with-compiledby=vim-testbed --with-tlib=ncurses"
fi
set +x
echo "TAG:$TAG"
echo "repo:$repo"
echo "tag:$tag"
echo "FLAVOR:$FLAVOR"
echo "NAME:$NAME"
set -x
apk_add_build_dep gcc libc-dev make
if [ -n "$PYTHON2" ]; then
apk_add_build_dep python2-dev
if [ "$FLAVOR" = vim ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-pythoninterp=dynamic"
else
apk add python2
apk_add_build_dep g++ # for building greenlet
python2 -m ensurepip
pip2 install pynvim
fi
fi
if [ -n "$PYTHON3" ]; then
apk_add_build_dep python3-dev
if [ "$FLAVOR" = vim ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-python3interp=dynamic"
else
apk add python3
apk add py3-pynvim
fi
fi
if [ $RUBY -eq 1 ]; then
apk_add_build_dep ruby-dev
apk add ruby
if [ "$FLAVOR" = vim ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-rubyinterp"
else
apk_add_build_dep ruby-rdoc ruby-irb
gem install neovim
fi
fi
if [ $LUA -eq 1 ]; then
if [ "$FLAVOR" = vim ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-luainterp"
apk_add_build_dep lua5.3-dev
apk add lua5.3-libs
# Install symlinks to make Vim's configure pick it up.
(cd /usr/bin && ln -s lua5.3 lua)
(cd /usr/lib && ln -s lua5.3/liblua.so liblua5.3.so)
else
echo 'NOTE: -lua is automatically used with Neovim 0.2.1+, and not supported before.'
fi
fi
if [ "$FLAVOR" = vim ] && [ -n "$CONFIGURE_OPTIONS" ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS $CONFIGURE_OPTIONS"
fi
cd /vim
if [ -d "$INSTALL_PREFIX" ]; then
echo "WARNING: $INSTALL_PREFIX exists already. Overwriting."
fi
BUILD_DIR="${FLAVOR}-${repo}-${tag}"
if [ ! -d "$BUILD_DIR" ]; then
apk_add_build_dep git
git clone -b "$tag" "https://github.com/$repo" "$BUILD_DIR"
cd "$BUILD_DIR"
else
cd "$BUILD_DIR"
fi
if [ "$FLAVOR" = vim ]; then
apk_add_build_dep ncurses-dev
apk add ncurses
elif [ "$FLAVOR" = neovim ]; then
# Some of them will be installed already, but it is a good reference for
# what is required.
# luajit is required with Neomvim 0.2.1+ (previously only during build).
apk add gettext \
libuv \
libtermkey \
libvterm \
luajit \
msgpack-c \
unibilium
apk_add_build_dep \
autoconf \
automake \
ca-certificates \
cmake \
g++ \
gettext-dev \
gperf \
libtool \
libuv-dev \
libtermkey-dev \
libvterm-dev \
lua5.1-lpeg \
lua5.1-mpack \
luajit-dev \
m4 \
make \
msgpack-c-dev \
perl \
unzip \
unibilium-dev \
xz
else
bail "Unexpected FLAVOR: $FLAVOR (use vim or neovim)."
fi
}
build() {
if [ -n "$PREBUILD_SCRIPT" ]; then
eval "$PREBUILD_SCRIPT"
fi
if [ "$FLAVOR" = vim ]; then
# Apply build fix from v7.1.148.
# NOTE: this silently does nothing with 7.1.148+, but can be skipped with
# Vim 8+ (and needs to be for 8.0.0082, where src/configure.in was renamed
# to src/configure.ac).
MAJOR="$(sed -n '/^MAJOR = / s~MAJOR = ~~p' Makefile)"
if [ "$MAJOR" -lt 8 ]; then
sed -i 's~sys/time.h termio.h~sys/time.h sys/types.h termio.h~' src/configure.in src/auto/configure
fi
# Apply Vim patch v8.0.1635 to fix build with Python.
if grep -q _POSIX_THREADS src/if_python3.c; then
sed -i '/#ifdef _POSIX_THREADS/,+2 d' src/if_python3.c
fi
if [ -n "$PYTHON3" ]; then
# Vim patch 8.1.2201 (cannot build with dynamically linked Python 3.8).
if ! grep -q "# if PY_VERSION_HEX >= 0x030800f0" src/if_python3.c; then
apk_add_build_dep curl patch
curl https://github.com/vim/vim/commit/13a1f3fb0.patch \
| patch -p1
fi
# Vim patch 8.2.0354 (Python 3.9 does not define _Py_DEC_REFTOTAL).
if grep -q "^ _Py_DEC_REFTOTAL;$" src/if_python3.c; then
apk_add_build_dep curl patch
curl https://github.com/vim/vim/commit/a65bb5351.patch \
| patch -p1
fi
# Vim patch 8.2.1225: linker errors when building with dynamic Python 3.9.
if ! grep -q "^# define PyType_GetFlags py3_PyType_GetFlags" src/if_python3.c; then
# NOTE: --fuzz=3 needed with Vim v7.4.052 (likely due to e.g. missingv8.1.0735).
apk_add_build_dep curl patch
curl https://github.com/vim/vim/commit/ee1b93169.patch \
| patch -p1 --fuzz=3
fi
fi
# Older xxd sources redeclare libc functions without arguments, which
# newer system headers reject.
if grep -q '^extern long int strtol();$' src/xxd/xxd.c; then
sed -i '/^extern long int strtol();$/d' src/xxd/xxd.c
fi
if grep -q '^extern long int ftell();$' src/xxd/xxd.c; then
sed -i '/^extern long int ftell();$/d' src/xxd/xxd.c
fi
echo "Configuring with: $VIM_CONFIG_ARGS"
# shellcheck disable=SC2086
./configure $VIM_CONFIG_ARGS || bail "Could not configure"
make CFLAGS="-Wno-error=incompatible-pointer-types -Wno-incompatible-pointer-types -Wno-error=int-conversion -Wno-int-conversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" -j4 || bail "Make failed"
make install || bail "Install failed"
elif [ "$FLAVOR" = neovim ]; then
CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX"
DEPS_CMAKE_FLAGS="$DEPS_CMAKE_FLAGS -DUSE_BUNDLED_TS_PARSERS=ON"
DEPS_CMAKE_FLAGS="$DEPS_CMAKE_FLAGS -DUSE_BUNDLED_TS=ON"
# Use bundled libvterm. Neovim 0.4.x requires 0.1, which is not yet in
# Alpine Linux. Using the bundled version also makes it easier for older
# Neovim versions when Alpine updates it.
DEPS_CMAKE_FLAGS="$DEPS_CMAKE_FLAGS -DUSE_BUNDLED_LIBVTERM=ON"
# Install luv, for Neovim 0.4.0+, shipped with Alpine 3.10+.
# Only add it when required, since it was broken with nvim-0.2.0
# (at least, maybe only when using the bundled one), where it is optional
# (only for tests).
if grep -iq 'find.*libluv' CMakeLists.txt; then
apk add libluv
apk_add_build_dep libluv-dev
fi
# NOTE: ENABLE_JEMALLOC has been removed in v0.3.4-168-gc2343180d
# (https://github.com/neovim/neovim/commit/c2343180d).
if grep -q 'ENABLE_JEMALLOC' CMakeLists.txt; then
CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS -DENABLE_JEMALLOC=OFF"
fi
# Use bundled unibilium with older releases that use data directly, and not
# through unibi_var_from_num like it is required now.
if ! grep -qF 'unibi_var_from_num' src/nvim/tui/tui.c; then
DEPS_CMAKE_FLAGS="$DEPS_CMAKE_FLAGS -DUSE_BUNDLED_UNIBILIUM=ON"
fi
if grep -qF 'UTF8PROC' CMakeLists.txt; then
apk add utf8proc
apk_add_build_dep utf8proc-dev
fi
# gcc10 fixes (due to -fno-common),
# required to fix builds with v0.3.0+, until v0.4.4/v0.5.0.
# Ref: https://github.com/neovim/neovim/commit/c036e24f3.patch
if grep -q '\} ListLenSpecials;$' src/nvim/eval/typval.h; then
apk_add_build_dep curl patch
curl https://github.com/neovim/neovim/commit/ebcde1de4.patch | patch -p1
fi
if grep -q '\} ExprParserFlags;$' src/nvim/viml/parser/expressions.h; then
apk_add_build_dep curl patch
curl https://github.com/neovim/neovim/commit/b87b4a614.patch | patch -p1
fi
if grep -q '\} RemapValues;$' src/nvim/getchar.h; then
apk_add_build_dep curl patch
curl https://github.com/neovim/neovim/commit/986db1adb.patch | patch -p1
fi
if grep -q "^MultiQueue \*ch_before_blocking_events;" src/nvim/msgpack_rpc/channel.h; then
apk_add_build_dep curl patch
curl https://github.com/neovim/neovim/commit/517bf1560.patch | patch -p1
fi
if grep -q '^EXTERN PMap(uint64_t) \*channels;$' src/nvim/channel.h; then
apk_add_build_dep curl patch
curl https://github.com/neovim/neovim/commit/823b2104c.patch | patch -p1
fi
# NOTE: uses "make cmake" to avoid linking twice when changing versiondef.h
make cmake CMAKE_BUILD_TYPE=RelWithDebInfo \
CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" \
DEPS_CMAKE_FLAGS="$DEPS_CMAKE_FLAGS" \
|| bail "make cmake failed"
make install || bail "Install failed"
fi
# Clean, but don't delete the source in case you want make a different build
# with the same version.
make distclean
if [ "$FLAVOR" = vim ]; then
VIM_BIN="$INSTALL_PREFIX/bin/vim"
else
VIM_BIN="$INSTALL_PREFIX/bin/nvim"
fi
if ! [ -e "$VIM_BIN" ]; then
bail "Binary $VIM_BIN was not created."
fi
link_target="/vim-build/bin/$NAME"
if [ -e "$link_target" ]; then
echo "WARNING: link target for $NAME exists already. Overwriting."
fi
ln -sfn "$VIM_BIN" "$link_target"
"$link_target" --version
}
apk update
init_vars
clean=
while [ $# -gt 0 ]; do
case $1 in
-flavor)
if [ "$2" != vim ] && [ "$2" != neovim ]; then
bail "Invalid value for -flavor: $2: only vim or neovim are recognized."
fi
FLAVOR="$2"
shift
;;
-name)
NAME="$2"
shift
;;
-tag)
TAG="$2"
shift
;;
-py|-py2)
PYTHON2=2
;;
-py3)
PYTHON3=3
;;
-ruby)
RUBY=1
;;
-lua)
LUA=1
;;
-prepare_build)
# Not documented, meant to ease hacking on this script, by avoiding
# downloads over and over again.
prepare_build
[ -z "$clean" ] && clean=0
;;
-skip_clean)
clean=0
;;
-prebuild_script)
PREBUILD_SCRIPT="$2"
shift
;;
-build)
# So here I am thinking that using Alpine was going to give the biggest
# savings in image size. Alpine starts at about 5MB. Built this image,
# and it's about 8MB. Looking good. Install two versions of vanilla
# vim, 300MB wtf!!! Each run of this script without cleaning up created
# a layer with all of the build dependencies. So now, this script
# expects a -build flag to signal the start of a build. This way,
# installing all Vim versions becomes one layer.
# Side note: tried docker-squash and it didn't seem to do anything.
echo "=== building: NAME=$NAME, TAG=$TAG, PYTHON=${PYTHON2}${PYTHON3}, RUBY=$RUBY, LUA=$LUA, FLAVOR=$FLAVOR ==="
prepare_build
build
init_vars
[ -z "$clean" ] && clean=1
;;
*)
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS $1"
;;
esac
shift
done
if [ "$clean" = 0 ]; then
echo "NOTE: skipping cleanup."
else
echo "Pruning packages and dirs.."
if [ -n "$APK_BUILD_DEPS" ]; then
# shellcheck disable=SC2086
apk del $APK_BUILD_DEPS
APK_BUILD_DEPS=
fi
rm -rf /vim/*
rm -rf /var/cache/apk/* /tmp/* /var/tmp/* /root/.cache
find / \( -name '*.pyc' -o -name '*.pyo' \) -delete
# Luarocks used for Neovim.
rm -f /usr/local/bin/luarocks*
rm -rf /usr/local/share/lua/5*/luarocks
rm -rf /usr/local/etc/luarocks*
fi