Skip to content

Commit

Permalink
Add remote server cross compilation (#19136)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mikayla-maki authored Oct 13, 2024
1 parent f73a076 commit bebe24e
Show file tree
Hide file tree
Showing 23 changed files with 540 additions and 159 deletions.
31 changes: 30 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ jobs:
run: cargo build -p collab

- name: Build other binaries and features
run: cargo build --workspace --bins --all-features; cargo check -p gpui --features "macos-blade"
run: |
cargo build --workspace --bins --all-features
cargo check -p gpui --features "macos-blade"
cargo build -p remote_server
linux_tests:
timeout-minutes: 60
Expand Down Expand Up @@ -133,6 +136,32 @@ jobs:
- name: Build Zed
run: cargo build -p zed

build_remote_server:
timeout-minutes: 60
name: (Linux) Build Remote Server
runs-on:
- buildjet-16vcpu-ubuntu-2204
steps:
- name: Add Rust to the PATH
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Checkout repo
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
with:
clean: false

- name: Cache dependencies
uses: swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-provider: "buildjet"

- name: Install Clang & Mold
run: ./script/remote-server && ./script/install-mold 2.34.0

- name: Build Remote Server
run: cargo build -p remote_server

# todo(windows): Actually run the tests
windows_tests:
timeout-minutes: 60
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ git = { path = "crates/git" }
git_hosting_providers = { path = "crates/git_hosting_providers" }
go_to_line = { path = "crates/go_to_line" }
google_ai = { path = "crates/google_ai" }
gpui = { path = "crates/gpui" }
gpui = { path = "crates/gpui", default-features = false, features = ["http_client"]}
gpui_macros = { path = "crates/gpui_macros" }
headless = { path = "crates/headless" }
html_to_markdown = { path = "crates/html_to_markdown" }
Expand Down Expand Up @@ -477,6 +477,7 @@ wasmtime = { version = "24", default-features = false, features = [
wasmtime-wasi = "24"
which = "6.0.0"
wit-component = "0.201"
zstd = "0.11"

[workspace.dependencies.async-stripe]
git = "https://github.com/zed-industries/async-stripe"
Expand Down
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
dockerfile = "Dockerfile-cross"
17 changes: 17 additions & 0 deletions Dockerfile-cross
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1

ARG CROSS_BASE_IMAGE
FROM ${CROSS_BASE_IMAGE}
WORKDIR /app
ARG TZ=Etc/UTC \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
DEBIAN_FRONTEND=noninteractive
ENV CARGO_TERM_COLOR=always

COPY script/install-mold script/
RUN ./script/install-mold "2.34.0"
COPY script/remote-server script/
RUN ./script/remote-server

COPY . .
16 changes: 16 additions & 0 deletions Dockerfile-cross.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git
.github
**/.gitignore
**/.gitkeep
.gitattributes
.mailmap
**/target
zed.xcworkspace
.DS_Store
compose.yml
plugins/bin
script/node_modules
styles/node_modules
crates/collab/static/styles.css
vendor/bin
assets/themes/
1 change: 1 addition & 0 deletions crates/auto_update/src/auto_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ impl AutoUpdater {
smol::fs::create_dir_all(&platform_dir).await.ok();

let client = this.read_with(cx, |this, _| this.http_client.clone())?;

if smol::fs::metadata(&version_path).await.is_err() {
log::info!("downloading zed-remote-server {os} {arch}");
download_remote_server_binary(&version_path, release, client, cx).await?;
Expand Down
109 changes: 81 additions & 28 deletions crates/gpui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,53 @@ license = "Apache-2.0"
workspace = true

[features]
default = ["http_client"]
default = ["http_client", "font-kit", "wayland", "x11"]
test-support = [
"backtrace",
"collections/test-support",
"rand",
"util/test-support",
"http_client?/test-support",
"wayland",
"x11",
]
runtime_shaders = []
macos-blade = ["blade-graphics", "blade-macros", "blade-util", "bytemuck"]
wayland = [
"blade-graphics",
"blade-macros",
"blade-util",
"bytemuck",
"ashpd",
"cosmic-text",
"font-kit",
"calloop-wayland-source",
"wayland-backend",
"wayland-client",
"wayland-cursor",
"wayland-protocols",
"wayland-protocols-plasma",
"filedescriptor",
"xkbcommon",
"open",
]
x11 = [
"blade-graphics",
"blade-macros",
"blade-util",
"bytemuck",
"ashpd",
"cosmic-text",
"font-kit",
"as-raw-xcb-connection",
"x11rb",
"xkbcommon",
"xim",
"x11-clipboard",
"filedescriptor",
"open",
]


[lib]
path = "src/gpui.rs"
Expand Down Expand Up @@ -95,7 +132,7 @@ core-foundation.workspace = true
core-foundation-sys = "0.8"
core-graphics = "0.23"
core-text = "20.1"
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "40391b7" }
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "40391b7", optional = true}
foreign-types = "0.5"
log.workspace = true
media.workspace = true
Expand All @@ -105,31 +142,45 @@ objc = "0.2"
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
pathfinder_geometry = "0.5"

[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
blade-graphics.workspace = true
blade-macros.workspace = true
blade-util.workspace = true
bytemuck = "1"
[target.'cfg(target_os = "linux")'.dependencies]
# Always used
flume = "0.11"
oo7 = "0.3.0"

[target.'cfg(target_os = "linux")'.dependencies]
as-raw-xcb-connection = "1"
ashpd.workspace = true
calloop = "0.13.0"
calloop-wayland-source = "0.3.0"
cosmic-text = { git = "https://github.com/pop-os/cosmic-text", rev = "542b20c" }
wayland-backend = { version = "0.3.3", features = ["client_system", "dlopen"] }
wayland-client = { version = "0.31.2" }
wayland-cursor = "0.31.1"
# Used in both windowing options
ashpd = { workspace = true, optional = true }
blade-graphics = { workspace = true, optional = true }
blade-macros = { workspace = true, optional = true }
blade-util = { workspace = true, optional = true }
bytemuck = { version = "1", optional = true }
cosmic-text = { git = "https://github.com/pop-os/cosmic-text", rev = "542b20c", optional = true }
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "40391b7", features = [
"source-fontconfig-dlopen",
], optional = true }
calloop = { version = "0.13.0" }
filedescriptor = { version = "0.8.2", optional = true }
open = { version = "5.2.0", optional = true }

# Wayland
calloop-wayland-source = { version = "0.3.0", optional = true }
wayland-backend = { version = "0.3.3", features = [
"client_system",
"dlopen",
], optional = true }
wayland-client = { version = "0.31.2", optional = true }
wayland-cursor = { version = "0.31.1", optional = true }
wayland-protocols = { version = "0.31.2", features = [
"client",
"staging",
"unstable",
] }
wayland-protocols-plasma = { version = "0.2.0", features = ["client"] }
oo7 = "0.3.0"
open = "5.2.0"
filedescriptor = "0.8.2"
], optional = true }
wayland-protocols-plasma = { version = "0.2.0", features = [
"client",
], optional = true }


# X11
as-raw-xcb-connection = { version = "1", optional = true }
x11rb = { version = "0.13.0", features = [
"allow-unsafe-code",
"xkb",
Expand All @@ -138,21 +189,23 @@ x11rb = { version = "0.13.0", features = [
"cursor",
"resource_manager",
"sync",
] }
], optional = true }
xkbcommon = { git = "https://github.com/ConradIrwin/xkbcommon-rs", rev = "fcbb4612185cc129ceeff51d22f7fb51810a03b2", features = [
"wayland",
"x11",
] }
], optional = true }
xim = { git = "https://github.com/XDeme1/xim-rs", rev = "d50d461764c2213655cd9cf65a0ea94c70d3c4fd", features = [
"x11rb-xcb",
"x11rb-client",
] }
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "40391b7", features = [
"source-fontconfig-dlopen",
] }
x11-clipboard = "0.9.2"
], optional = true }
x11-clipboard = { version = "0.9.2", optional = true }

[target.'cfg(windows)'.dependencies]
blade-util.workspace = true
bytemuck = "1"
blade-graphics.workspace = true
blade-macros.workspace = true
flume = "0.11"
rand.workspace = true
windows.workspace = true
windows-core = "0.58"
Expand Down
Loading

0 comments on commit bebe24e

Please sign in to comment.