diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46e7ab7d51..8a19130324 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -129,8 +129,9 @@ jobs: run: | cargo build --workspace --bins --all-features cargo check -p gpui --features "macos-blade" - cargo check -p workspace --features "livekit-cross-platform" + cargo check -p workspace cargo build -p remote_server + script/check-rust-livekit-macos linux_tests: timeout-minutes: 60 @@ -162,8 +163,10 @@ jobs: - name: Run tests uses: ./.github/actions/run_tests - - name: Build Zed - run: cargo build -p zed + - name: Build other binaries and features + run: | + cargo build -p zed + cargo check -p workspace build_remote_server: timeout-minutes: 60 diff --git a/crates/call/Cargo.toml b/crates/call/Cargo.toml index e7bc8b44a3..9ba10e56ba 100644 --- a/crates/call/Cargo.toml +++ b/crates/call/Cargo.toml @@ -21,8 +21,6 @@ test-support = [ "project/test-support", "util/test-support" ] -livekit-macos = ["livekit_client_macos"] -livekit-cross-platform = ["livekit_client"] [dependencies] anyhow.workspace = true @@ -42,8 +40,12 @@ serde.workspace = true serde_derive.workspace = true settings.workspace = true util.workspace = true -livekit_client_macos = { workspace = true, optional = true } -livekit_client = { workspace = true, optional = true } + +[target.'cfg(target_os = "macos")'.dependencies] +livekit_client_macos = { workspace = true } + +[target.'cfg(not(target_os = "macos"))'.dependencies] +livekit_client = { workspace = true } [dev-dependencies] client = { workspace = true, features = ["test-support"] } diff --git a/crates/call/src/call.rs b/crates/call/src/call.rs index 9fdce4b8ba..5e212d35b7 100644 --- a/crates/call/src/call.rs +++ b/crates/call/src/call.rs @@ -1,41 +1,13 @@ pub mod call_settings; -#[cfg(any( - all(target_os = "macos", feature = "livekit-macos"), - all( - not(target_os = "macos"), - feature = "livekit-macos", - not(feature = "livekit-cross-platform") - ) -))] +#[cfg(target_os = "macos")] mod macos; -#[cfg(any( - all(target_os = "macos", feature = "livekit-macos"), - all( - not(target_os = "macos"), - feature = "livekit-macos", - not(feature = "livekit-cross-platform") - ) -))] +#[cfg(target_os = "macos")] pub use macos::*; -#[cfg(any( - all( - target_os = "macos", - feature = "livekit-cross-platform", - not(feature = "livekit-macos"), - ), - all(not(target_os = "macos"), feature = "livekit-cross-platform"), -))] +#[cfg(not(target_os = "macos"))] mod cross_platform; -#[cfg(any( - all( - target_os = "macos", - feature = "livekit-cross-platform", - not(feature = "livekit-macos"), - ), - all(not(target_os = "macos"), feature = "livekit-cross-platform"), -))] +#[cfg(not(target_os = "macos"))] pub use cross_platform::*; diff --git a/crates/workspace/Cargo.toml b/crates/workspace/Cargo.toml index be2dfb06bd..3b17ed8dab 100644 --- a/crates/workspace/Cargo.toml +++ b/crates/workspace/Cargo.toml @@ -24,8 +24,6 @@ test-support = [ "gpui/test-support", "fs/test-support", ] -livekit-macos = ["call/livekit-macos"] -livekit-cross-platform = ["call/livekit-cross-platform"] [dependencies] anyhow.workspace = true diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs index f7a1ccf760..1d17cfa145 100644 --- a/crates/workspace/src/shared_screen.rs +++ b/crates/workspace/src/shared_screen.rs @@ -1,282 +1,11 @@ -#[cfg(any( - all( - target_os = "macos", - feature = "livekit-cross-platform", - not(feature = "livekit-macos"), - ), - all(not(target_os = "macos"), feature = "livekit-cross-platform"), -))] -mod cross_platform { - use crate::{ - item::{Item, ItemEvent}, - ItemNavHistory, WorkspaceId, - }; - use call::{RemoteVideoTrack, RemoteVideoTrackView}; - use client::{proto::PeerId, User}; - use gpui::{ - div, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement, - ParentElement, Render, SharedString, Styled, View, ViewContext, VisualContext, - WindowContext, - }; - use std::sync::Arc; - use ui::{prelude::*, Icon, IconName}; +#[cfg(target_os = "macos")] +mod macos; - pub enum Event { - Close, - } - - pub struct SharedScreen { - pub peer_id: PeerId, - user: Arc, - nav_history: Option, - view: View, - focus: FocusHandle, - } - - impl SharedScreen { - pub fn new( - track: RemoteVideoTrack, - peer_id: PeerId, - user: Arc, - cx: &mut ViewContext, - ) -> Self { - let view = cx.new_view(|cx| RemoteVideoTrackView::new(track.clone(), cx)); - cx.subscribe(&view, |_, _, ev, cx| match ev { - call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close), - }) - .detach(); - Self { - view, - peer_id, - user, - nav_history: Default::default(), - focus: cx.focus_handle(), - } - } - } - - impl EventEmitter for SharedScreen {} - - impl FocusableView for SharedScreen { - fn focus_handle(&self, _: &AppContext) -> FocusHandle { - self.focus.clone() - } - } - impl Render for SharedScreen { - fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { - div() - .bg(cx.theme().colors().editor_background) - .track_focus(&self.focus) - .key_context("SharedScreen") - .size_full() - .child(self.view.clone()) - } - } - - impl Item for SharedScreen { - type Event = Event; - - fn tab_tooltip_text(&self, _: &AppContext) -> Option { - Some(format!("{}'s screen", self.user.github_login).into()) - } - - fn deactivated(&mut self, cx: &mut ViewContext) { - if let Some(nav_history) = self.nav_history.as_mut() { - nav_history.push::<()>(None, cx); - } - } - - fn tab_icon(&self, _cx: &WindowContext) -> Option { - Some(Icon::new(IconName::Screen)) - } - - fn tab_content_text(&self, _cx: &WindowContext) -> Option { - Some(format!("{}'s screen", self.user.github_login).into()) - } - - fn telemetry_event_text(&self) -> Option<&'static str> { - None - } - - fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext) { - self.nav_history = Some(history); - } - - fn clone_on_split( - &self, - _workspace_id: Option, - cx: &mut ViewContext, - ) -> Option> { - Some(cx.new_view(|cx| Self { - view: self.view.update(cx, |view, cx| view.clone(cx)), - peer_id: self.peer_id, - user: self.user.clone(), - nav_history: Default::default(), - focus: cx.focus_handle(), - })) - } - - fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) { - match event { - Event::Close => f(ItemEvent::CloseItem), - } - } - } -} - -#[cfg(any( - all( - target_os = "macos", - feature = "livekit-cross-platform", - not(feature = "livekit-macos"), - ), - all(not(target_os = "macos"), feature = "livekit-cross-platform"), -))] -pub use cross_platform::*; - -#[cfg(any( - all(target_os = "macos", feature = "livekit-macos"), - all( - not(target_os = "macos"), - feature = "livekit-macos", - not(feature = "livekit-cross-platform") - ) -))] -mod macos { - use crate::{ - item::{Item, ItemEvent}, - ItemNavHistory, WorkspaceId, - }; - use anyhow::Result; - use call::participant::{Frame, RemoteVideoTrack}; - use client::{proto::PeerId, User}; - use futures::StreamExt; - use gpui::{ - div, surface, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement, - ParentElement, Render, SharedString, Styled, Task, View, ViewContext, VisualContext, - WindowContext, - }; - use std::sync::{Arc, Weak}; - use ui::{prelude::*, Icon, IconName}; - - pub enum Event { - Close, - } - - pub struct SharedScreen { - track: Weak, - frame: Option, - pub peer_id: PeerId, - user: Arc, - nav_history: Option, - _maintain_frame: Task>, - focus: FocusHandle, - } - - impl SharedScreen { - pub fn new( - track: Arc, - peer_id: PeerId, - user: Arc, - cx: &mut ViewContext, - ) -> Self { - cx.focus_handle(); - let mut frames = track.frames(); - Self { - track: Arc::downgrade(&track), - frame: None, - peer_id, - user, - nav_history: Default::default(), - _maintain_frame: cx.spawn(|this, mut cx| async move { - while let Some(frame) = frames.next().await { - this.update(&mut cx, |this, cx| { - this.frame = Some(frame); - cx.notify(); - })?; - } - this.update(&mut cx, |_, cx| cx.emit(Event::Close))?; - Ok(()) - }), - focus: cx.focus_handle(), - } - } - } - - impl EventEmitter for SharedScreen {} - - impl FocusableView for SharedScreen { - fn focus_handle(&self, _: &AppContext) -> FocusHandle { - self.focus.clone() - } - } - impl Render for SharedScreen { - fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { - div() - .bg(cx.theme().colors().editor_background) - .track_focus(&self.focus) - .key_context("SharedScreen") - .size_full() - .children( - self.frame - .as_ref() - .map(|frame| surface(frame.image()).size_full()), - ) - } - } - - impl Item for SharedScreen { - type Event = Event; - - fn tab_tooltip_text(&self, _: &AppContext) -> Option { - Some(format!("{}'s screen", self.user.github_login).into()) - } - - fn deactivated(&mut self, cx: &mut ViewContext) { - if let Some(nav_history) = self.nav_history.as_mut() { - nav_history.push::<()>(None, cx); - } - } - - fn tab_icon(&self, _cx: &WindowContext) -> Option { - Some(Icon::new(IconName::Screen)) - } - - fn tab_content_text(&self, _cx: &WindowContext) -> Option { - Some(format!("{}'s screen", self.user.github_login).into()) - } - - fn telemetry_event_text(&self) -> Option<&'static str> { - None - } - - fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext) { - self.nav_history = Some(history); - } - - fn clone_on_split( - &self, - _workspace_id: Option, - cx: &mut ViewContext, - ) -> Option> { - let track = self.track.upgrade()?; - Some(cx.new_view(|cx| Self::new(track, self.peer_id, self.user.clone(), cx))) - } - - fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) { - match event { - Event::Close => f(ItemEvent::CloseItem), - } - } - } -} - -#[cfg(any( - all(target_os = "macos", feature = "livekit-macos"), - all( - not(target_os = "macos"), - feature = "livekit-macos", - not(feature = "livekit-cross-platform") - ) -))] +#[cfg(target_os = "macos")] pub use macos::*; + +#[cfg(not(target_os = "macos"))] +mod cross_platform; + +#[cfg(not(target_os = "macos"))] +pub use cross_platform::*; diff --git a/crates/workspace/src/shared_screen/cross_platform.rs b/crates/workspace/src/shared_screen/cross_platform.rs new file mode 100644 index 0000000000..285946cce0 --- /dev/null +++ b/crates/workspace/src/shared_screen/cross_platform.rs @@ -0,0 +1,114 @@ +use crate::{ + item::{Item, ItemEvent}, + ItemNavHistory, WorkspaceId, +}; +use call::{RemoteVideoTrack, RemoteVideoTrackView}; +use client::{proto::PeerId, User}; +use gpui::{ + div, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement, ParentElement, + Render, SharedString, Styled, View, ViewContext, VisualContext, WindowContext, +}; +use std::sync::Arc; +use ui::{prelude::*, Icon, IconName}; + +pub enum Event { + Close, +} + +pub struct SharedScreen { + pub peer_id: PeerId, + user: Arc, + nav_history: Option, + view: View, + focus: FocusHandle, +} + +impl SharedScreen { + pub fn new( + track: RemoteVideoTrack, + peer_id: PeerId, + user: Arc, + cx: &mut ViewContext, + ) -> Self { + let view = cx.new_view(|cx| RemoteVideoTrackView::new(track.clone(), cx)); + cx.subscribe(&view, |_, _, ev, cx| match ev { + call::RemoteVideoTrackViewEvent::Close => cx.emit(Event::Close), + }) + .detach(); + Self { + view, + peer_id, + user, + nav_history: Default::default(), + focus: cx.focus_handle(), + } + } +} + +impl EventEmitter for SharedScreen {} + +impl FocusableView for SharedScreen { + fn focus_handle(&self, _: &AppContext) -> FocusHandle { + self.focus.clone() + } +} +impl Render for SharedScreen { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { + div() + .bg(cx.theme().colors().editor_background) + .track_focus(&self.focus) + .key_context("SharedScreen") + .size_full() + .child(self.view.clone()) + } +} + +impl Item for SharedScreen { + type Event = Event; + + fn tab_tooltip_text(&self, _: &AppContext) -> Option { + Some(format!("{}'s screen", self.user.github_login).into()) + } + + fn deactivated(&mut self, cx: &mut ViewContext) { + if let Some(nav_history) = self.nav_history.as_mut() { + nav_history.push::<()>(None, cx); + } + } + + fn tab_icon(&self, _cx: &WindowContext) -> Option { + Some(Icon::new(IconName::Screen)) + } + + fn tab_content_text(&self, _cx: &WindowContext) -> Option { + Some(format!("{}'s screen", self.user.github_login).into()) + } + + fn telemetry_event_text(&self) -> Option<&'static str> { + None + } + + fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext) { + self.nav_history = Some(history); + } + + fn clone_on_split( + &self, + _workspace_id: Option, + cx: &mut ViewContext, + ) -> Option> { + Some(cx.new_view(|cx| Self { + view: self.view.update(cx, |view, cx| view.clone(cx)), + peer_id: self.peer_id, + user: self.user.clone(), + nav_history: Default::default(), + focus: cx.focus_handle(), + })) + } + + fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) { + match event { + Event::Close => f(ItemEvent::CloseItem), + } + } +} diff --git a/crates/workspace/src/shared_screen/macos.rs b/crates/workspace/src/shared_screen/macos.rs new file mode 100644 index 0000000000..ad0b4c4275 --- /dev/null +++ b/crates/workspace/src/shared_screen/macos.rs @@ -0,0 +1,126 @@ +use crate::{ + item::{Item, ItemEvent}, + ItemNavHistory, WorkspaceId, +}; +use anyhow::Result; +use call::participant::{Frame, RemoteVideoTrack}; +use client::{proto::PeerId, User}; +use futures::StreamExt; +use gpui::{ + div, surface, AppContext, EventEmitter, FocusHandle, FocusableView, InteractiveElement, + ParentElement, Render, SharedString, Styled, Task, View, ViewContext, VisualContext, + WindowContext, +}; +use std::sync::{Arc, Weak}; +use ui::{prelude::*, Icon, IconName}; + +pub enum Event { + Close, +} + +pub struct SharedScreen { + track: Weak, + frame: Option, + pub peer_id: PeerId, + user: Arc, + nav_history: Option, + _maintain_frame: Task>, + focus: FocusHandle, +} + +impl SharedScreen { + pub fn new( + track: Arc, + peer_id: PeerId, + user: Arc, + cx: &mut ViewContext, + ) -> Self { + cx.focus_handle(); + let mut frames = track.frames(); + Self { + track: Arc::downgrade(&track), + frame: None, + peer_id, + user, + nav_history: Default::default(), + _maintain_frame: cx.spawn(|this, mut cx| async move { + while let Some(frame) = frames.next().await { + this.update(&mut cx, |this, cx| { + this.frame = Some(frame); + cx.notify(); + })?; + } + this.update(&mut cx, |_, cx| cx.emit(Event::Close))?; + Ok(()) + }), + focus: cx.focus_handle(), + } + } +} + +impl EventEmitter for SharedScreen {} + +impl FocusableView for SharedScreen { + fn focus_handle(&self, _: &AppContext) -> FocusHandle { + self.focus.clone() + } +} +impl Render for SharedScreen { + fn render(&mut self, cx: &mut ViewContext) -> impl IntoElement { + div() + .bg(cx.theme().colors().editor_background) + .track_focus(&self.focus) + .key_context("SharedScreen") + .size_full() + .children( + self.frame + .as_ref() + .map(|frame| surface(frame.image()).size_full()), + ) + } +} + +impl Item for SharedScreen { + type Event = Event; + + fn tab_tooltip_text(&self, _: &AppContext) -> Option { + Some(format!("{}'s screen", self.user.github_login).into()) + } + + fn deactivated(&mut self, cx: &mut ViewContext) { + if let Some(nav_history) = self.nav_history.as_mut() { + nav_history.push::<()>(None, cx); + } + } + + fn tab_icon(&self, _cx: &WindowContext) -> Option { + Some(Icon::new(IconName::Screen)) + } + + fn tab_content_text(&self, _cx: &WindowContext) -> Option { + Some(format!("{}'s screen", self.user.github_login).into()) + } + + fn telemetry_event_text(&self) -> Option<&'static str> { + None + } + + fn set_nav_history(&mut self, history: ItemNavHistory, _: &mut ViewContext) { + self.nav_history = Some(history); + } + + fn clone_on_split( + &self, + _workspace_id: Option, + cx: &mut ViewContext, + ) -> Option> { + let track = self.track.upgrade()?; + Some(cx.new_view(|cx| Self::new(track, self.peer_id, self.user.clone(), cx))) + } + + fn to_item_events(event: &Self::Event, mut f: impl FnMut(ItemEvent)) { + match event { + Event::Close => f(ItemEvent::CloseItem), + } + } +} diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 9a672757a6..2220cc7be0 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -127,12 +127,6 @@ welcome.workspace = true workspace.workspace = true zed_actions.workspace = true -[target.'cfg(target_os = "macos")'.dependencies] -workspace = { workspace = true, features = ["livekit-macos"] } - -[target.'cfg(not(target_os = "macos"))'.dependencies] -workspace = { workspace = true, features = ["livekit-cross-platform"] } - [target.'cfg(target_os = "windows")'.dependencies] windows.workspace = true diff --git a/script/check-rust-livekit-macos b/script/check-rust-livekit-macos new file mode 100755 index 0000000000..e2d0f9cf62 --- /dev/null +++ b/script/check-rust-livekit-macos @@ -0,0 +1,19 @@ +#!/bin/bash + + +set -exuo pipefail + +git apply script/patches/use-cross-platform-livekit.patch + +# Re-enable error skipping for this check, so that we can unapply the patch +set +e + +cargo check -p workspace +exit_code=$? + +# Disable error skipping again +set -e + +git apply -R script/patches/use-cross-platform-livekit.patch + +exit "$exit_code" diff --git a/script/patches/use-cross-platform-livekit.patch b/script/patches/use-cross-platform-livekit.patch new file mode 100644 index 0000000000..81dcca80f6 --- /dev/null +++ b/script/patches/use-cross-platform-livekit.patch @@ -0,0 +1,59 @@ +diff --git a/crates/call/Cargo.toml b/crates/call/Cargo.toml +index 9ba10e56ba..bb69440691 100644 +--- a/crates/call/Cargo.toml ++++ b/crates/call/Cargo.toml +@@ -41,10 +41,10 @@ serde_derive.workspace = true + settings.workspace = true + util.workspace = true + +-[target.'cfg(target_os = "macos")'.dependencies] ++[target.'cfg(any())'.dependencies] + livekit_client_macos = { workspace = true } + +-[target.'cfg(not(target_os = "macos"))'.dependencies] ++[target.'cfg(all())'.dependencies] + livekit_client = { workspace = true } + + [dev-dependencies] +diff --git a/crates/call/src/call.rs b/crates/call/src/call.rs +index 5e212d35b7..a8f9e8f43e 100644 +--- a/crates/call/src/call.rs ++++ b/crates/call/src/call.rs +@@ -1,13 +1,13 @@ + pub mod call_settings; + +-#[cfg(target_os = "macos")] ++#[cfg(any())] + mod macos; + +-#[cfg(target_os = "macos")] ++#[cfg(any())] + pub use macos::*; + +-#[cfg(not(target_os = "macos"))] ++#[cfg(all())] + mod cross_platform; + +-#[cfg(not(target_os = "macos"))] ++#[cfg(all())] + pub use cross_platform::*; +diff --git a/crates/workspace/src/shared_screen.rs b/crates/workspace/src/shared_screen.rs +index 1d17cfa145..f845234987 100644 +--- a/crates/workspace/src/shared_screen.rs ++++ b/crates/workspace/src/shared_screen.rs +@@ -1,11 +1,11 @@ +-#[cfg(target_os = "macos")] ++#[cfg(any())] + mod macos; + +-#[cfg(target_os = "macos")] ++#[cfg(any())] + pub use macos::*; + +-#[cfg(not(target_os = "macos"))] ++#[cfg(all())] + mod cross_platform; + +-#[cfg(not(target_os = "macos"))] ++#[cfg(all())] + pub use cross_platform::*; diff --git a/typos.toml b/typos.toml index dc724dd50d..50f3aadd0a 100644 --- a/typos.toml +++ b/typos.toml @@ -43,6 +43,8 @@ extend-exclude = [ "docs/theme/css/", # Spellcheck triggers on `|Fixe[sd]|` regex part. "script/danger/dangerfile.ts", + # Hashes are not typos + "script/patches/use-cross-platform-livekit.patch" ] [default]