-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
74 lines (66 loc) · 2.53 KB
/
Copy pathbuild.rs
File metadata and controls
74 lines (66 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use std::{env, path::PathBuf, process::Command};
fn main() {
const MINIMUM_MACOS_VERSION: &str = "14.2";
println!("cargo:rerun-if-changed=Info.plist");
println!("cargo:rerun-if-changed=src/process_tap.h");
println!("cargo:rerun-if-changed=src/process_tap.m");
println!("cargo:rerun-if-changed=src/media_sessions.m");
if env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("macos") {
return;
}
cc::Build::new()
.file("src/process_tap.m")
.flag("-fobjc-arc")
.flag("-Werror=return-type")
.flag(format!("-mmacosx-version-min={MINIMUM_MACOS_VERSION}"))
.compile("codex_micro_chroma_process_tap");
let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("build output directory"));
let helper = out_dir.join("codex_micro_chroma_media_sessions");
let target_arch = match env::var("CARGO_CFG_TARGET_ARCH").as_deref() {
Ok("aarch64") => "arm64",
Ok("x86_64") => "x86_64",
Ok(other) => panic!("unsupported macOS target architecture: {other}"),
Err(error) => panic!("missing target architecture: {error}"),
};
let clang_status = Command::new("/usr/bin/xcrun")
.args([
"clang",
"-fobjc-arc",
"-fblocks",
"-Wall",
"-Wextra",
"-Werror=return-type",
"-arch",
target_arch,
&format!("-mmacosx-version-min={MINIMUM_MACOS_VERSION}"),
"-framework",
"Foundation",
"-o",
])
.arg(&helper)
.arg("src/media_sessions.m")
.status()
.expect("failed to launch clang for the MediaRemote session helper");
assert!(
clang_status.success(),
"failed to compile MediaRemote session helper"
);
let codesign_status = Command::new("/usr/bin/codesign")
.args(["--force", "--sign", "-"])
.arg(&helper)
.status()
.expect("failed to launch codesign for the MediaRemote session helper");
assert!(
codesign_status.success(),
"failed to ad-hoc sign MediaRemote session helper"
);
println!("cargo:rustc-link-lib=framework=Foundation");
println!("cargo:rustc-link-lib=framework=CoreAudio");
println!("cargo:rustc-link-arg=-mmacosx-version-min={MINIMUM_MACOS_VERSION}");
let plist = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("manifest directory"))
.join("Info.plist");
println!(
"cargo:rustc-link-arg=-Wl,-sectcreate,__TEXT,__info_plist,{}",
plist.display()
);
}