agent-desktop/scripts/update-ffi-header.sh
Lahfir f73c023eac fix(ffi): resolve 4 code review findings (P1-P3)
P1: last_error_survives_successful_calls used ad_check_permissions as
a success-only probe but it returns ErrPermDenied without Accessibility
permission, overwriting the TLS error slot. Replaced with null-tolerant
list accessors that never set last-error.

P2: build.rs auto-copied the generated header into include/, making the
CI drift check self-heal instead of catching stale ABI. Removed the
copy step; CI now diffs OUT_DIR output against the committed header.
Added scripts/update-ffi-header.sh for developers.

P2: ad_free_handle suppressed ActionNotSupported but the default adapter
returns PlatformNotSupported. Added PlatformNotSupported to the match.

P3: ad_get_clipboard returned Ok with *out=NULL when clipboard text had
an interior NUL. Now returns ErrInternal with a diagnostic message.
2026-04-16 16:11:51 -07:00

21 lines
717 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
# Regenerate the committed FFI header from source.
# Run this after changing any `#[no_mangle] pub extern "C"` signatures
# in crates/ffi/src/ and commit the result.
cargo build -p agent-desktop-ffi 2>/dev/null
GENERATED=$(find target -path '*/agent-desktop-ffi-*/out/agent_desktop.h' -newer crates/ffi/include/agent_desktop.h | head -1)
if [ -z "$GENERATED" ]; then
GENERATED=$(find target -path '*/agent-desktop-ffi-*/out/agent_desktop.h' | head -1)
fi
if [ -z "$GENERATED" ]; then
echo "ERROR: cbindgen did not produce a header. Check build output." >&2
exit 1
fi
cp "$GENERATED" crates/ffi/include/agent_desktop.h
echo "Updated crates/ffi/include/agent_desktop.h"