diff options
Diffstat (limited to 'src/tools/mkvsix.sh')
| -rwxr-xr-x | src/tools/mkvsix.sh | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/tools/mkvsix.sh b/src/tools/mkvsix.sh index 39fb9c4..df9e703 100755 --- a/src/tools/mkvsix.sh +++ b/src/tools/mkvsix.sh @@ -1,9 +1,13 @@ #!/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 +# javascript vm (built from src/js/tinyvm.ts) and the server's image +# (build/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. +# +# everything generated lands in build/. the packaged files are staged into +# editors/vscode/server/ only for as long as vsce is packing, then removed, so a +# fresh clone has no extension until it is built. # src/tools/mkvsix.sh [outfile.vsix] set -e case "${1:-}" in @@ -14,20 +18,32 @@ cd "$(dirname "$0")/../.." OUT=${1:-$PWD/build/zc-language-support.vsix} case "$OUT" in /*) ;; *) OUT="$PWD/$OUT" ;; esac mkdir -p "$(dirname "$OUT")" +JS=build/js +STAGE=build/editors/vscode/server +PACKDIR=editors/vscode/server + 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 +tsc src/js/tinyvm.ts --target es2020 --lib es2020,dom --module commonjs --outDir "$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 +mkdir -p "$STAGE" +cp "$JS/tinyvm.js" "$JS/layout.js" "$JS/lsp.json" "$STAGE/" +# the wasm server runs when there is one; 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 + LSP_BUILD_DIR=build/lsp LSP_REUSE_BUILD=1 bash src/tools/mklspwasm.sh "$STAGE/lsp.wasm" else - rm -f editors/vscode/server/lsp.wasm + rm -f "$STAGE/lsp.wasm" echo "no clang with wasm32: packing the javascript vm server only" >&2 fi + +# vsce packs the extension directory, so the server has to sit inside it while +# it runs. stage it, package, and leave the tree as it was. +cleanup() { rm -rf "$PACKDIR"; } +trap cleanup EXIT INT TERM +rm -rf "$PACKDIR" +mkdir -p "$PACKDIR" +cp "$STAGE"/* "$PACKDIR"/ cd editors/vscode if [ -n "${VSCE:-}" ]; then "$VSCE" package --allow-missing-repository --skip-license -o "$OUT" >/dev/null @@ -36,4 +52,4 @@ elif command -v vsce >/dev/null; then else npx -y @vscode/vsce package --allow-missing-repository --skip-license -o "$OUT" >/dev/null fi -echo "$OUT" +echo "$OUT"
\ No newline at end of file |
