Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

feat(gpui): Allow building gpui against ohos (#64579)

richerfu484bcbfea6ec
diff --git a/crates/gpui_platform/Cargo.toml b/crates/gpui_platform/Cargo.toml
index 6245202a714..4520063e897 100644
--- a/crates/gpui_platform/Cargo.toml
+++ b/crates/gpui_platform/Cargo.toml
@@ -65,7 +65,7 @@ gpui_ios.workspace = true
gpui_windows.workspace = true
gpui = { workspace = true, features = ["windows-manifest"] }
-[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
+[target.'cfg(all(any(target_os = "linux", target_os = "freebsd"), not(target_env = "ohos")))'.dependencies]
gpui_linux.workspace = true
[target.'cfg(target_os = "linux")'.dependencies]
diff --git a/crates/gpui_platform/src/gpui_platform.rs b/crates/gpui_platform/src/gpui_platform.rs
index 5f328d1bcdd..706caf80db4 100644
--- a/crates/gpui_platform/src/gpui_platform.rs
+++ b/crates/gpui_platform/src/gpui_platform.rs
@@ -29,7 +29,10 @@ pub fn headless() -> gpui::Application {
/// It starts windowed in the process's own environment, or headless if that names no allowed
/// display server. Set another initial mode with [`gpui::Application::with_windowing`], and
/// switch later with [`gpui::App::request_windowing`].
-#[cfg(any(target_os = "linux", target_os = "freebsd"))]
+#[cfg(all(
+ any(target_os = "linux", target_os = "freebsd"),
+ not(target_env = "ohos")
+))]
pub fn linux(allowed_modes: gpui::WindowingModes) -> gpui::Application {
gpui::Application::with_platform(gpui_linux::linux_platform(allowed_modes))
}
@@ -83,7 +86,18 @@ pub fn current_platform(headless: bool) -> Rc<dyn Platform> {
)
}
- #[cfg(any(target_os = "linux", target_os = "freebsd"))]
+ #[cfg(target_env = "ohos")]
+ {
+ let _ = headless;
+ panic!(
+ "gpui_platform does not select an OpenHarmony backend; inject gpui-ohos with Application::with_platform"
+ )
+ }
+
+ #[cfg(all(
+ any(target_os = "linux", target_os = "freebsd"),
+ not(target_env = "ohos")
+ ))]
{
gpui_linux::current_platform(headless)
}