Files
sausage/spikes/s7-preview1-adapter/build.nu
T
surma 5ce2a2f2bd vfs: host-side WASI preview1 over sausage-vfs (T11)
Preview1 state lives in the host, so Go modules (esbuild) work. esbuild bundles
byte-identical to native; uutils and QuickJS-ng file tests pass. The failed
guest-side adapter attempt (T7) moves to spikes/s7-preview1-adapter/.
2026-11-06 16:34:33 +00:00

30 lines
1.4 KiB
Nu

# Build the command adapter from pinned Wasmtime sources and a local patch.
def main [] {
let root = '/tmp/p1-adapter'
let source = $root | path join wasmtime
let revision = '3c8a3e79aa3188a1a12b3aebbaa097abccceac92'
mkdir $root
if not ($source | path exists) {
^git clone --depth 1 --branch v49.0.2 https://github.com/bytecodealliance/wasmtime.git $source
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'clone failed'} }
}
if ((^git -C $source rev-parse HEAD | str trim) != $revision) {
error make {msg: 'unexpected Wasmtime revision'}
}
let patch = $env.FILE_PWD | path join eager-state.patch
let applied = (^git -C $source apply --reverse --check $patch | complete)
if $applied.exit_code != 0 {
^git -C $source apply $patch
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'patch failed'} }
}
cd $source
with-env {CARGO_TARGET_DIR: '/tmp/p1-adapter/target', CARGO_BUILD_JOBS: '2'} {
^cargo build --locked -p wasi-preview1-component-adapter --target wasm32-unknown-unknown --release --features command --no-default-features
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'adapter build failed'} }
}
cp ($root | path join target wasm32-unknown-unknown release wasi_snapshot_preview1.wasm) ($root | path join adapter-command.wasm)
^wasm-tools validate ($root | path join adapter-command.wasm)
if $env.LAST_EXIT_CODE != 0 { error make {msg: 'adapter validation failed'} }
print 'PASS patched command adapter build'
}