richerfu 说明 Zed 的 OpenHarmony 平台适配
richerfu 说明 OpenHarmony 的 Rust target 会误走 Linux 依赖路径,相关 PR 通过 cfg 排除桌面 Linux 依赖并接入 gpui-ohos,同时加入适配 OpenHarmony 的触摸滚动物理。
作者原文@richerfuI'm not sure if I fully understood your point, so I'll do my best to clearly explain what I'm trying to achieve with this PR.
OpenHarmony's Rust target triple is
aarch64-unknown-linux-ohos, whererustcsets bothtarget_os = "linux"andtarget_env = "ohos". We are trying to solve three things here:
- Avoid Linux dependency build errors (
crates/gpui_platform/Cargo.toml):
Becauseaarch64-unknown-linux-ohosalso matchestarget_os = "linux", whenevergpui_platformis pulled into the dependency graph, Cargo enablesgpui_linuxand triggers desktop Linux dependency build scripts (Wayland, X11, system libraries, etc.), which fail to compile on OpenHarmony. Guardinggpui_linuxwithnot(target_env = "ohos")prevents Cargo from pulling in desktop Linux dependencies on OpenHarmony.
- Use our own rendering backend instead of desktop Linux's Wayland/X11 (
crates/gpui_platform/src/gpui_platform.rs):
OpenHarmony's windowing and rendering architecture is much closer to Android and iOS than to desktop Linux (Wayland/X11), so we use our own external backend
(gpui-ohos) viaApplication::with_platform(...).
Oncegpui_linuxis excluded fromCargo.tomlontarget_env = "ohos",gpui_platform::linuxandgpui_platform::current_platformingpui_platform.rs
also need#[cfg]guards sogpui_platformitself still compiles without referencinggpui_linuxor hitting a missing return value error.
- Align touch scroll physics with Android and iOS (
crates/gpui/src/gestures.rs):
OpenHarmony primarily targets mobile/touch devices, so we addedScrollPhysics::ohos()alongsideScrollPhysics::ios()andScrollPhysics::android()to
support OpenHarmony's native touch momentum scrolling curve.