-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·49 lines (39 loc) · 1.29 KB
/
install.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.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
#!/usr/bin/env bash
# Add -x for debug
set -e
# The root of the project.
PRJ_ROOT="${PRJ_ROOT:-$(git rev-parse --show-toplevel)}"
# Whether to build a debug or release version of the project.
PROFILE="${1:-release}"
if [ $PROFILE != "debug" ] && [ $PROFILE != "release" ]; then
echo "Invalid profile \"$PROFILE\": profile should either be \"debug\" or \"release\""
exit 1
fi
case "$OSTYPE" in
linux*|bsd*|solaris*) OS="linux" ;;
msys*|cygwin*) OS="windows" ;;
darwin*) OS="macos" ;;
*) echo "Unknown OS type \"$OSTYPE\"" && exit 1 ;;
esac
cargo_build() {
if ! command -v cargo &>/dev/null; then
echo "Couldn't find cargo in \$PATH, make sure the Rust toolchain is installed"
return 1
fi
profile=$([ $PROFILE == debug ] && echo "" || echo --release)
cargo build $profile &>/dev/null
return 0
}
symlink_dll() {
case "$OS" in
linux) dll_prefix="lib" && dll_suffix="so" && target_suffix="so" ;;
macos) dll_prefix="lib" && dll_suffix="dylib" && target_suffix="so" ;;
windows) dll_prefix="" && dll_suffix="dll" && target_suffix="dll" ;;
esac
mkdir -p "$PRJ_ROOT/lua"
# Link the dll where Neovim can find it.
ln -sf \
"$PRJ_ROOT/target/$PROFILE/${dll_prefix}nvim_chaos.${dll_suffix}" \
"$PRJ_ROOT/lua/nvim_chaos.${target_suffix}"
}
cargo_build && symlink_dll