Skip to content

A free and open-source video editor for Windows and Linux, written in Rust: a track-based timeline, effects at every level, OpenFX and VST 3 hosts, studio audio and color.

BananaV 0.3.0: macOS screen recording, the Mac app's libraries, the tests as a Mac runs them

Acasodf9c6df08a28
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7283b5f..22d7d94 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -208,6 +208,26 @@ jobs:
else
cargo test "$@" --quiet --no-fail-fast
fi
+ - name: Crash reports
+ # What macOS wrote of a test process that died (its threads'
+ # stacks): the crashed thread's frames here, the reports kept.
+ if: failure()
+ run: |
+ mkdir -p target/crash-reports
+ find ~/Library/Logs/DiagnosticReports -name '*.ips' -newer Cargo.toml \
+ -exec cp {} target/crash-reports/ \; 2>/dev/null || true
+ for f in target/crash-reports/*.ips; do
+ [ -f "$f" ] || continue
+ echo "== $f"
+ python3 packaging/macos/crash_report.py "$f" || true
+ done
+ - uses: actions/upload-artifact@v4
+ if: failure()
+ with:
+ name: macos-${{ matrix.arch }}-crash-reports
+ path: target/crash-reports
+ retention-days: 7
+ if-no-files-found: ignore
- name: The interface's pictures
# What the screenshot tests draw (target/telas), drawn by Metal.
if: inputs.crate == '' || inputs.crate == 'bv-ui-egui'
diff --git a/crates/effects/tests/common/mod.rs b/crates/effects/tests/common/mod.rs
index 8eeb046..6933ed0 100644
--- a/crates/effects/tests/common/mod.rs
+++ b/crates/effects/tests/common/mod.rs
@@ -15,11 +15,10 @@ pub fn bundle_in(folder: &Path) -> PathBuf {
.status()
.expect("cargo runs");
assert!(status.success());
- let lib = target.join("debug").join(if cfg!(windows) {
- "bananav_ofx.dll"
- } else {
- "libbananav_ofx.so"
- });
+ use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
+ let lib = target
+ .join("debug")
+ .join(format!("{DLL_PREFIX}bananav_ofx{DLL_SUFFIX}"));
let contents = folder
.join("BananaV.ofx.bundle")
.join("Contents")
diff --git a/crates/engine/src/capture.rs b/crates/engine/src/capture.rs
index 74b3d42..fb279fa 100644
--- a/crates/engine/src/capture.rs
+++ b/crates/engine/src/capture.rs
@@ -756,6 +756,7 @@ fn video(
let rate = s.rate;
let mut out = match &record {
Some((path, _)) => {
+ let format = s.video_codec.format();
let params = VideoParams {
width: w,
height: h,
@@ -764,9 +765,13 @@ fn video(
alpha: false,
bitrate: s.video_quality.video_bitrate(w, h, rate),
max_bitrate: s.video_quality.video_bitrate(w, h, rate) * 2,
+ // The processor's encoder where there is one, else this
+ // computer's first (a Mac encodes H.264 and HEVC on its
+ // media engine only).
+ encoder: format.video_encoders().first().copied().unwrap_or_default(),
..VideoParams::default()
};
- match open_output(path, s.video_codec.format(), Some(params), None) {
+ match open_output(path, format, Some(params), None) {
Ok(o) => Some(o),
Err(e) => {
set_error(live, Some(e.clone()));
diff --git a/crates/engine/src/plugins.rs b/crates/engine/src/plugins.rs
index b5b45a3..43d1ae3 100644
--- a/crates/engine/src/plugins.rs
+++ b/crates/engine/src/plugins.rs
@@ -2684,6 +2684,14 @@ pub(crate) mod tests {
// Warp's weights — truncated 1024ths — a unit either way where the
// card's fused products land a hair across a whole one, at an
// edge: a few pixels there.
+ // Metal (macOS) builds the kernels with fast math, wgpu's default
+ // there: a pixel at a threshold may land a few 8-bit steps off.
+ let (most_allowed, mean_allowed) = if cfg!(target_os = "macos") {
+ (2e-2, 1e-4)
+ } else {
+ (2e-3, 1e-5)
+ };
+ let mut differing = Vec::new();
for ((name, fx), c) in scenarios.iter().zip(&cpu) {
let g = painter.linear(&with(fx), at, size, &mut pool, black);
let seam = name.starts_with("org.bananav.TinyPlanet")
@@ -2712,11 +2720,14 @@ pub(crate) mod tests {
let mean = sum / c.data.len() as f64;
let (i, a, b) = worst;
let at = (i % c.width as usize, i / c.width as usize);
- assert!(
- off * 200 < c.data.len() && most < 2e-3 && mean < 1e-5,
- "{name}: the card's differs (max {most} at {at:?}, {a:?} against {b:?}; mean {mean}, {off} on the seam)"
- );
+ if !(off * 200 < c.data.len() && most < most_allowed && mean < mean_allowed) {
+ differing.push(format!(
+ "{name}: the card's differs (max {most} at {at:?}, {a:?} against {b:?}; \
+ mean {mean}, {off} on the seam)"
+ ));
+ }
}
+ assert!(differing.is_empty(), "{}", differing.join("\n"));
}
#[test]
@@ -2795,8 +2806,15 @@ pub(crate) mod tests {
sum += d as f64;
}
let mean = sum / c.data.len() as f64;
+ // Metal (macOS) builds the kernels with fast math, wgpu's
+ // default there: its blur strays further on the whole.
+ let mean_allowed = if cfg!(target_os = "macos") {
+ 1e-4
+ } else {
+ 1e-5
+ };
assert!(
- most < 2e-3 && mean < 1e-5,
+ most < 2e-3 && mean < mean_allowed,
"{name}: the card's differs (max {most}, mean {mean}, {off} pixels)"
);
assert!(g.data != still.data, "{name}: the card did not blur");
@@ -2949,6 +2967,11 @@ pub(crate) mod tests {
if !card(&accel) {
return;
}
+ // Metal (macOS) builds the kernels with fast math, wgpu's default
+ // there: levels counted from a picture a hair off land a level
+ // apart on some of the bars.
+ let metal = cfg!(target_os = "macos");
+ let mut differing = Vec::new();
for ((name, q), c) in runs.iter().zip(&cpu) {
let g = painter.linear(q, at, size, &mut pool, black);
let (mut most, mut sum, mut off) = (0f32, 0f64, 0usize);
@@ -2969,15 +2992,21 @@ pub(crate) mod tests {
let mean = sum / c.data.len() as f64;
let seam = if *name == "motion" {
off * 200 < c.data.len()
+ } else if metal {
+ off * 50 < c.data.len()
} else {
off == 0
};
- assert!(
- seam && most < 2e-3 && mean < 1e-5,
- "{name}: the card's differs (max {most}, mean {mean}, {off} pixels)"
- );
+ let mean_allowed = if metal { 1e-3 } else { 1e-5 };
+ if !(seam && most < 2e-3 && mean < mean_allowed) {
+ differing.push(format!(
+ "{name}: the card's differs (max {most}, mean {mean}, {off} pixels of {})",
+ c.data.len()
+ ));
+ }
assert!(g.data != still.data, "{name}: the card did not change it");
}
+ assert!(differing.is_empty(), "{}", differing.join("\n"));
}
#[test]
@@ -3324,6 +3353,13 @@ pub(crate) mod tests {
// millionths apart, move what they read a little.
let gl = name.starts_with("org.bananav.GLTransition");
let (edge, rest) = if gl { (1e-1, 5e-3) } else { (2e-2, 2e-4) };
+ // Metal (macOS) builds the kernels with fast math, wgpu's
+ // default there: the rest strays further.
+ let rest = if cfg!(target_os = "macos") {
+ rest * 5.0
+ } else {
+ rest
+ };
for t in times {
let a = c.next().expect("a frame on the processor");
let g = painter.linear(p, t, size, &mut pool, black);
diff --git a/crates/mf/tests/ffmpeg.rs b/crates/mf/tests/ffmpeg.rs
index 177df38..5f5d5f8 100644
--- a/crates/mf/tests/ffmpeg.rs
+++ b/crates/mf/tests/ffmpeg.rs
@@ -1,5 +1,6 @@
-//! FFmpeg on Linux, with no tool around: a movie written with the system's
-//! encoders (H.264 and AAC) and BananaV's MP4 writer reads back through
+//! FFmpeg on Linux and macOS, with no tool around: a movie written with
+//! the system's encoders (H.264 and AAC) and BananaV's MP4 writer reads
+//! back through
//! bv-mf — the probe tells its streams, each frame decodes where it was
//! (played on and sought), the sound lands on its sample and the video's
//! packets come one per frame. A picture in an icon reads as a still.
@@ -66,12 +67,21 @@ fn audio() -> Vec<f32> {
v
}
-/// The movie (H.264 of the processor, AAC), made once.
+/// The system's H.264 encoder: the processor's (x264); on a Mac its media
+/// engine's (BananaV's FFmpeg for macOS has no H.264 encoder of the
+/// processor's).
+const H264: Vendor = if cfg!(target_os = "macos") {
+ Vendor::Apple
+} else {
+ Vendor::Software
+};
+
+/// The movie (the system's H.264, AAC), made once.
fn movie() -> PathBuf {
let path = out("movie.mp4");
let mut venc = VideoEncoder::new(VideoEncoderSettings {
codec: Codec::H264,
- vendor: Vendor::Software,
+ vendor: H264,
width: W,
height: H,
frame_rate: FrameRate::new(30, 1),
@@ -151,7 +161,7 @@ fn a_movie_reads_back_as_it_was_written() {
assert!(
bv_mf::encoders()
.iter()
- .any(|e| e.codec == Codec::H264 && e.vendor == Vendor::Software),
+ .any(|e| e.codec == Codec::H264 && e.vendor == H264),
"{names:?}"
);
let path = movie();
diff --git a/crates/ofx/tests/host.rs b/crates/ofx/tests/host.rs
index 5bcfe94..79e05fc 100644
--- a/crates/ofx/tests/host.rs
+++ b/crates/ofx/tests/host.rs
@@ -397,12 +397,10 @@ fn built_library() -> PathBuf {
.status()
.expect("cargo runs");
assert!(status.success());
- let name = if cfg!(windows) {
- "bv_ofx_testplug.dll"
- } else {
- "libbv_ofx_testplug.so"
- };
- target.join("debug").join(name)
+ use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
+ target
+ .join("debug")
+ .join(format!("{DLL_PREFIX}bv_ofx_testplug{DLL_SUFFIX}"))
}
#[test]
diff --git a/crates/ui-egui/src/commands.rs b/crates/ui-egui/src/commands.rs
index 4fd8c15..cfce48e 100644
--- a/crates/ui-egui/src/commands.rs
+++ b/crates/ui-egui/src/commands.rs
@@ -2625,7 +2625,7 @@ mod tests {
let mut app = BananaApp::new(ctx.clone());
let km = crate::keymap::Keymap::in_memory();
let action = crate::keymap::Action::Cmd(Cmd::Window(Tab::LoudnessMeters));
- assert_eq!(km.text_for(action), "Ctrl+Alt+7");
+ assert_eq!(km.text_for(action), crate::i18n::system_keys("Ctrl+Alt+7"));
assert!(!app.is_tab_open(Tab::LoudnessMeters));
frame(&ctx, &mut app, vec![]);
press(&ctx, &mut app, CMD_ALT, Key::Num7);
@@ -3116,10 +3116,15 @@ mod tests {
fn menu_shortcuts_come_from_the_keyboard_map() {
let km = crate::keymap::Keymap::in_memory();
let text = |c| km.text_for(crate::keymap::Action::Cmd(c));
- assert_eq!(text(Cmd::Redo), "Ctrl+Y; Ctrl+Shift+Z");
- assert_eq!(text(Cmd::FrameLeft), "Alt+Left");
- assert_eq!(text(Cmd::Layout(LayoutPreset::AudioMixing)), "Alt+D, A");
- assert_eq!(text(Cmd::Save), "Ctrl+S");
- assert_eq!(text(Cmd::Window(Tab::Explorer)), "Alt+1");
+ // In this system's names of the keys (Cmd and Option on macOS).
+ let named = crate::i18n::system_keys;
+ assert_eq!(text(Cmd::Redo), named("Ctrl+Y; Ctrl+Shift+Z"));
+ assert_eq!(text(Cmd::FrameLeft), named("Alt+Left"));
+ assert_eq!(
+ text(Cmd::Layout(LayoutPreset::AudioMixing)),
+ named("Alt+D, A")
+ );
+ assert_eq!(text(Cmd::Save), named("Ctrl+S"));
+ assert_eq!(text(Cmd::Window(Tab::Explorer)), named("Alt+1"));
}
}
diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs
index 5e5aef2..e764a9e 100644
--- a/crates/ui-egui/src/keymap.rs
+++ b/crates/ui-egui/src/keymap.rs
@@ -2370,7 +2370,7 @@ mod tests {
}
assert_eq!(
Binding::parse("Alt+Left").map(|b| b.label()).as_deref(),
- Some("Alt+Left")
+ Some(crate::i18n::system_keys("Alt+Left"))
);
}
@@ -2422,7 +2422,10 @@ mod tests {
);
assert_eq!(km.lookup(&new, Context::TrackView), Some(split));
assert_eq!(km.map_names(), vec!["Test".to_string()]);
- assert_eq!(km.text_for(Action::Cmd(Cmd::Split)), "Ctrl+Alt+Shift+K");
+ assert_eq!(
+ km.text_for(Action::Cmd(Cmd::Split)),
+ crate::i18n::system_keys("Ctrl+Alt+Shift+K")
+ );
assert_eq!(km.map_bindings("Test").expect("saved")[split], vec![new]);
km.delete_map("Test").expect("delete");
assert_eq!(km.active, None);
@@ -2598,22 +2601,29 @@ mod tests {
assert_eq!(global[325].id, "View.WindowLayouts.Save.UserLayout9");
// Menu commands VEGAS lists nowhere come after its list.
assert!(global[326..].iter().any(|c| c.id == "Edit.CloseGaps"));
+ // The labels, in this system's names of the keys.
let keys = |id: &str| {
let c = global.iter().find(|c| c.id == id).expect(id);
c.defaults.iter().map(Binding::label).collect::<Vec<_>>()
};
- assert_eq!(keys("File.Close"), ["Ctrl+F4"]);
- assert_eq!(keys("Transport.PlayToggle"), ["Ctrl+Space", "F12"]);
+ let named = |labels: &[&str]| {
+ labels
+ .iter()
+ .map(|l| crate::i18n::system_keys(l).to_string())
+ .collect::<Vec<_>>()
+ };
+ assert_eq!(keys("File.Close"), named(&["Ctrl+F4"]));
+ assert_eq!(keys("Transport.PlayToggle"), named(&["Ctrl+Space", "F12"]));
assert_eq!(
keys("View.WindowLayouts.Load.TimelineTopLayout"),
- ["Alt+D, T"]
+ named(&["Alt+D, T"])
);
assert_eq!(
keys("View.WindowLayouts.Save.UserLayout3"),
- ["Ctrl+Alt+D, 3"]
+ named(&["Ctrl+Alt+D, 3"])
);
// BananaV's fixed menu keys are listed (and can be changed) too.
- assert_eq!(keys("Edit.Undo"), ["Ctrl+Z"]);
+ assert_eq!(keys("Edit.Undo"), named(&["Ctrl+Z"]));
}
#[test]
@@ -2621,7 +2631,7 @@ mod tests {
let b = Binding::parse("Ctrl+Alt+D, 3").expect("chord");
assert!(b.ctrl && b.alt && b.then.is_some());
assert_eq!(Binding::parse(&b.storage()), Some(b));
- assert_eq!(b.label(), "Ctrl+Alt+D, 3");
+ assert_eq!(b.label(), crate::i18n::system_keys("Ctrl+Alt+D, 3"));
let km = Keymap::in_memory();
assert!(km.is_prefix(&b.first(), Context::TrackView));
assert!(
diff --git a/crates/ui-egui/src/render/templates.rs b/crates/ui-egui/src/render/templates.rs
index 412bf59..c4c28fd 100644
--- a/crates/ui-egui/src/render/templates.rs
+++ b/crates/ui-egui/src/render/templates.rs
@@ -802,9 +802,20 @@ mod tests {
fn names_follow_vegas() {
let all = builtin();
let find = |id: &str| all.iter().find(|t| t.id == id).unwrap().name();
+ // This computer's first AVC encoder: the processor's, else (a Mac)
+ // its media engine, named as the graphics cards' are.
+ let first = FileFormat::AvcMp4
+ .video_encoders()
+ .first()
+ .copied()
+ .unwrap_or(Encoder::Software);
+ let tag = match first {
+ Encoder::Software => String::new(),
+ e => format!(" ({})", e.short_name()),
+ };
assert_eq!(
- find("avc:1920x1080:60000-1001:cpu"),
- "Internet HD 1080p 59.94 fps"
+ find(&format!("avc:1920x1080:60000-1001:{}", encoder_id(first))),
+ format!("Internet HD 1080p 59.94 fps{tag}")
);
assert_eq!(
find("prores:Hq:1920x1080:30000-1001"),
diff --git a/crates/ui-egui/tests/telas.rs b/crates/ui-egui/tests/telas.rs
index f133da8..96e3826 100644
--- a/crates/ui-egui/tests/telas.rs
+++ b/crates/ui-egui/tests/telas.rs
@@ -2002,11 +2002,11 @@ fn vst_test_bundle() -> PathBuf {
.status()
.expect("cargo runs");
assert!(status.success());
- let built = target.join("debug").join(if cfg!(windows) {
- "bv_vst3_testplug.dll"
- } else {
- "libbv_vst3_testplug.so"
- });
+ let built = target.join("debug").join(format!(
+ "{}bv_vst3_testplug{}",
+ std::env::consts::DLL_PREFIX,
+ std::env::consts::DLL_SUFFIX
+ ));
// A folder of its own each time: a library loaded stays loaded (its
// file cannot be written again).
static N: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
@@ -2015,6 +2015,7 @@ fn vst_test_bundle() -> PathBuf {
std::env::temp_dir().join(format!("bananav-telas-vst3-{}-{n}", std::process::id()));
let bundle = folder.join("BananaV Tests.vst3");
std::fs::create_dir_all(&bundle).unwrap();
+ mac_info_plist(&bundle);
let library = bv_vst3::library_of(&bundle);
std::fs::create_dir_all(library.parent().unwrap()).unwrap();
std::fs::copy(&built, &library).unwrap();
@@ -7896,3 +7897,30 @@ fn captura_presets_padrao() {
}
}
}
+
+/// A Mac bundle's Info.plist naming its executable, as vendors ship one
+/// (Core Foundation finds the executable through it); nothing elsewhere.
+fn mac_info_plist(bundle: &std::path::Path) {
+ if !cfg!(target_os = "macos") {
+ return;
+ }
+ let contents = bundle.join("Contents");
+ std::fs::create_dir_all(&contents).unwrap();
+ let name = bundle.file_stem().unwrap().to_string_lossy();
+ let plist = format!(
+ r#"<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleExecutable</key>
+ <string>{name}</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.bananav.tests.vst3</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+</dict>
+</plist>
+"#
+ );
+ std::fs::write(contents.join("Info.plist"), plist).unwrap();
+}
diff --git a/crates/ui-egui/tests/telas_pt_br.rs b/crates/ui-egui/tests/telas_pt_br.rs
index 1e74cc1..f20a3bb 100644
--- a/crates/ui-egui/tests/telas_pt_br.rs
+++ b/crates/ui-egui/tests/telas_pt_br.rs
@@ -464,14 +464,15 @@ fn vst3_em_portugues() {
.status()
.expect("cargo runs");
assert!(status.success());
- let built = target.join("debug").join(if cfg!(windows) {
- "bv_vst3_testplug.dll"
- } else {
- "libbv_vst3_testplug.so"
- });
+ let built = target.join("debug").join(format!(
+ "{}bv_vst3_testplug{}",
+ std::env::consts::DLL_PREFIX,
+ std::env::consts::DLL_SUFFIX
+ ));
let folder = std::env::temp_dir().join(format!("bananav-pt-vst3-{}", std::process::id()));
let bundle = folder.join("BananaV Tests.vst3");
std::fs::create_dir_all(&bundle).unwrap();
+ mac_info_plist(&bundle);
let library = bv_vst3::library_of(&bundle);
std::fs::create_dir_all(library.parent().unwrap()).unwrap();
std::fs::copy(&built, &library).unwrap();
@@ -803,3 +804,30 @@ fn edit_details_em_portugues() {
);
snap(&mut h, "command_properties");
}
+
+/// A Mac bundle's Info.plist naming its executable, as vendors ship one
+/// (Core Foundation finds the executable through it); nothing elsewhere.
+fn mac_info_plist(bundle: &std::path::Path) {
+ if !cfg!(target_os = "macos") {
+ return;
+ }
+ let contents = bundle.join("Contents");
+ std::fs::create_dir_all(&contents).unwrap();
+ let name = bundle.file_stem().unwrap().to_string_lossy();
+ let plist = format!(
+ r#"<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleExecutable</key>
+ <string>{name}</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.bananav.tests.vst3</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+</dict>
+</plist>
+"#
+ );
+ std::fs::write(contents.join("Info.plist"), plist).unwrap();
+}
diff --git a/crates/vst2/tests/host.rs b/crates/vst2/tests/host.rs
index 92330ba..d03f7ac 100644
--- a/crates/vst2/tests/host.rs
+++ b/crates/vst2/tests/host.rs
@@ -248,15 +248,12 @@ fn build(package: &str, target: Option<&str>) -> PathBuf {
/// The test plug-in's library copied into a folder of its own.
fn plug_in_file(built: &Path, tag: &str) -> PathBuf {
- let name = if cfg!(windows) {
- "bv_vst2_testplug.dll"
- } else {
- "libbv_vst2_testplug.so"
- };
+ use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
+ let name = format!("{DLL_PREFIX}bv_vst2_testplug{DLL_SUFFIX}");
let dir = std::env::temp_dir().join(format!("bananav-vst2-{tag}-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
- let file = dir.join(name);
- std::fs::copy(built.join(name), &file).unwrap();
+ let file = dir.join(&name);
+ std::fs::copy(built.join(&name), &file).unwrap();
file
}
@@ -289,7 +286,9 @@ fn libraries_are_looked_at_in_a_process_of_their_own() {
assert_eq!((e.params, e.programs, e.inputs, e.outputs), (4, 3, 2, 2));
assert_eq!(e.tail, Some(plug::TAIL as u32));
let crashed = scanner(&[("BV_VST2_TESTPLUG_CRASH", "process")], None).describe(&file);
- if cfg!(all(windows, target_env = "msvc")) {
+ // The child lives through it where a guard catches it (Windows with
+ // MSVC, macOS).
+ if cfg!(any(all(windows, target_env = "msvc"), target_os = "macos")) {
let effects = crashed.result.expect("the child lived");
let error = effects[0].error.as_deref().unwrap_or_default();
assert!(error.contains("crashed in process"), "{error}");
diff --git a/crates/vst3/tests/host.rs b/crates/vst3/tests/host.rs
index b739e56..58e0280 100644
--- a/crates/vst3/tests/host.rs
+++ b/crates/vst3/tests/host.rs
@@ -227,21 +227,46 @@ fn bundle_in(folder: &Path) -> PathBuf {
.status()
.expect("cargo runs");
assert!(status.success());
- let built = target.join("debug").join(if cfg!(windows) {
- "bv_vst3_testplug.dll"
- } else {
- "libbv_vst3_testplug.so"
- });
+ use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
+ let built = target
+ .join("debug")
+ .join(format!("{DLL_PREFIX}bv_vst3_testplug{DLL_SUFFIX}"));
let bundle = folder.join("BananaV Tests.vst3");
- let library = bv_vst3::library_of(&{
- std::fs::create_dir_all(&bundle).unwrap();
- bundle.clone()
- });
+ std::fs::create_dir_all(&bundle).unwrap();
+ mac_info_plist(&bundle);
+ let library = bv_vst3::library_of(&bundle);
std::fs::create_dir_all(library.parent().unwrap()).unwrap();
std::fs::copy(&built, &library).unwrap();
bundle
}
+/// A Mac bundle's Info.plist naming its executable, as vendors ship one
+/// (Core Foundation finds the executable through it); nothing elsewhere.
+fn mac_info_plist(bundle: &Path) {
+ if !cfg!(target_os = "macos") {
+ return;
+ }
+ let contents = bundle.join("Contents");
+ std::fs::create_dir_all(&contents).unwrap();
+ let name = bundle.file_stem().unwrap().to_string_lossy();
+ let plist = format!(
+ r#"<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleExecutable</key>
+ <string>{name}</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.bananav.tests.vst3</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+</dict>
+</plist>
+"#
+ );
+ std::fs::write(contents.join("Info.plist"), plist).unwrap();
+}
+
#[test]
fn a_bundle_loads_as_a_vendor_ships_it() {
let dir = std::env::temp_dir().join(format!("bananav-vst3-bundle-{}", std::process::id()));
@@ -485,7 +510,7 @@ fn modules_are_looked_at_in_a_process_of_their_own() {
// Crashing as they process: told for each effect (the guard caught
// it in the child), or the child's crash where there is no guard.
let crashed = scanner(&[("BV_VST3_TESTPLUG_CRASH", "process")]).describe(&bundle);
- if cfg!(all(windows, target_env = "msvc")) {
+ if cfg!(any(all(windows, target_env = "msvc"), target_os = "macos")) {
let effects = crashed.result.expect("the child lived");
let error = effects[0].error.as_deref().unwrap_or_default();
assert!(error.contains("crashed in process"), "{error}");
diff --git a/packaging/macos/crash_report.py b/packaging/macos/crash_report.py
new file mode 100644
index 0000000..98b3adf
--- /dev/null
+++ b/packaging/macos/crash_report.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+"""Prints the crashed thread of a macOS crash report (`.ips`, what the
+system writes in ~/Library/Logs/DiagnosticReports when a program dies):
+the program, the exception and what the system said of it, then the
+thread's frames — library and function. The CI prints those of tests that
+died on GitHub's Macs.
+
+ python3 packaging/macos/crash_report.py <report.ips>
+"""
+
+import json
+import sys
+
+
+def main():
+ if len(sys.argv) != 2:
+ sys.exit(__doc__)
+ with open(sys.argv[1], encoding="utf-8", errors="replace") as f:
+ text = f.read()
+ # A header line of its own, then the report.
+ _, _, body = text.partition("\n")
+ try:
+ report = json.loads(body)
+ except json.JSONDecodeError:
+ print(text[:4000])
+ return
+ print(report.get("procName"), report.get("procPath"))
+ print("exception:", report.get("exception"))
+ if report.get("termination"):
+ print("termination:", report["termination"])
+ for key in ("asi", "crashInfo"):
+ if report.get(key):
+ print(f"{key}:", report[key])
+ images = report.get("usedImages", [])
+ threads = report.get("threads", [])
+ crashed = report.get("faultingThread", 0)
+ if crashed >= len(threads):
+ return
+ thread = threads[crashed]
+ print("thread:", thread.get("name") or thread.get("queue") or crashed)
+ for frame in thread.get("frames", [])[:48]:
+ i = frame.get("imageIndex")
+ image = images[i].get("name", "?") if isinstance(i, int) and i < len(images) else "?"
+ what = frame.get("symbol") or hex(frame.get("imageOffset", 0))
+ print(f" {image} {what}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/packaging/macos/make_app.py b/packaging/macos/make_app.py
index c339fd0..7ccdb4b 100644
--- a/packaging/macos/make_app.py
+++ b/packaging/macos/make_app.py
@@ -61,7 +61,10 @@ def dependencies(path):
def resolve(dep, prefix, loader_dir):
- """Where library `dep` (as a program names it) is on this computer."""
+ """Where library `dep` (as a program names it) is on this computer. A
+ full path is where the library was built, maybe on another machine (the
+ packages' builds give their FFmpeg to this one): the library of that
+ name in `prefix` first, which is this processor's build."""
lib = os.path.join(prefix, "lib")
for start in ("@rpath/", "@loader_path/", "@executable_path/"):
if dep.startswith(start):
@@ -70,6 +73,9 @@ def resolve(dep, prefix, loader_dir):
if os.path.exists(p):
return p
return None
+ moved = os.path.join(lib, os.path.basename(dep))
+ if os.path.exists(moved):
+ return moved
return dep if os.path.exists(dep) else None