Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified tauri/src-tauri/bin/mic_check
Binary file not shown.
Binary file modified tauri/src-tauri/bin/mic_check-aarch64-apple-darwin
Binary file not shown.
37 changes: 37 additions & 0 deletions tauri/src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;

fn main() {
compile_mic_check_helper();
compile_system_audio_helper();
compile_calendar_helper();
stage_minutes_cli_sidecar();
Expand Down Expand Up @@ -108,6 +109,42 @@ fn stage_minutes_cli_sidecar() {
}
}

fn compile_mic_check_helper() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
if target_os != "macos" {
return;
}

let manifest_dir = PathBuf::from(
std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR should be set"),
);
let source = manifest_dir.join("src/mic_check.swift");
let bin_dir = manifest_dir.join("bin");
let binary = bin_dir.join("mic_check");
let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown-target".into());
let target_binary = bin_dir.join(format!("mic_check-{}", target));

println!("cargo:rerun-if-changed={}", source.display());
std::fs::create_dir_all(&bin_dir).expect("failed to create helper bin dir");

let output = Command::new("swiftc")
.arg(&source)
.arg("-o")
.arg(&binary)
.output()
.expect("failed to run swiftc for mic_check");

if !output.status.success() {
panic!(
"failed to compile mic_check.swift: {}",
String::from_utf8_lossy(&output.stderr)
);
}

std::fs::copy(&binary, &target_binary)
.expect("failed to copy target-specific mic_check helper");
}

fn compile_system_audio_helper() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
if target_os != "macos" {
Expand Down
Loading
Loading