aboutsummaryrefslogtreecommitdiff
path: root/src/tools/mkvsix.sh
blob: 5ca8ef5ba9b661ee064f12db3033d1ee7810c665 (plain) (blame)
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
#!/bin/bash
# builds the vs code extension, with the language server inside it: the tinyvm
# javascript vm (src/js/tinyvm.js, compiled from src/js/tinyvm.ts) and the server's image
# (src/js/lsp.json, from build/lsp/genome.h and its map), and the wasm server
# (src/tools/mklspwasm.sh) when clang can build it. needs node and tsc; the
# server build (src/tools/mklsp.sh) runs first if build/lsp is missing.
#   src/tools/mkvsix.sh [outfile.vsix]
set -e
cd "$(dirname "$0")/../.."
OUT=${1:-$PWD/build/zc-language-support.vsix}
case "$OUT" in /*) ;; *) OUT="$PWD/$OUT" ;; esac
mkdir -p "$(dirname "$OUT")"
bash src/tools/mklsp.sh build/lsp >/dev/null
# typescript errors stop packaging, so broken generated code is never shipped.
command -v tsc >/dev/null || { echo "mkvsix: tsc is not installed" >&2; exit 1; }
tsc src/js/tinyvm.ts --target es2020 --lib es2020,dom --module commonjs --outDir src/js
node src/js/extract_lsp.js
mkdir -p editors/vscode/server
cp src/js/tinyvm.js src/js/layout.js src/js/lsp.json editors/vscode/server/
# the wasm server runs when it is there; without clang the vm server is packed alone
if command -v clang >/dev/null && clang --print-targets | grep -q wasm32; then
    LSP_BUILD_DIR=build/lsp LSP_REUSE_BUILD=1 bash src/tools/mklspwasm.sh editors/vscode/server/lsp.wasm
else
    rm -f editors/vscode/server/lsp.wasm
    echo "no clang with wasm32: packing the javascript vm server only" >&2
fi
cd editors/vscode
if [ -n "${VSCE:-}" ]; then
    "$VSCE" package --allow-missing-repository --skip-license -o "$OUT" >/dev/null
elif command -v vsce >/dev/null; then
    vsce package --allow-missing-repository --skip-license -o "$OUT" >/dev/null
else
    npx -y @vscode/vsce package --allow-missing-repository --skip-license -o "$OUT" >/dev/null
fi
echo "$OUT"