Add remote server cross compilation (#19136)

This will allow us to compile debug builds of the remote-server for a
different architecture than the one we are developing on.

This also adds a CI step for building our remote server with minimal
dependencies.

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2024-10-12 23:23:56 -07:00 committed by GitHub
parent f73a076a63
commit bebe24ea77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 542 additions and 161 deletions

View file

@ -10,7 +10,11 @@ mod linux;
#[cfg(target_os = "macos")]
mod mac;
#[cfg(any(target_os = "linux", target_os = "windows", feature = "macos-blade"))]
#[cfg(any(
all(target_os = "linux", any(feature = "x11", feature = "wayland")),
target_os = "windows",
feature = "macos-blade"
))]
mod blade;
#[cfg(any(test, feature = "test-support"))]
@ -26,7 +30,7 @@ use crate::{
RenderGlyphParams, RenderImage, RenderImageParams, RenderSvgParams, ScaledPixels, Scene,
SharedString, Size, SvgSize, Task, TaskLabel, WindowContext, DEFAULT_WINDOW_SIZE,
};
use anyhow::Result;
use anyhow::{anyhow, Result};
use async_task::Runnable;
use futures::channel::oneshot;
use image::codecs::gif::GifDecoder;
@ -75,8 +79,12 @@ pub(crate) fn current_platform(headless: bool) -> Rc<dyn Platform> {
}
match guess_compositor() {
#[cfg(feature = "wayland")]
"Wayland" => Rc::new(WaylandClient::new()),
#[cfg(feature = "x11")]
"X11" => Rc::new(X11Client::new()),
"Headless" => Rc::new(HeadlessClient::new()),
_ => unreachable!(),
}
@ -90,8 +98,16 @@ pub fn guess_compositor() -> &'static str {
if std::env::var_os("ZED_HEADLESS").is_some() {
return "Headless";
}
#[cfg(feature = "wayland")]
let wayland_display = std::env::var_os("WAYLAND_DISPLAY");
#[cfg(not(feature = "wayland"))]
let wayland_display: Option<std::ffi::OsString> = None;
#[cfg(feature = "x11")]
let x11_display = std::env::var_os("DISPLAY");
#[cfg(not(feature = "x11"))]
let x11_display: Option<std::ffi::OsString> = None;
let use_wayland = wayland_display.is_some_and(|display| !display.is_empty());
let use_x11 = x11_display.is_some_and(|display| !display.is_empty());
@ -426,6 +442,61 @@ pub(crate) trait PlatformTextSystem: Send + Sync {
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout;
}
pub(crate) struct NoopTextSystem;
impl NoopTextSystem {
#[allow(dead_code)]
pub fn new() -> Self {
Self
}
}
impl PlatformTextSystem for NoopTextSystem {
fn add_fonts(&self, _fonts: Vec<Cow<'static, [u8]>>) -> Result<()> {
Ok(())
}
fn all_font_names(&self) -> Vec<String> {
Vec::new()
}
fn font_id(&self, descriptor: &Font) -> Result<FontId> {
Err(anyhow!("No font found for {:?}", descriptor))
}
fn font_metrics(&self, _font_id: FontId) -> FontMetrics {
unimplemented!()
}
fn typographic_bounds(&self, font_id: FontId, _glyph_id: GlyphId) -> Result<Bounds<f32>> {
Err(anyhow!("No font found for {:?}", font_id))
}
fn advance(&self, font_id: FontId, _glyph_id: GlyphId) -> Result<Size<f32>> {
Err(anyhow!("No font found for {:?}", font_id))
}
fn glyph_for_char(&self, _font_id: FontId, _ch: char) -> Option<GlyphId> {
None
}
fn glyph_raster_bounds(&self, params: &RenderGlyphParams) -> Result<Bounds<DevicePixels>> {
Err(anyhow!("No font found for {:?}", params))
}
fn rasterize_glyph(
&self,
params: &RenderGlyphParams,
_raster_bounds: Bounds<DevicePixels>,
) -> Result<(Size<DevicePixels>, Vec<u8>)> {
Err(anyhow!("No font found for {:?}", params))
}
fn layout_line(&self, _text: &str, _font_size: Pixels, _runs: &[FontRun]) -> LineLayout {
unimplemented!()
}
}
#[derive(PartialEq, Eq, Hash, Clone)]
pub(crate) enum AtlasKey {
Glyph(RenderGlyphParams),
@ -434,6 +505,10 @@ pub(crate) enum AtlasKey {
}
impl AtlasKey {
#[cfg_attr(
all(target_os = "linux", not(any(feature = "x11", feature = "wayland"))),
allow(dead_code)
)]
pub(crate) fn texture_kind(&self) -> AtlasTextureKind {
match self {
AtlasKey::Glyph(params) => {
@ -494,6 +569,10 @@ pub(crate) struct AtlasTextureId {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[repr(C)]
#[cfg_attr(
all(target_os = "linux", not(any(feature = "x11", feature = "wayland"))),
allow(dead_code)
)]
pub(crate) enum AtlasTextureKind {
Monochrome = 0,
Polychrome = 1,
@ -521,6 +600,10 @@ pub(crate) struct PlatformInputHandler {
handler: Box<dyn InputHandler>,
}
#[cfg_attr(
all(target_os = "linux", not(any(feature = "x11", feature = "wayland"))),
allow(dead_code)
)]
impl PlatformInputHandler {
pub fn new(cx: AsyncWindowContext, handler: Box<dyn InputHandler>) -> Self {
Self { cx, handler }
@ -728,10 +811,15 @@ pub struct WindowOptions {
/// The variables that can be configured when creating a new window
#[derive(Debug)]
#[cfg_attr(
all(target_os = "linux", not(any(feature = "x11", feature = "wayland"))),
allow(dead_code)
)]
pub(crate) struct WindowParams {
pub bounds: Bounds<Pixels>,
/// The titlebar configuration of the window
#[cfg_attr(feature = "wayland", allow(dead_code))]
pub titlebar: Option<TitlebarOptions>,
/// The kind of window to create
@ -748,6 +836,7 @@ pub(crate) struct WindowParams {
#[cfg_attr(target_os = "linux", allow(dead_code))]
pub show: bool,
#[cfg_attr(feature = "wayland", allow(dead_code))]
pub display_id: Option<DisplayId>,
pub window_min_size: Option<Size<Pixels>>,