windows: Move manifest file to gpui (#11036)

This is a follow up of #10810 , `embed-resource` crate uses a different
method to link the manifest file, so this makes moving manifest file to
`gpui` possible.

Now, examples can run as expected:
![Screenshot 2024-04-26
111559](https://github.com/zed-industries/zed/assets/14981363/bb040690-8129-490b-83b3-0a7d3cbd4953)

TODO:
- [ ] check if it builds with gnu toolchain

Release Notes:

- N/A
This commit is contained in:
张小白 2024-04-27 04:56:48 +08:00 committed by GitHub
parent 6a915e349c
commit 268cb948a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 62 additions and 21 deletions

52
Cargo.lock generated
View File

@ -3438,6 +3438,20 @@ dependencies = [
"zeroize",
]
[[package]]
name = "embed-resource"
version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6985554d0688b687c5cb73898a34fbe3ad6c24c58c238a4d91d5e840670ee9d"
dependencies = [
"cc",
"memchr",
"rustc_version",
"toml 0.8.10",
"vswhom",
"winreg 0.52.0",
]
[[package]]
name = "emojis"
version = "0.6.1"
@ -4536,6 +4550,7 @@ dependencies = [
"cosmic-text",
"ctor",
"derive_more",
"embed-resource",
"env_logger",
"etagere",
"filedescriptor",
@ -5959,9 +5974,9 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.6.3"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "memfd"
@ -7970,7 +7985,7 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"winreg",
"winreg 0.50.0",
]
[[package]]
@ -9499,7 +9514,6 @@ dependencies = [
"strum",
"theme",
"ui",
"winresource",
]
[[package]]
@ -11133,6 +11147,26 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64"
[[package]]
name = "vswhom"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b"
dependencies = [
"libc",
"vswhom-sys",
]
[[package]]
name = "vswhom-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "vte"
version = "0.13.0"
@ -12206,6 +12240,16 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "winreg"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"
dependencies = [
"cfg-if",
"windows-sys 0.48.0",
]
[[package]]
name = "winresource"
version = "0.1.17"

View File

@ -120,6 +120,9 @@ xkbcommon = { version = "0.7", features = ["wayland", "x11"] }
[target.'cfg(windows)'.dependencies]
windows.workspace = true
[target.'cfg(windows)'.build-dependencies]
embed-resource = "2.4"
[[example]]
name = "hello_world"
path = "examples/hello_world.rs"

View File

@ -6,6 +6,15 @@
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);
}
}
#[cfg(target_os = "macos")]

View File

@ -0,0 +1,2 @@
#define RT_MANIFEST 24
1 RT_MANIFEST "resources/windows/gpui.manifest.xml"

View File

@ -35,8 +35,5 @@ strum = { version = "0.25.0", features = ["derive"] }
theme.workspace = true
ui = { workspace = true, features = ["stories"] }
[target.'cfg(target_os = "windows")'.build-dependencies]
winresource = "0.1"
[dev-dependencies]
gpui = { workspace = true, features = ["test-support"] }

View File

@ -9,16 +9,5 @@ fn main() {
{
println!("cargo:rustc-link-arg=/stack:{}", 8 * 1024 * 1024);
}
let manifest = std::path::Path::new("../zed/resources/windows/manifest.xml");
println!("cargo:rerun-if-changed={}", manifest.display());
let mut res = winresource::WindowsResource::new();
res.set_manifest_file(manifest.to_str().unwrap());
if let Err(e) = res.compile() {
eprintln!("{}", e);
std::process::exit(1);
}
}
}

View File

@ -52,14 +52,11 @@ fn main() {
println!("cargo:rustc-link-arg=/stack:{}", 8 * 1024 * 1024);
}
let manifest = std::path::Path::new("resources/windows/manifest.xml");
let icon = std::path::Path::new("resources/windows/app-icon.ico");
println!("cargo:rerun-if-changed={}", manifest.display());
println!("cargo:rerun-if-changed={}", icon.display());
let mut res = winresource::WindowsResource::new();
res.set_icon(icon.to_str().unwrap());
res.set_manifest_file(manifest.to_str().unwrap());
if let Err(e) = res.compile() {
eprintln!("{}", e);