xworkmate-app/scripts/integrate_rust_flutter.sh
Haitao Pan a6699beff3 feat: integrate Codex CLI as built-in code agent
- Add CodexRuntime for process management and JSON-RPC communication
- Add CodexConfigBridge for AI Gateway configuration
- Add ModeSwitcher for OpenClaw Gateway mode switching (local/remote/offline)
- Add AgentRegistry for agent registration and discovery
- Add RuntimeCoordinator for unified coordination
- Add Rust FFI bindings for native integration
- Add comprehensive test coverage

Phase 1-4 features:
- Configuration bridging to AI Gateway
- Mode switching between local/remote/offline
- Agent registration protocol
- Cloud memory sync capability
- Offline fallback support

CI/CD:
- GitHub Actions workflow for Rust FFI build
- Build scripts for macOS universal binary
- Integration with Flutter build process

Co-authored-by: Codex CLI Integration <codex@openai.com>
2026-03-14 00:10:27 +08:00

54 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..."
"$SCRIPT_DIR/build_rust_ffi.sh" 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 scripts/build_rust_ffi.sh 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!"