1#!/bin/sh
2# Build and relaunch the app. Ships the RELEASE binary — the timeline is
3# measurably 4× slower under -Onone, so the app people actually run must be
4# optimized. Pass --debug to ship the debug build (e.g. when chasing a crash
5# with full assertions/symbols).
6set -e
7cd "$(dirname "$0")"
8CONF=release
9[ "$1" = "--debug" ] && CONF=debug
10swift build -c "$CONF"
11pkill -x Sequencer 2>/dev/null || true
12# The app terminates its ffmpeg children on SIGTERM, but sweep any strays from
13# older builds anyway — orphaned encoders exhaust the shared VideoToolbox
14# session pool and the next launch's players silently render black.
15sleep 1
16pkill -9 -f "Library/Caches/Sequencer" 2>/dev/null || true
17cp ".build/$CONF/Sequencer" Sequencer.app/Contents/MacOS/Sequencer
18codesign --force --deep --sign "Sequencer Dev" Sequencer.app
19open Sequencer.app