From 5d54b797d4fc65bb1e8e68a8936495ad2f93d4a0 Mon Sep 17 00:00:00 2001 From: cs01 Date: Wed, 25 Feb 2026 21:03:55 -0800 Subject: [PATCH 01/16] update hn and cli docs --- docs/getting-started/cli.md | 18 ++++++++++++++++++ examples/hackernews/app.ts | 4 ++-- examples/hackernews/public/index.html | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/getting-started/cli.md b/docs/getting-started/cli.md index c3077a16..1cad4b52 100644 --- a/docs/getting-started/cli.md +++ b/docs/getting-started/cli.md @@ -126,6 +126,24 @@ When you pass `--target`, the compiler: |--------|--------|-------| | `linux-x64` | `x86_64-unknown-linux-gnu` | Static glibc binary | +### Adding extra libraries + +The target SDK includes libgc, libuv, and yyjson, but not system libs like libsqlite3, libz, or libzstd. If your app links against these, you need to provide linux-x64 static builds and drop them into the SDK vendor directory at `~/.chadscript/targets/linux-x64/vendor/`. + +A convenient way to get them is to run a throwaway Linux container on any linux-x64 machine (e.g., your deploy server) and copy the static libs out: + +```bash +podman run --rm -v /tmp/libs:/output:z ubuntu:22.04 bash -c " + apt-get update -qq && + apt-get install -y -qq zlib1g-dev libzstd-dev libsqlite3-dev && + cp /usr/lib/x86_64-linux-gnu/libz.a /output/ && + cp /usr/lib/x86_64-linux-gnu/libzstd.a /output/ && + cp /usr/lib/x86_64-linux-gnu/libsqlite3.a /output/" +rsync -a user@yourserver:/tmp/libs/ ~/.chadscript/targets/linux-x64/vendor/ +``` + +Docker works the same way — just swap `podman` for `docker` and drop the `:z` volume flag. + ### Limitations - **macOS to Linux** is the primary cross-compilation path (e.g., develop on Mac, deploy to Linux) diff --git a/examples/hackernews/app.ts b/examples/hackernews/app.ts index 40dc5b88..1dcdd06a 100644 --- a/examples/hackernews/app.ts +++ b/examples/hackernews/app.ts @@ -108,7 +108,7 @@ function renderPosts(): string { const post = posts[i]; const rank = i + 1; html = html + '
' + rank + "."; - html = html + '
'; + html = html + ''; html = html + '
'; html = html + '' + post.title + "
"; @@ -131,7 +131,7 @@ function handleRequest(req: HttpRequest): HttpResponse { const idStr = req.path.substring(8, req.path.length); sqlite.exec(db, "UPDATE posts SET points = points + 1 WHERE id = ?", [idStr]); const redirectHtml = - 'Redirecting...'; + 'Redirecting...'; return { status: 200, body: redirectHtml }; } diff --git a/examples/hackernews/public/index.html b/examples/hackernews/public/index.html index 1656aad3..a70947d8 100644 --- a/examples/hackernews/public/index.html +++ b/examples/hackernews/public/index.html @@ -4,7 +4,7 @@ Hacker News - +