-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.sh
executable file
·221 lines (180 loc) · 5.85 KB
/
bootstrap.sh
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
. "$(dirname $0)/include.sh"
NOTICES=()
OS="$(get_os)"
function compile_check() {
if ! qwhich "$1"; then
notify "Warning: Could not find \"$1\" in your path, skipped compilation"
BUILD=
fi
}
function notify() {
local text="$1"
NOTICES+=("$1")
}
if [[ "$OS" == Windows ]]; then
BIN_TPL=tpl/bin/windows
elif [[ "$OS" == macOS ]]; then
BIN_TPL=tpl/bin/mac
else
if grep "^Ubuntu" < /etc/issue > /dev/null 2>&1; then
OS_VARIANT=Ubuntu
BIN_TPL=tpl/bin/ubuntu
else
BIN_TPL=tpl/bin/linux
fi
fi
BUILD=y
compile_check which
compile_check cmake
compile_check make
compile_check node
compile_check pnpm
if [[ $OS == Windows ]]; then
compile_check ninja
if ! uname_grep 'MINGW64_NT'; then
# Symptom of building in Git Bash is that Emacs will crash when trying to use magit
notify "Warning: Cannot compile binaries unless you are in an MSYS2 MinGW 64-bit terminal, skipped compilation"
BUILD=
fi
fi
REQUIRED_EMACS_VERSION=29.4
# Set this environment variable to rebuild git-for-windows manpages; otherwise use pre-built ones
: ${BUILD_GIT_MANPAGES:=}
if [[ $OS == Windows ]]; then
if ! qwhich emacs-${REQUIRED_EMACS_VERSION}; then
PATH="/c/Program Files/Emacs/emacs-${REQUIRED_EMACS_VERSION}/bin":"$PATH"
if ! qwhich emacs-${REQUIRED_EMACS_VERSION}; then
echo >&2 "Error: Could not find \"emacs-${REQUIRED_EMACS_VERSION}\" in your path"
exit 1
fi
fi
elif [[ $OS == macOS ]]; then
if [[ ! -e /Applications/Emacs.app ]]; then
echo >&2 "Error: Emacs does not seem to be installed in Applications"
exit 1
fi
if [[ ! -e /opt/homebrew/opt/emacs-plus@29/Emacs.app/Contents/MacOS/Emacs ]]; then
echo >&2 "Error: Could not find Emacs Homebrew installation"
exit 1
fi
elif [[ $OS_VARIANT == Ubuntu ]]; then
if [[ ! -x /usr/local/bin/emacs ]]; then
echo >&2 "Error: /usr/local/bin/emacs does not exist"
exit 1
fi
elif ! qwhich emacs; then
echo >&2 "Error: Could not find \"emacs\" in your path"
exit 1
fi
# Create bin directory
rm -fr bin
mkdir bin
cp tpl/bin/shared/* bin
cp "$BIN_TPL"/* bin
DESTDIR=$PWD
PATH="$PWD"/bin:"$PATH"
# Make sure we're using the recommended version of Emacs
EMACS_VERSION=$(emacs --batch -q --no-site-file --eval "(message \"%s\" emacs-version)" 2>&1)
if [[ z$EMACS_VERSION != z${REQUIRED_EMACS_VERSION}* ]]; then
echo >&2 "Error: Your version of Emacs is \"$EMACS_VERSION\", but should be \"${REQUIRED_EMACS_VERSION}.x\""
exit 1
fi
if ! qwhich make; then
notify "Warning: Could not find \"make\" in your path, skipped compilation"
fi
if [[ $OS == Windows ]]; then
if ! qwhich ninja; then
notify "Warning: Could not find \"ninja\" in your path, skipped compilation"
fi
fi
set -e
echo "OS : $OS"
echo "BUILD : $BUILD"
echo "BUILD_GIT_MANPAGES : $BUILD_GIT_MANPAGES"
echo "DESTDIR : $DESTDIR"
echo
git submodule init
git submodule sync
git submodule update --depth 1
echo
if [[ -n "$BUILD" ]]; then
pnpm install --quiet
pnpm run compile:json-server
fi
emacs --script "$(get_topdir)"/install-packages.el 2>&1 | grep -v '^Loading '
set_treesit_dir
qpushd share/man
git submodule init
git submodule update --depth 1
qpopd
if [[ -n "$BUILD_GIT_MANPAGES" ]]; then
qpushd extra/git
git submodule init
git submodule update --depth 1
# check this for most up-to-date path:
# https://packages.msys2.org/package/docbook-xsl?repo=msys&variant=x86_64
xmlcatalog --noout \
--add rewriteURI \
http://docbook.sourceforge.net/release/xsl/current \
/ucrt64/share/xml/docbook/xsl-stylesheets-1.79.2 \
/etc/xml/catalog
# check this for most up-to-date path:
# https://packages.msys2.org/package/docbook-xml?repo=msys&variant=x86_64
xmlcatalog --noout \
--add rewriteURI \
http://www.oasis-open.org/docbook/xml/4.5/xsl/current \
/ucrt64/share/xml/docbook/xml-dtd-4.5 \
/etc/xml/catalog
xmlcatalog --noout \
--add rewriteURI \
http://www.oasis-open.org/docbook/xml/4.5 \
/ucrt64/share/xml/docbook/xml-dtd-4.5 \
/etc/xml/catalog
# see also end of INSTALL doc at https://github.com/git-for-windows/git/blob/main/INSTALL#L229
make prefix=$DESTDIR install-man
notify "Built manpages, make sure to check them in"
qpopd
fi
dir_elisp_submodules="aidermacs archive-rpm gptel ligature polymode"
for mod in $dir_elisp_submodules; do
update_submodule elisp/"$mod"
byte_compile "$mod" elisp/"$mod"
done
file_elisp_submodules="
asdf-vm clojure-ts-mode erlang-ts gptel-fn-complete jtsx kotlin-ts-mode
mermaid-ts-mode minuet poly-markdown prisma-ts-mode swift-ts-mode tmux-mode
vterm zig-ts-mode
"
for mod in $file_elisp_submodules; do
update_submodule elisp/"$mod"
byte_compile "$mod" elisp/"$mod"/"$mod".el
done
update_submodule extra/emacs
if [[ -n "$BUILD" ]]; then
qpushd elisp/vterm
rm -fr build
mkdir -p build
cd build
cmake ..
make
qpopd
"$(get_topdir)"/install-treesit-grammar.sh \
markdown_inline markdown "tree-sitter-markdown-inline/src"
"$(get_topdir)"/install-treesit-grammar.sh \
tsx typescript "tsx/src"
"$(get_topdir)"/install-treesit-grammar.sh \
typescript "" "typescript/src"
tree_sitter_modules="
bash c c-sharp clojure cpp dockerfile erlang go gomod java javascript
jsdoc json kotlin mermaid nix prisma python rust yaml zig
"
<<< $tree_sitter_modules xargs -P4 -n1 "$(get_topdir)"/install-treesit-grammar.sh
"$(get_topdir)"/install-treesit-grammar.sh swift "" "" pnpm
else
notify "Warning: tree-sitter modules will not be built, some major modes will not work"
fi
for idx in ${!NOTICES[@]}; do
echo -e >&2 "\n${NOTICES[$idx]}"
done
echo -e >&2 "\nBootstrap complete! Your Emacs is ready for use."