From 87299d27f8b49834be454e922d412ba0e02dcd81 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 27 Jan 2024 03:15:30 -0800 Subject: [PATCH 1/4] fix: isolate macos-specific dependencies --- crates/fsevent/Cargo.toml | 4 +++- crates/fsevent/examples/events.rs | 13 ++++++++++--- crates/live_kit_client/Cargo.toml | 17 +++++++++++------ crates/live_kit_client/build.rs | 2 +- crates/media/Cargo.toml | 6 ++++-- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/crates/fsevent/Cargo.toml b/crates/fsevent/Cargo.toml index 065c97c64449f6..a684fca8675427 100644 --- a/crates/fsevent/Cargo.toml +++ b/crates/fsevent/Cargo.toml @@ -12,9 +12,11 @@ doctest = false [dependencies] bitflags = "1" -fsevent-sys = "3.0.2" parking_lot.workspace = true +[target.'cfg(target_os = "macos")'.dependencies] +fsevent-sys = "3.0.2" + [dev-dependencies] tempfile.workspace = true diff --git a/crates/fsevent/examples/events.rs b/crates/fsevent/examples/events.rs index 43678dd6d6bc10..bae9e734259992 100644 --- a/crates/fsevent/examples/events.rs +++ b/crates/fsevent/examples/events.rs @@ -1,10 +1,12 @@ -use fsevent::EventStream; -use std::{env::args, path::Path, time::Duration}; - +#[cfg(target_os = "macos")] fn main() { + use fsevent::EventStream; + use std::{env::args, path::Path, time::Duration}; + let paths = args().skip(1).collect::>(); let paths = paths.iter().map(Path::new).collect::>(); assert!(!paths.is_empty(), "Must pass 1 or more paths as arguments"); + let (stream, _handle) = EventStream::new(&paths, Duration::from_millis(100)); stream.run(|events| { eprintln!("event batch"); @@ -14,3 +16,8 @@ fn main() { true }); } + +#[cfg(not(target_os = "macos"))] +fn main() { + eprintln!("This example only works on macOS"); +} diff --git a/crates/live_kit_client/Cargo.toml b/crates/live_kit_client/Cargo.toml index 65fa9352ac707f..4e61d16dd91422 100644 --- a/crates/live_kit_client/Cargo.toml +++ b/crates/live_kit_client/Cargo.toml @@ -31,8 +31,6 @@ media = { path = "../media" } anyhow.workspace = true async-broadcast = "0.4" -core-foundation = "0.9.3" -core-graphics = "0.22.3" futures.workspace = true log.workspace = true parking_lot.workspace = true @@ -41,6 +39,10 @@ postage.workspace = true async-trait = { workspace = true, optional = true } nanoid = { version ="0.4", optional = true} +[target.'cfg(target_os = "macos")'.dependencies] +core-foundation = "0.9.3" +core-graphics = "0.22.3" + [dev-dependencies] collections = { path = "../collections", features = ["test-support"] } gpui = { path = "../gpui", features = ["test-support"] } @@ -53,20 +55,23 @@ async-trait.workspace = true block = "0.1" bytes = "1.2" byteorder = "1.4" -cocoa = "0.25" -core-foundation = "0.9.3" -core-graphics = "0.22.3" foreign-types = "0.3" futures.workspace = true hmac = "0.12" jwt = "0.16" -objc = "0.2" parking_lot.workspace = true serde.workspace = true serde_derive.workspace = true sha2 = "0.10" simplelog = "0.9" + +[target.'cfg(target_os = "macos")'.dev-dependencies] +core-foundation = "0.9.3" +core-graphics = "0.22.3" +cocoa = "0.25" +objc = "0.2" + [build-dependencies] serde.workspace = true serde_derive.workspace = true diff --git a/crates/live_kit_client/build.rs b/crates/live_kit_client/build.rs index 3f67bfc15694dd..743a26a08d1e50 100644 --- a/crates/live_kit_client/build.rs +++ b/crates/live_kit_client/build.rs @@ -35,7 +35,7 @@ pub struct SwiftTarget { const MACOS_TARGET_VERSION: &str = "10.15.7"; fn main() { - if cfg!(not(any(test, feature = "test-support"))) { + if cfg!(all(target_os = "macos", not(any(test, feature = "test-support")))) { let swift_target = get_swift_target(); build_bridge(&swift_target); diff --git a/crates/media/Cargo.toml b/crates/media/Cargo.toml index 225eca0ff8abd9..a4916a86d502f7 100644 --- a/crates/media/Cargo.toml +++ b/crates/media/Cargo.toml @@ -14,10 +14,12 @@ doctest = false anyhow.workspace = true block = "0.1" bytes = "1.2" -core-foundation = "0.9.3" foreign-types = "0.3" -metal = "0.21.0" + +[target.'cfg(target_os = "macos")'.dependencies] +core-foundation = "0.9.3" objc = "0.2" +metal = "0.21.0" [build-dependencies] bindgen = "0.65.1" From 5e64767f1029f1eb80cde67a0e822e93b70b28dd Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 27 Jan 2024 03:59:45 -0800 Subject: [PATCH 2/4] lint: fix cargo-fmt errors --- crates/live_kit_client/build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/live_kit_client/build.rs b/crates/live_kit_client/build.rs index 743a26a08d1e50..53aad4181bdf6a 100644 --- a/crates/live_kit_client/build.rs +++ b/crates/live_kit_client/build.rs @@ -35,7 +35,10 @@ pub struct SwiftTarget { const MACOS_TARGET_VERSION: &str = "10.15.7"; fn main() { - if cfg!(all(target_os = "macos", not(any(test, feature = "test-support")))) { + if cfg!(all( + target_os = "macos", + not(any(test, feature = "test-support")) + )) { let swift_target = get_swift_target(); build_bridge(&swift_target); From 3ab39d7df9d88b1e327ab96fcf64367a8fce2a98 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 27 Jan 2024 04:29:17 -0800 Subject: [PATCH 3/4] fix: remove duplicate dev-dependency declaration --- crates/live_kit_client/Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/live_kit_client/Cargo.toml b/crates/live_kit_client/Cargo.toml index 4e61d16dd91422..6582a213d97d70 100644 --- a/crates/live_kit_client/Cargo.toml +++ b/crates/live_kit_client/Cargo.toml @@ -67,8 +67,6 @@ simplelog = "0.9" [target.'cfg(target_os = "macos")'.dev-dependencies] -core-foundation = "0.9.3" -core-graphics = "0.22.3" cocoa = "0.25" objc = "0.2" From 30faa538a482832364b21295d8a710584bfa7368 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sat, 27 Jan 2024 04:34:05 -0800 Subject: [PATCH 4/4] fix: remove unused cocoa, core-graphics, objc from livekit --- Cargo.lock | 3 --- crates/live_kit_client/Cargo.toml | 6 ------ 2 files changed, 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2829247cbda84e..888506b09e4921 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3984,10 +3984,8 @@ dependencies = [ "block", "byteorder", "bytes 1.5.0", - "cocoa", "collections", "core-foundation", - "core-graphics 0.22.3", "foreign-types 0.3.2", "futures 0.3.28", "gpui", @@ -3997,7 +3995,6 @@ dependencies = [ "log", "media", "nanoid", - "objc", "parking_lot 0.11.2", "postage", "serde", diff --git a/crates/live_kit_client/Cargo.toml b/crates/live_kit_client/Cargo.toml index 6582a213d97d70..8eb79c3a8992ee 100644 --- a/crates/live_kit_client/Cargo.toml +++ b/crates/live_kit_client/Cargo.toml @@ -41,7 +41,6 @@ nanoid = { version ="0.4", optional = true} [target.'cfg(target_os = "macos")'.dependencies] core-foundation = "0.9.3" -core-graphics = "0.22.3" [dev-dependencies] collections = { path = "../collections", features = ["test-support"] } @@ -65,11 +64,6 @@ serde_derive.workspace = true sha2 = "0.10" simplelog = "0.9" - -[target.'cfg(target_os = "macos")'.dev-dependencies] -cocoa = "0.25" -objc = "0.2" - [build-dependencies] serde.workspace = true serde_derive.workspace = true