Files
sausage/userland/preview1.nu
T
surma d44f1d9677 Build separate native and WASI pipelines with shared multicall names
Checkpoint before integration and package validation.

Assisted-by: SurmAgent:unknown [read] [edit] [bash]
2026-11-12 09:36:27 +00:00

30 lines
1.6 KiB
Nu

#!/usr/bin/env nu
# Build the pinned Go tools and QuickJS C sources for WASI preview1 during development.
def main [bin: path] {
let here = $env.FILE_PWD
let target = ($env.CARGO_TARGET_DIR | path expand)
mkdir $target $bin
for tool in [
{name: awk, source: goawk, package: '.'}
{name: esbuild, source: esbuild, package: './cmd/esbuild'}
] {
let output = ($target | path join $'($tool.name).wasm')
do {
cd ($here | path join $tool.source source)
with-env {GOOS: wasip1, GOARCH: wasm, GOPROXY: off} {
^go build -mod=vendor -trimpath '-ldflags=-s -w' -o $output $tool.package
}
}
if $env.LAST_EXIT_CODE != 0 { error make {msg: $'($tool.name) build failed'} }
^cp --remove-destination $output ($bin | path join $'($tool.name).wasm')
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'preview1 bundle copy failed'} }
}
let build = ($target | path join qjs)
^cmake -S ($here | path join qjs source) -B $build -DCMAKE_SYSTEM_NAME=WASI $'-DCMAKE_C_COMPILER=($env.CC_wasm32_wasip2)' $'-DCMAKE_AR=($env.AR_wasm32_wasip2)' $'-DCMAKE_RANLIB=($env.AR_wasm32_wasip2 | str replace "-ar" "-ranlib")' -DCMAKE_BUILD_TYPE=Release
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'QuickJS configure failed'} }
^cmake --build $build --target qjs_exe --parallel
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'QuickJS build failed'} }
^cp --remove-destination ($build | path join qjs) ($bin | path join qjs.wasm)
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'QuickJS bundle copy failed'} }
}