-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall
More file actions
executable file
·91 lines (77 loc) · 2.29 KB
/
Copy pathinstall
File metadata and controls
executable file
·91 lines (77 loc) · 2.29 KB
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
#!/usr/bin/env bash
set -euo pipefail
# Calculate plugin_dir for utils.bash source reference
if [ -z "${ASDF_PLUGIN_PATH:-}" ]; then
current_script_path="${BASH_SOURCE[0]}"
plugin_dir="$(dirname "$(dirname "$current_script_path")")"
plugin_dir="$(cd "$plugin_dir" && pwd)"
else
plugin_dir="${ASDF_PLUGIN_PATH}"
fi
if ! source "${plugin_dir}/lib/utils.bash"; then
printf "[asdf-vim] ERROR: Failed to source lib/utils.bash from %s\n" "${plugin_dir}" >&2
exit 1
fi
install_vim() {
local install_version
local install_path
local concurrency
local download_path
install_version=$1
install_path=$2
concurrency=$(get_valid_concurrency "$3")
download_path=$4
# If install_version contains 'latest', try to resolve it
if [[ "${install_version}" == *latest* ]]; then
if [[ -x "${plugin_dir}/bin/latest-stable" ]]; then
local resolved
resolved="$("${plugin_dir}/bin/latest-stable" 2>/dev/null)" || {
printf '[asdf-vim] ERROR: failed to resolve latest in install\n' >&2
return 1
}
printf '[asdf-vim] Resolved install version latest -> %s\n' "$resolved" >&2
install_version="$resolved"
fi
fi
echo "Install Vim version:${install_version}, path:${install_path}, build concurrency:${concurrency}"
local default_config="\
--with-tlib=ncurses \
--with-compiledby=asdf \
--enable-multibyte \
--enable-cscope \
--enable-terminal \
--enable-perlinterp \
--enable-rubyinterp \
--enable-python3interp \
--enable-luainterp \
--enable-gui=no \
--without-x"
local vim_type="${ASDF_VIM_TYPE:-huge}"
local config="${ASDF_VIM_CONFIG:-${default_config}}"
# running this in subshell
# we don't want to disturb current working dir
(
cd "${download_path}/vim-${install_version}" || exit 1
local configure_option="--prefix=${install_path} --with-features=${vim_type} ${config}"
# shellcheck disable=SC2086
echo 'configure option: ' $configure_option || exit 1
# shellcheck disable=SC2086
./configure $configure_option || exit 1
make -j "${concurrency}" || exit 1
make install || exit 1
)
return
}
get_valid_concurrency() {
local concurrency
concurrency=$1
if [[ "${concurrency}" =~ ^[0-9]+$ ]]; then
# number
echo "${concurrency}"
else
# is not number
echo "1"
fi
return
}
install_vim "${ASDF_INSTALL_VERSION}" "${ASDF_INSTALL_PATH}" "${ASDF_CONCURRENCY:-1}" "${ASDF_DOWNLOAD_PATH}"