1use std::process::Command;
2
3fn main() {
4 println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7");
5
6 if let Ok(value) = std::env::var("ZED_PREVIEW_CHANNEL") {
7 println!("cargo:rustc-env=ZED_PREVIEW_CHANNEL={value}");
8 }
9
10 if std::env::var("ZED_BUNDLE").ok().as_deref() == Some("true") {
11 // Find WebRTC.framework in the Frameworks folder when running as part of an application bundle.
12 println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path/../Frameworks");
13 } else {
14 // Find WebRTC.framework as a sibling of the executable when running outside of an application bundle.
15 println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");
16 }
17
18 // Weakly link ReplayKit to ensure Zed can be used on macOS 10.15+.
19 println!("cargo:rustc-link-arg=-Wl,-weak_framework,ReplayKit");
20
21 // Seems to be required to enable Swift concurrency
22 println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/lib/swift");
23
24 // Register exported Objective-C selectors, protocols, etc
25 println!("cargo:rustc-link-arg=-Wl,-ObjC");
26
27 // Install dependencies for theme-generation
28 let output = Command::new("npm")
29 .current_dir("../../styles")
30 .args(["install", "--no-save"])
31 .output()
32 .expect("failed to run npm");
33 if !output.status.success() {
34 panic!(
35 "failed to install theme dependencies {}",
36 String::from_utf8_lossy(&output.stderr)
37 );
38 }
39
40 // Regenerate themes
41 let output = Command::new("npm")
42 .current_dir("../../styles")
43 .args(["run", "build"])
44 .output()
45 .expect("failed to run npm");
46 if !output.status.success() {
47 panic!(
48 "build script failed {}",
49 String::from_utf8_lossy(&output.stderr)
50 );
51 }
52
53 println!("cargo:rerun-if-changed=../../styles/src");
54}