docs.sheetjs.com/tests/engines/duktape-zig.sh

41 lines
1.2 KiB
Bash
Raw Normal View History

2026-01-21 06:14:24 +00:00
#!/bin/bash
# https://docs.sheetjs.com/docs/demos/engines/duktape#zig-demo
cd /tmp
rm -rf sheetjs-zig
mkdir -p sheetjs-zig
cd sheetjs-zig
## NOTE: these steps are for darwin
2026-01-22 06:59:11 +00:00
ARCH="$(uname -m)"
case "$ARCH" in
2026-01-21 06:14:24 +00:00
arm64) curl -LO https://ziglang.org/download/0.15.2/zig-aarch64-macos-0.15.2.tar.xz ;;
x86_64) curl -LO https://ziglang.org/download/0.15.2/zig-x86_64-macos-0.15.2.tar.xz ;;
2026-01-22 06:59:11 +00:00
*) echo "unsupported arch $ARCH"; exit 1 ;;
2026-01-21 06:14:24 +00:00
esac
tar -xzf zig-*.tar.xz
./zig-*/zig init
curl -LO https://duktape.org/duktape-2.7.0.tar.xz
tar -xJf duktape-2.7.0.tar.xz
curl -LO https://cdn.sheetjs.com/xlsx-latest/package/dist/shim.min.js
curl -LO https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js
curl -LO https://docs.sheetjs.com/pres.numbers
mv *.js src
curl -L -o src/main.zig https://docs.sheetjs.com/duk/main.zig
sed -i '' '/b.installArtifact(exe);/ i\
exe.addCSourceFile(.{ .file = b.path("duktape-2.7.0/src/duktape.c"), .flags = &.{ "-std=c99", "-fno-sanitize=undefined" } });\
exe.addIncludePath(b.path("duktape-2.7.0/src"));\
exe.linkSystemLibrary("c");\
exe.linkSystemLibrary("m");' build.zig
./zig-*/zig build run -- pres.numbers; echo $?
npx -y xlsx-cli sheetjs.zig.xlsx