diff options
| author | 2026-10-14 07:28:39 +0000 | |
|---|---|---|
| committer | 2026-10-14 07:28:39 +0000 | |
| commit | 7451eb090d890fb5ea5e4d40627a1b4df15a49de (patch) | |
| tree | 357bdf4b528e860bffa688865306f656b788d2c2 /src/tools/mkvsix.sh | |
| parent | analyzer: close the ownership gaps that stopped the compiler compiling itself (diff) | |
build: embed images with #embed, keep everything generated in build/
the cores take their genome in with c23 #embed through src/core/genome.h,
so images are plain little-endian word files (genome.bin) instead of
generated c headers. zc0 writes that format, mkgenome checks an image
against its map and shows a compiler's diagnostics when it gets them,
and the javascript vm and the editor's vm host read the same files.
src/tools/findcc.sh picks a compiler with #embed (clang 19 or gcc 15).
zc gets an embed declaration, embed "file" as [type] name, for globals
and locals: a byte string by default, char*, numbers read little-endian,
and arrays of numbers. the compiler and language server carry their
library and source texts through it, so embed.sh and the text it
spliced into compiler.zc are gone.
make writes executables to build/bin, the default map to build/core/map,
the web page to build/web and the extension staging to build/vsix, and
the genome now rebuilds when its sources change. the test suite lays
out its own map and bootstrap and reads nothing from build/.
also: rt.put_s of a byte string in zc0 images, retained function
sources no longer count as live objects, a missing include no longer
cascades into undefined-name errors, consecutive comment lines join
into one hover paragraph, and stale test fixtures follow the include
format.
Diffstat (limited to 'src/tools/mkvsix.sh')
| -rwxr-xr-x | src/tools/mkvsix.sh | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/tools/mkvsix.sh b/src/tools/mkvsix.sh index df9e703..61fe9a8 100755 --- a/src/tools/mkvsix.sh +++ b/src/tools/mkvsix.sh @@ -1,13 +1,12 @@ #!/bin/bash # builds the vs code extension, with the language server inside it: the tinyvm # 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 +# (build/js/lsp.bin and its map in lsp.json, from build/lsp), 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. +# everything generated lands in build/: the server files in +# build/editors/vscode/server, the packing copy of the extension in build/vsix. # src/tools/mkvsix.sh [outfile.vsix] set -e case "${1:-}" in @@ -20,31 +19,33 @@ 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; } +make --no-print-directory build/js/layout.js >/dev/null tsc src/js/tinyvm.ts --target es2020 --lib es2020,dom --module commonjs --outDir "$JS" node src/js/extract_lsp.js mkdir -p "$STAGE" -cp "$JS/tinyvm.js" "$JS/layout.js" "$JS/lsp.json" "$STAGE/" +cp "$JS/tinyvm.js" "$JS/layout.js" "$JS/lsp.json" "$JS/lsp.bin" "$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 +if sh src/tools/findcc.sh --wasm >/dev/null 2>&1; then LSP_BUILD_DIR=build/lsp LSP_REUSE_BUILD=1 bash src/tools/mklspwasm.sh "$STAGE/lsp.wasm" else rm -f "$STAGE/lsp.wasm" - echo "no clang with wasm32: packing the javascript vm server only" >&2 + echo "no clang with wasm32 and #embed: 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 +# vsce packs a whole extension directory, so the extension is copied into +# build/vsix/extension with the server beside its client, and packed there. the +# tree is never written to. +PACKROOT=build/vsix/extension +rm -rf "$PACKROOT" +mkdir -p "$PACKROOT" +cp -R editors/vscode/. "$PACKROOT/" +mkdir -p "$PACKROOT/server" +cp "$STAGE"/* "$PACKROOT/server/" +cd "$PACKROOT" if [ -n "${VSCE:-}" ]; then "$VSCE" package --allow-missing-repository --skip-license -o "$OUT" >/dev/null elif command -v vsce >/dev/null; then @@ -52,4 +53,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"
\ No newline at end of file +echo "$OUT" |
