#!/bin/bash
# Build script for Kobo e-reader ARM binary

set -e

echo "Building kb_exfiltrator for Kobo (ARM)..."
zig build -Dtarget=arm-linux-musleabihf -Doptimize=ReleaseSmall

# Save the ARM binary with a clear name
cp zig-out/bin/kb_exfiltrator kb_exfiltrator-kobo-arm
chmod +x kb_exfiltrator-kobo-arm

echo ""
echo "Build complete!"
ls -lh kb_exfiltrator-kobo-arm
file kb_exfiltrator-kobo-arm

echo ""
echo "ARM binary saved as: kb_exfiltrator-kobo-arm"
echo ""
echo "To use on your Kobo:"
echo "1. Copy kb_exfiltrator-kobo-arm to your Kobo (via USB or SSH)"
echo "2. Run: ./kb_exfiltrator-kobo-arm /mnt/onboard/.kobo/KoboReader.sqlite"
echo ""
echo "To save highlights to a file:"
echo "  ./kb_exfiltrator-kobo-arm /mnt/onboard/.kobo/KoboReader.sqlite > my_highlights.txt"
echo ""
echo "To test locally, use: zig build && ./zig-out/bin/kb_exfiltrator local-dev.sqlite"
