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.

Add cross-compilation support from MacOS to Windows (#13382)

SELO7be1ffb9ecdd
diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml
index 409fe5ce590..8f9f3d5a25c 100644
--- a/crates/gpui/Cargo.toml
+++ b/crates/gpui/Cargo.toml
@@ -81,6 +81,9 @@ collections = { workspace = true, features = ["test-support"] }
util = { workspace = true, features = ["test-support"] }
http = { workspace = true, features = ["test-support"] }
+[build-dependencies]
+embed-resource = "2.4"
+
[target.'cfg(target_os = "macos")'.build-dependencies]
bindgen = "0.65.1"
cbindgen = "0.26.0"
@@ -143,9 +146,6 @@ windows.workspace = true
windows-core = "0.57"
clipboard-win = "3.1.1"
-[target.'cfg(windows)'.build-dependencies]
-embed-resource = "2.4"
-
[[example]]
name = "hello_world"
path = "examples/hello_world.rs"
diff --git a/crates/gpui/build.rs b/crates/gpui/build.rs
index 46c55ee278e..0808288e595 100644
--- a/crates/gpui/build.rs
+++ b/crates/gpui/build.rs
@@ -3,18 +3,25 @@
//TODO: consider generating shader code for WGSL
//TODO: deprecate "runtime-shaders" and "macos-blade"
+use std::env;
+
fn main() {
- #[cfg(target_os = "macos")]
- macos::build();
-
- #[cfg(target_os = "windows")]
- {
- let manifest = std::path::Path::new("resources/windows/gpui.manifest.xml");
- let rc_file = std::path::Path::new("resources/windows/gpui.rc");
- println!("cargo:rerun-if-changed={}", manifest.display());
- println!("cargo:rerun-if-changed={}", rc_file.display());
- embed_resource::compile(rc_file, embed_resource::NONE);
- }
+ let target = env::var("CARGO_CFG_TARGET_OS");
+
+ match target.as_deref() {
+ Ok("macos") => {
+ #[cfg(target_os = "macos")]
+ macos::build();
+ }
+ Ok("windows") => {
+ let manifest = std::path::Path::new("resources/windows/gpui.manifest.xml");
+ let rc_file = std::path::Path::new("resources/windows/gpui.rc");
+ println!("cargo:rerun-if-changed={}", manifest.display());
+ println!("cargo:rerun-if-changed={}", rc_file.display());
+ embed_resource::compile(rc_file, embed_resource::NONE);
+ }
+ _ => (),
+ };
}
#[cfg(target_os = "macos")]