41 lines
1.2 KiB
Bash
Executable File
41 lines
1.2 KiB
Bash
Executable File
#!/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
|
|
ARCH="$(uname -m)"
|
|
|
|
case "$ARCH" in
|
|
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 ;;
|
|
*) echo "unsupported arch $ARCH"; exit 1 ;;
|
|
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
|