-
Notifications
You must be signed in to change notification settings - Fork 0
/
s_base_swift
executable file
·72 lines (58 loc) · 2.32 KB
/
s_base_swift
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
#!/usr/bin/env bash
#
# Bin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Bin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Bin. If not, see <https://www.gnu.org/licenses/>.
#
# DEBUG OPTIONS
set -euo pipefail
DEPS=(bash wget git tar mv ln)
s_checkdeps "${DEPS[@]}"
LOCAL_DIR="$HOME/.local"
BUILDS_DIR="$HOME/Builds"
mkdir -pv "$BUILDS_DIR"
echo " --- Swift"
SWIFT_VERSION=swift-5.10.1
UBUNTU_VERSION=ubuntu24.04
SWIFT_URL="https://download.swift.org/$SWIFT_VERSION-release/ubuntu2204/$SWIFT_VERSION-release-RELEASE/$SWIFT_VERSION-RELEASE-$UBUNTU_VERSION.tar.gz"
if [[ ! -d "$LOCAL_DIR/swift" ]]; then
wget -c "$SWIFT_URL" -P /tmp
tar -xvzf /tmp/swift-*-RELEASE-ubuntu*.tar.gz -C "$LOCAL_DIR"
mv "$LOCAL_DIR"/swift-*-RELEASE-* "$LOCAL_DIR/swift"
fi
if [[ ! -f "$LOCAL_DIR/bin/swift" ]]; then
ln -sf "$LOCAL_DIR/swift/usr/bin/swift*" "$LOCAL_DIR/bin"
ln -sf "$LOCAL_DIR/swift/usr/bin/sourcekit-lsp" "$LOCAL_DIR/bin/sourcekit-lsp"
ln -sf "$LOCAL_DIR/swift/usr/bin/docc" "$LOCAL_DIR/bin/docc"
"$LOCAL_DIR/bin/swift" --version
"$LOCAL_DIR/bin/sourcekit-lsp" --help
"$LOCAL_DIR/bin/docc" --help
fi
echo " --- Swift Format"
SWIFT_FORMAT_DIR="$HOME/Builds/swift-format"
SWIFT_FORMAT_VERSION=510.1.0
[[ ! -d $SWIFT_FORMAT_DIR/.git ]] && git clone https://github.com/apple/swift-format "$SWIFT_FORMAT_DIR"
git -C "$SWIFT_FORMAT_DIR" pull
cd "$SWIFT_FORMAT_DIR"
git checkout "$SWIFT_FORMAT_VERSION"
swift build -c release
ln -sf "$SWIFT_FORMAT_DIR/.build/release/swift-format" "$LOCAL_DIR/bin"
echo " --- sourcekit-lsp"
SOURCEKIT_DIR=$BUILDS/sourcekit-lsp
[[ -d $SOURCEKIT_DIR ]] && git clone https://github.com/apple/sourcekit-lsp
exit
VAPOR_VERSION=18.7.1 # https://github.com/vapor/toolbox/releases
VAPOR_DIR=$BUILDS/vapor
[[ ! -d $VAPOR_DIR/.git ]] && git clone https://github.com/vapor/toolbox.git "$VAPOR_DIR"
cd "$VAPOR_DIR"
gitf checkout "$VAPOR_VERSION"
make install