From 13b1799c7189942f0b56827af5936fded0747aec Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Fri, 21 Aug 2026 04:25:43 +0800 Subject: [PATCH] ci: resolve CARGO_HOME via cygpath for the ocio-sys patch; gate screenshot example to macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rust-toolchain sets CARGO_HOME to the Windows userprofile path while the msys2 shell's HOME is elsewhere — the yaml-cpp patch targeted an empty directory and the assertion ls failed - examples/screenshot.rs uses the macOS-only VisualTestAppContext; its items are now cfg-gated with a non-macOS stub main so workspace test builds pass on Linux/Windows --- .github/workflows/cd.yml | 11 +++++++---- .github/workflows/ci.yml | 11 +++++++---- examples/screenshot.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2e4a10ad8..7906edaa7 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -294,20 +294,23 @@ jobs: # registry src dir may not exist yet on a fresh runner — create # it from the cache dir's hash. The trailing ls asserts the # patched file actually exists. + # rust-toolchain sets CARGO_HOME to the WINDOWS userprofile + # path ($USERPROFILE\.cargo), not the msys2 $HOME — resolve it. + CH=$(cygpath -u "${CARGO_HOME:-$HOME/.cargo}") cargo fetch --locked - for cache in "$HOME"/.cargo/registry/cache/*/; do - src="$HOME/.cargo/registry/src/$(basename "$cache")" + for cache in "$CH"/registry/cache/*/; do + src="$CH/registry/src/$(basename "$cache")" mkdir -p "$src" if [ -f "$cache/ocio-sys-0.2.1.crate" ]; then tar xzf "$cache/ocio-sys-0.2.1.crate" -C "$src" fi done - for f in "$HOME"/.cargo/registry/src/*/ocio-sys-0.2.1/vendor/OpenColorIO/ext/ocio-rs-deps/yaml-cpp/src/emitterutils.cpp; do + for f in "$CH"/registry/src/*/ocio-sys-0.2.1/vendor/OpenColorIO/ext/ocio-rs-deps/yaml-cpp/src/emitterutils.cpp; do [ -e "$f" ] || continue grep -q '#include ' "$f" || \ sed -i '0,/#include/s||#include \n&|' "$f" done - ls "$HOME"/.cargo/registry/src/*/ocio-sys-0.2.1/vendor/OpenColorIO/ext/ocio-rs-deps/yaml-cpp/src/emitterutils.cpp + ls "$CH"/registry/src/*/ocio-sys-0.2.1/vendor/OpenColorIO/ext/ocio-rs-deps/yaml-cpp/src/emitterutils.cpp - name: Cache cargo artifacts uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a76502e3..5302bbf6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -130,20 +130,23 @@ jobs: # registry src dir may not exist yet on a fresh runner — create # it from the cache dir's hash. The trailing ls asserts the # patched file actually exists. + # rust-toolchain sets CARGO_HOME to the WINDOWS userprofile + # path ($USERPROFILE\.cargo), not the msys2 $HOME — resolve it. + CH=$(cygpath -u "${CARGO_HOME:-$HOME/.cargo}") cargo fetch --locked - for cache in "$HOME"/.cargo/registry/cache/*/; do - src="$HOME/.cargo/registry/src/$(basename "$cache")" + for cache in "$CH"/registry/cache/*/; do + src="$CH/registry/src/$(basename "$cache")" mkdir -p "$src" if [ -f "$cache/ocio-sys-0.2.1.crate" ]; then tar xzf "$cache/ocio-sys-0.2.1.crate" -C "$src" fi done - for f in "$HOME"/.cargo/registry/src/*/ocio-sys-0.2.1/vendor/OpenColorIO/ext/ocio-rs-deps/yaml-cpp/src/emitterutils.cpp; do + for f in "$CH"/registry/src/*/ocio-sys-0.2.1/vendor/OpenColorIO/ext/ocio-rs-deps/yaml-cpp/src/emitterutils.cpp; do [ -e "$f" ] || continue grep -q '#include ' "$f" || \ sed -i '0,/#include/s||#include \n&|' "$f" done - ls "$HOME"/.cargo/registry/src/*/ocio-sys-0.2.1/vendor/OpenColorIO/ext/ocio-rs-deps/yaml-cpp/src/emitterutils.cpp + ls "$CH"/registry/src/*/ocio-sys-0.2.1/vendor/OpenColorIO/ext/ocio-rs-deps/yaml-cpp/src/emitterutils.cpp # ------------------------------------------------------------------ # Caches diff --git a/examples/screenshot.rs b/examples/screenshot.rs index 7c86f53fd..b5235be40 100644 --- a/examples/screenshot.rs +++ b/examples/screenshot.rs @@ -38,19 +38,32 @@ //! cargo run --example screenshot -- 1100 900 # any size (same filenames) //! ``` +#[cfg(target_os = "macos")] use gpui::{px, size, AnyWindowHandle, AppContext, Entity, Result, VisualTestAppContext}; +#[cfg(target_os = "macos")] use gpui_platform::current_platform; +#[cfg(target_os = "macos")] use oakapp::app::OakApp; +#[cfg(target_os = "macos")] use oakapp::i18n::{self, Language}; +#[cfg(target_os = "macos")] use oakapp::oakui::MockEngine; +#[cfg(target_os = "macos")] const DEFAULT_WIDTH: f32 = 1600.0; +#[cfg(target_os = "macos")] const DEFAULT_HEIGHT: f32 = 900.0; +#[cfg(target_os = "macos")] const OUT_ZH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/docs/screenshot-window.png"); +#[cfg(target_os = "macos")] const OUT_EN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/docs/screenshot-window-en.png"); +#[cfg(target_os = "macos")] const OUT_MGR_ZH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/docs/screenshot-manager.png"); +#[cfg(target_os = "macos")] const OUT_MGR_EN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/docs/screenshot-manager-en.png"); +#[cfg(target_os = "macos")] const OUT_PREF_ZH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/docs/screenshot-preferences.png"); +#[cfg(target_os = "macos")] const OUT_PREF_EN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/docs/screenshot-preferences-en.png"); /// Logical y of the timeline toolbar row, which sits at the top of the @@ -59,9 +72,12 @@ const OUT_PREF_EN: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/docs/screenshot- /// split handle separates them from the timeline. The toolbar is its 31px /// first row. The assertion scans a small band around it so minor layout /// drift does not false-negative. +#[cfg(target_os = "macos")] const TOOLBAR_Y: f32 = 541.0; +#[cfg(target_os = "macos")] const TOOLBAR_BAND: f32 = 44.0; +#[cfg(target_os = "macos")] fn main() -> Result<()> { let args: Vec = std::env::args().skip(1).collect(); let width = args @@ -111,6 +127,7 @@ fn main() -> Result<()> { /// [`settle`]). Returns the typed window handle and the root entity so the /// caller can still drive the shell (the manager capture) after the plain /// screenshot. +#[cfg(target_os = "macos")] fn open_shell( cx: &mut VisualTestAppContext, width: f32, @@ -139,6 +156,7 @@ fn open_shell( /// known, the viewers upload their first CPU frame, and the PNG toolbar /// icons load through the background executor on the frame after the asset /// future resolves. +#[cfg(target_os = "macos")] fn settle(cx: &mut VisualTestAppContext, handle: AnyWindowHandle) { for _ in 0..16 { cx.run_until_parked(); @@ -164,6 +182,7 @@ fn settle(cx: &mut VisualTestAppContext, handle: AnyWindowHandle) { /// project / audio). Drives the root ENTITY (not the window handle — see /// [`capture_manager`]). The dialog closes afterwards so the manager /// capture starts from a clean shell. +#[cfg(target_os = "macos")] fn capture_preferences( cx: &mut VisualTestAppContext, handle: gpui::WindowHandle>, @@ -185,6 +204,7 @@ fn capture_preferences( /// modal card lists the mock library with its per-project stats. Drives the /// root ENTITY (not the window handle — a window update borrows the window, /// and building the modal inside it would re-enter it). +#[cfg(target_os = "macos")] fn capture_manager( cx: &mut VisualTestAppContext, handle: gpui::WindowHandle>, @@ -203,6 +223,7 @@ fn capture_manager( /// render: the toolbar is the 31px row at the top of the bottom dock panel. /// Scan the tool cells for bright glyph pixels, so a broken icon load fails /// the capture loudly instead of shipping an empty toolbar. +#[cfg(target_os = "macos")] fn assert_toolbar(image: &image::RgbaImage, language: &str) { // The image is 2× the logical size; convert logical → pixel y. TOOLBAR_Y // is measured from the window's top edge. @@ -232,3 +253,8 @@ fn assert_toolbar(image: &image::RgbaImage, language: &str) { "{language} timeline toolbar icons did not render (only {rendered}/8 tool cells had pixels)" ); } + +#[cfg(not(target_os = "macos"))] +fn main() { + eprintln!("the screenshot example is macOS-only (offscreen Metal rendering)"); +}