xworkmate-app/scripts/integrate_rust_flutter.sh
Haitao Pan a04b22ec4a refactor(storage): unify persistent storage with robust error handling and simplified secret management
- Consolidate settings, tasks, and audit storage into SettingsStore and SecretStore
- Implement PersistentWriteFailure for detailed error reporting across storage scopes
- Migrate secret retrieval to rely primarily on reference-based lookups
- Add ThemeMode persistence and AccountSyncState serialization
- Modernize SecureConfigStore with clear path resolution and support for UI state
- Streamline Rust build process by migrating from custom scripts to Makefile
- Remove redundant build_rust_ffi.sh and update integration scripts
2026-04-19 10:34:15 +08:00

55 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Integrate Rust FFI library with Flutter macOS build
# This script should be run before flutter build macos
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
echo "Integrating Rust FFI with Flutter..."
# Build Rust library if not exists
RUST_LIB="$PROJECT_ROOT/rust/target/universal/libcodex_ffi.dylib"
if [[ ! -f "$RUST_LIB" ]]; then
echo "Rust library not found, building..."
# Attempt to build using Makefile target if available
(cd "$PROJECT_ROOT" && make rust-build-release)
fi
# Ensure Frameworks directory exists
FRAMEWORKS_DIR="$PROJECT_ROOT/macos/Frameworks"
mkdir -p "$FRAMEWORKS_DIR"
# Copy library
if [[ -f "$RUST_LIB" ]]; then
cp "$RUST_LIB" "$FRAMEWORKS_DIR/"
echo "Copied libcodex_ffi.dylib to $FRAMEWORKS_DIR/"
else
echo "Warning: Universal binary not found, using arm64..."
ARM_LIB="$PROJECT_ROOT/rust/target/aarch64-apple-darwin/release/libcodex_ffi.dylib"
if [[ -f "$ARM_LIB" ]]; then
cp "$ARM_LIB" "$FRAMEWORKS_DIR/"
echo "Copied arm64 library to $FRAMEWORKS_DIR/"
else
echo "Error: No Rust library found. Please run 'make rust-build-release' first."
exit 1
fi
fi
# Update Xcode project to link the library
# This would typically be done via Xcode build phases
echo ""
echo "Note: You may need to add the following to your Xcode project:"
echo " 1. Add libcodex_ffi.dylib to 'Link Binary With Libraries' build phase"
echo " 2. Add macos/Frameworks to 'Framework Search Paths'"
echo ""
# Generate FFI bindings if needed
if [[ ! -f "$PROJECT_ROOT/lib/runtime/codex_ffi_generated.dart" ]]; then
echo "Generating FFI bindings..."
"$SCRIPT_DIR/generate_ffi_bindings.sh"
fi
echo "Integration complete!"