From 74b18ea71a57ee445b4d8b8f0481d316c0f441b7 Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Fri, 21 Aug 2026 07:08:31 +0800 Subject: [PATCH] ci: gate ocio-sys' forced MSVC includes behind OCIO_RS_NO_MSVC_INCLUDES MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The crate's build.rs unconditionally adds the MSVC + Windows SDK include dirs on Windows (for MSVC hosts); on the GNU toolchain that breaks the bridge compile with MSVC-only headers. The runner's job hook re-exports INCLUDE/LIB per step, so the in-step unset did not help — patch the extracted build.rs instead (both the env-var failure modes are now documented in the step comment). --- .github/workflows/cd.yml | 22 +++++++++++++++++----- .github/workflows/ci.yml | 22 +++++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 77829feb6..e58031d75 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -341,11 +341,23 @@ jobs: echo "OCIO_RS_ENABLE_REAL=1" >> "$GITHUB_ENV" echo "OCIO_INSTALL_DIR=/ucrt64" >> "$GITHUB_ENV" echo "OCIO_RS_LINK=dynamic" >> "$GITHUB_ENV" - # The runner image exports the MSVC INCLUDE/LIB; cc-rs appends - # them to the MinGW compile lines and drags in the MSVC SDK - # headers (vcruntime.h) — clear both for the GNU toolchain. - echo "INCLUDE=" >> "$GITHUB_ENV" - echo "LIB=" >> "$GITHUB_ENV" + # ocio-sys' build.rs force-adds the MSVC + Windows SDK include + # dirs on Windows (meant for MSVC hosts); with the GNU toolchain + # that drags MSVC-only headers into the g++ compile. Unpack the + # crate and gate that block behind OCIO_RS_NO_MSVC_INCLUDES. + echo "OCIO_RS_NO_MSVC_INCLUDES=1" >> "$GITHUB_ENV" + CH=$(cygpath -u "${CARGO_HOME:-$HOME/.cargo}") + cargo fetch --locked + for cache in "$CH"/registry/cache/*/; do + src="$CH/registry/src/$(basename "$cache")" + mkdir -p "$src" + [ -f "$cache/ocio-sys-0.2.1.crate" ] && tar xzf "$cache/ocio-sys-0.2.1.crate" -C "$src" + done + BS=$(ls "$CH"/registry/src/*/ocio-sys-0.2.1/build.rs) + grep -q 'OCIO_RS_NO_MSVC_INCLUDES' "$BS" || sed -i \ + 's|if cfg!(target_os = "windows") && has_real_ocio {|if cfg!(target_os = "windows") \&\& has_real_ocio \&\& std::env::var_os("OCIO_RS_NO_MSVC_INCLUDES").is_none() {|' \ + "$BS" + grep -q 'OCIO_RS_NO_MSVC_INCLUDES' "$BS" - name: Cache cargo artifacts uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bdafd5a30..ca113a1e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,11 +125,23 @@ jobs: echo "OCIO_RS_ENABLE_REAL=1" >> "$GITHUB_ENV" echo "OCIO_INSTALL_DIR=/ucrt64" >> "$GITHUB_ENV" echo "OCIO_RS_LINK=dynamic" >> "$GITHUB_ENV" - # The runner image exports the MSVC INCLUDE/LIB; cc-rs appends - # them to the MinGW compile lines and drags in the MSVC SDK - # headers (vcruntime.h) — clear both for the GNU toolchain. - echo "INCLUDE=" >> "$GITHUB_ENV" - echo "LIB=" >> "$GITHUB_ENV" + # ocio-sys' build.rs force-adds the MSVC + Windows SDK include + # dirs on Windows (meant for MSVC hosts); with the GNU toolchain + # that drags MSVC-only headers into the g++ compile. Unpack the + # crate and gate that block behind OCIO_RS_NO_MSVC_INCLUDES. + echo "OCIO_RS_NO_MSVC_INCLUDES=1" >> "$GITHUB_ENV" + CH=$(cygpath -u "${CARGO_HOME:-$HOME/.cargo}") + cargo fetch --locked + for cache in "$CH"/registry/cache/*/; do + src="$CH/registry/src/$(basename "$cache")" + mkdir -p "$src" + [ -f "$cache/ocio-sys-0.2.1.crate" ] && tar xzf "$cache/ocio-sys-0.2.1.crate" -C "$src" + done + BS=$(ls "$CH"/registry/src/*/ocio-sys-0.2.1/build.rs) + grep -q 'OCIO_RS_NO_MSVC_INCLUDES' "$BS" || sed -i \ + 's|if cfg!(target_os = "windows") && has_real_ocio {|if cfg!(target_os = "windows") \&\& has_real_ocio \&\& std::env::var_os("OCIO_RS_NO_MSVC_INCLUDES").is_none() {|' \ + "$BS" + grep -q 'OCIO_RS_NO_MSVC_INCLUDES' "$BS" # ------------------------------------------------------------------ # Caches