c6d2958744
Add make release and make install PREFIX=/Users/valdemar/.local. Keep optimized no-debug release artifacts separate; install adjacent CLI/app under lib/terebi and link bin/terebi. Preflight FFmpeg/pkg-config before compiling or installing, including cached builds. Record the player's exact linked FFmpeg ABI paths. AppKit-only CLI/bootstrap validate native loadability and transitive dependencies before entering the FFmpeg-linked terebi-player. CLI fails with status 69 and remediation; Finder bootstrap shows a native alert and execs the player without losing initial events or process identity. Verified staged installation with spaces, reinstall preservation, absent build dependencies, missing/corrupt/transitively broken dylibs, real modal error surface, installed CLI and Finder startup across exec, local/YouTube resume and window reuse, and full make check.
35 lines
1.1 KiB
Swift
35 lines
1.1 KiB
Swift
import AppKit
|
|
import Darwin
|
|
|
|
@main
|
|
@MainActor
|
|
enum TerebiBootstrap {
|
|
static func main() {
|
|
let app = Bundle.main.bundleURL
|
|
if let error = FFmpegRuntime.error(for: app) {
|
|
fail(error)
|
|
}
|
|
let payload = app.appendingPathComponent("Contents/MacOS/terebi-player")
|
|
let errorCode = payload.path.withCString { path in
|
|
_ = execv(path, CommandLine.unsafeArgv)
|
|
return errno
|
|
}
|
|
let detail = String(cString: strerror(errorCode))
|
|
fail("Could not start the player: \(detail)\n\nPlayer executable: \(payload.path)\nRebuild and reinstall terebi.")
|
|
}
|
|
|
|
private static func fail(_ message: String) -> Never {
|
|
FileHandle.standardError.write(Data("terebi: \(message)\n".utf8))
|
|
let application = NSApplication.shared
|
|
application.setActivationPolicy(.regular)
|
|
application.activate(ignoringOtherApps: true)
|
|
let alert = NSAlert()
|
|
alert.alertStyle = .critical
|
|
alert.messageText = "terebi could not start"
|
|
alert.informativeText = message
|
|
alert.addButton(withTitle: "Quit")
|
|
alert.runModal()
|
|
exit(69)
|
|
}
|
|
}
|