diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index b1600c043..bc0d4f00f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: # X11, software Mesa Vulkan (lavapipe) and xvfb. sudo apt-get install -y \ cmake \ + libopencolorio-dev \ libpipewire-0.3-dev libspa-0.2-dev libjack-jackd2-dev \ libasound2-dev libpulse-dev libsndfile1-dev \ libgl1-mesa-dev libgl1-mesa-dri mesa-vulkan-drivers \ @@ -52,13 +53,12 @@ jobs: # ocio-sys builds a stub bridge unless these are set; the oak-common # ocioutils tests need the real library (see crates/oak-common/.cargo/ # config.toml, which only applies to builds run from that directory). - # ocio-sys builds its vendored OpenColorIO from source on Linux (the - # `bundled` feature; the distro package is too old for the bridge), - # so no OCIO_INSTALL_DIR here. + # tooling/ocio-env.sh picks a system OCIO >= 2.5 when present + # (vendored 2.5.2 fails on GCC >= 16) and otherwise falls back to + # the vendored static build. - name: Configure build environment run: | - echo "OCIO_RS_ENABLE_REAL=1" >> "$GITHUB_ENV" - echo "OCIO_RS_LINK=static" >> "$GITHUB_ENV" + tooling/ocio-env.sh >> "$GITHUB_ENV" echo "RUSTUP_HOME=/opt/rust/rustup" >> "$GITHUB_ENV" echo "CARGO_HOME=/opt/rust/cargo" >> "$GITHUB_ENV" echo "PATH=$PATH:/opt/rust/cargo/bin" >> "$GITHUB_ENV" @@ -96,8 +96,11 @@ jobs: # ------------------------------------------------------------------ # Build & test # ------------------------------------------------------------------ + # `cargo check` (not build): the Test step links the test binaries + # anyway, and a full build would codegen every workspace crate twice + # (once without and once with cfg(test)). - name: Build - run: cargo build --workspace --locked + run: cargo check --workspace --locked # xvfb + 24-bit screen: the gpui #[gpui::test] tests open real windows # and render through wgpu on Mesa's software Vulkan (lavapipe). @@ -224,6 +227,8 @@ jobs: pacman -S --needed --noconfirm \ mingw-w64-ucrt-x86_64-cmake \ mingw-w64-ucrt-x86_64-opencolorio \ + mingw-w64-ucrt-x86_64-ffnvcodec-headers \ + mingw-w64-ucrt-x86_64-pkgconf \ mingw-w64-ucrt-x86_64-clang mingw-w64-ucrt-x86_64-clang-libs git # ------------------------------------------------------------------ @@ -236,9 +241,10 @@ jobs: run: | cd "$GITHUB_WORKSPACE" export PATH="/ucrt64/bin:$PATH" - echo "OCIO_RS_ENABLE_REAL=1" >> "$GITHUB_ENV" - echo "OCIO_INSTALL_DIR=/ucrt64" >> "$GITHUB_ENV" - echo "OCIO_RS_LINK=dynamic" >> "$GITHUB_ENV" + # System OCIO (MSYS2, the exact 2.5.2 the bridge targets); + # tooling/ocio-env.sh links it STATICALLY when the package ships + # libOpenColorIO.a, dynamically otherwise. + tooling/ocio-env.sh >> "$GITHUB_ENV" echo "FFMPEG_DIR=.cache/ffmpeg" >> "$GITHUB_ENV" # ocio-sys' build.rs force-adds the MSVC + Windows SDK include # dirs on Windows (meant for MSVC hosts); with the GNU toolchain @@ -292,6 +298,9 @@ jobs: # ------------------------------------------------------------------ # Build & test # ------------------------------------------------------------------ + # `cargo check` (not build): the Test step links the test binaries + # anyway, and a full build would codegen every workspace crate twice + # (once without and once with cfg(test)). - name: Build run: | cd "$GITHUB_WORKSPACE" @@ -306,7 +315,7 @@ jobs: # __imp___msvcrt_assert unresolved. A trailing -lmsvcrt re-scans # the CRT import lib after libmingwex. # export RUSTFLAGS="-C link-args=-lmsvcrt" - cargo build --workspace --locked + cargo check --workspace --locked - name: Test run: | diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index bd34deda2..84dee6a09 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -69,7 +69,7 @@ jobs: libasound2-dev libpulse-dev libsndfile1-dev \ libgl1-mesa-dev libgl1-mesa-dri mesa-vulkan-drivers \ libvulkan-dev libxkbcommon-dev libxkbcommon-x11-dev \ - librsvg2-bin + librsvg2-bin libffnvcodec-dev libopencolorio-dev ;; fedora) dnf install -y \ @@ -79,23 +79,29 @@ jobs: mesa-libGL-devel mesa-vulkan-drivers \ vulkan-headers vulkan-loader-devel \ libxkbcommon-devel libxkbcommon-x11-devel \ - rpm-build librsvg2-tools + rpm-build librsvg2-tools OpenColorIO-devel + # ffnvcodec headers (NVDEC for the project FFmpeg build) are + # not in Fedora's base repos (RPM Fusion only); they are + # distribution-free headers, so install them from source. + git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git /tmp/nv-codec-headers + make -C /tmp/nv-codec-headers install PREFIX=/usr ;; arch) pacman -S --needed --noconfirm \ base-devel cmake pkgconf nasm \ pipewire jack2 alsa-lib libpulse libsndfile \ mesa vulkan-headers vulkan-icd-loader \ - libxkbcommon libxkbcommon-x11 librsvg + libxkbcommon libxkbcommon-x11 librsvg \ + ffnvcodec-headers opencolorio ;; esac - name: Configure build environment run: | - # OCIO builds from the ocio-sys vendored source (static) on - # Linux; the distro packages are too old for the bridge. - echo "OCIO_RS_ENABLE_REAL=1" >> "$GITHUB_ENV" - echo "OCIO_RS_LINK=static" >> "$GITHUB_ENV" + # tooling/ocio-env.sh: use a system OCIO >= 2.5 when present + # (vendored 2.5.2 fails on GCC >= 16), static when the package + # ships libOpenColorIO.a; otherwise the vendored static build. + tooling/ocio-env.sh >> "$GITHUB_ENV" # TEMP: cache disabled until the Gitea instance cache is provisioned (Cache cargo artifacts) # uses: Swatinem/rust-cache@v2 @@ -165,12 +171,11 @@ jobs: libpipewire-0.3-dev libspa-0.2-dev libjack-jackd2-dev \ libasound2-dev libpulse-dev libsndfile1-dev \ libgl1-mesa-dev libgl1-mesa-dri mesa-vulkan-drivers \ - libvulkan-dev libxkbcommon-dev libxkbcommon-x11-dev + libvulkan-dev libxkbcommon-dev libxkbcommon-x11-dev \ + libffnvcodec-dev libopencolorio-dev - name: Configure build environment - run: | - echo "OCIO_RS_ENABLE_REAL=1" >> "$GITHUB_ENV" - echo "OCIO_RS_LINK=static" >> "$GITHUB_ENV" + run: tooling/ocio-env.sh >> "$GITHUB_ENV" # TEMP: cache disabled until the Gitea instance cache is provisioned (Cache cargo artifacts) # uses: Swatinem/rust-cache@v2 @@ -339,16 +344,17 @@ jobs: pacman -S --needed --noconfirm \ mingw-w64-ucrt-x86_64-cmake \ mingw-w64-ucrt-x86_64-opencolorio \ - mingw-w64-ucrt-x86_64-librsvg + mingw-w64-ucrt-x86_64-librsvg \ + mingw-w64-ucrt-x86_64-ffnvcodec-headers \ + mingw-w64-ucrt-x86_64-pkgconf - name: Configure build environment run: | - # Windows uses the MSYS2 OpenColorIO package (the exact 2.5.2 the - # bridge targets; the vendored source needs MSVC-only constructs). - # Dynamic; the DLLs are packaged next to the binaries. - echo "OCIO_RS_ENABLE_REAL=1" >> "$GITHUB_ENV" - echo "OCIO_INSTALL_DIR=/ucrt64" >> "$GITHUB_ENV" - echo "OCIO_RS_LINK=dynamic" >> "$GITHUB_ENV" + # System OCIO (MSYS2, the exact 2.5.2 the bridge targets); + # tooling/ocio-env.sh links it STATICALLY when the package ships + # libOpenColorIO.a, dynamically otherwise (the DLL bundling step + # below then still applies). + tooling/ocio-env.sh >> "$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 diff --git a/Cargo.lock b/Cargo.lock index 072fef9cd..373e817d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5208,11 +5208,11 @@ dependencies = [ [[package]] name = "ocio-sys" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e63251d72d848de5eda39d59cd6490260cf031738ebd518ea37d76b5aae614ec" +source = "git+https://github.com/shaloong/ocio-rs.git#933c65dc4e8e4e22767174f0e22b07fe7af42e07" dependencies = [ "cc", "cmake", + "system-deps", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e2f616e6b..c2c998e2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,3 +67,9 @@ debug-assertions = false [profile.dev] opt-level = 1 + +# ocio-sys 0.2.1's vendored yaml-cpp misses and fails to build on +# GCC >= 16; the fork carries exactly that fix (d39c509) until a fixed +# release lands on crates.io. +[patch.crates-io] +ocio-sys = { git = "https://github.com/shaloong/ocio-rs.git" } diff --git a/tooling/install-deps.sh b/tooling/install-deps.sh index 22202ab63..9ee66978f 100755 --- a/tooling/install-deps.sh +++ b/tooling/install-deps.sh @@ -78,7 +78,8 @@ case "$(uname -s)" in libopenh264-dev libopenjp2-7-dev libtheora-dev libwebp-dev \ libmp3lame-dev libopus-dev libvorbis-dev libspeex-dev \ libsnappy-dev libass-dev libfreetype-dev libfribidi-dev \ - libfontconfig-dev libgnutls28-dev + libfontconfig-dev libgnutls28-dev \ + libffnvcodec-dev elif command -v dnf >/dev/null; then run sudo dnf install -y gcc gcc-c++ pkgconf-pkg-config nasm \ x264-devel x265-devel dav1d-devel libvpx-devel \ @@ -90,7 +91,7 @@ case "$(uname -s)" in run sudo pacman -S --needed --noconfirm base-devel pkgconf nasm \ x264 x265 dav1d libvpx openh264 openjpeg2 libtheora libwebp \ lame opus libvorbis speex snappy libass freetype2 fribidi \ - fontconfig gnutls + fontconfig gnutls ffnvcodec-headers else echo "Unsupported Linux distribution (need apt-get, dnf or pacman)." >&2 exit 1 diff --git a/tooling/ocio-env.sh b/tooling/ocio-env.sh new file mode 100644 index 000000000..3c1bb59a7 --- /dev/null +++ b/tooling/ocio-env.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +# Oak Video Editor - Non-Linear Video Editor +# Copyright (C) 2026 Oak Team +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Print the OpenColorIO build environment for cargo, one VAR=value per +# line — append to $GITHUB_ENV in CI/CD (`tooling/ocio-env.sh >> "$GITHUB_ENV"`) +# or eval locally. +# +# Policy: +# 1. Prefer a SYSTEM OpenColorIO >= 2.5 (the bridge's API floor). The +# vendored 2.5.2 source build FAILS on GCC >= 16 — its bundled +# yaml-cpp relied on stdint.h being included transitively, which +# GCC 16 no longer does (measured: yaml-cpp emitterutils.cpp). +# Link the system OCIO STATICALLY when the package ships +# libOpenColorIO.a (e.g. MSYS2); distro packages that only ship the +# shared object (Arch, Debian, Fedora) leave dynamic as the only +# way to use the prebuilt library. +# 2. With no suitable system OCIO (too old or absent), fall back to +# the vendored-source static build (ocio-sys `bundled`, no +# OCIO_INSTALL_DIR) — which needs GCC < 16. +# +# Pre-set OCIO_RS_LINK / OCIO_INSTALL_DIR are honored, never clobbered. + +set -euo pipefail + +if [ -n "${OCIO_RS_LINK:-}" ]; then + # The caller already chose a link mode; only make sure the real + # bridge (not the stub) is on. + echo "OCIO_RS_ENABLE_REAL=1" + exit 0 +fi + +echo "OCIO_RS_ENABLE_REAL=1" + +if pkg-config --exists 'OpenColorIO >= 2.5' 2>/dev/null; then + libdir=$(pkg-config --variable=libdir OpenColorIO) + prefix=$(pkg-config --variable=prefix OpenColorIO) + link=dynamic + for dir in "$libdir" "$prefix/lib" "$prefix"; do + if [ -f "$dir/libOpenColorIO.a" ]; then + link=static + break + fi + done + echo "OCIO_INSTALL_DIR=$prefix" + echo "OCIO_RS_LINK=$link" + exit 0 +fi + +# No usable system OCIO: vendored-source static build (needs GCC < 16). +echo "OCIO_RS_LINK=static" diff --git a/tooling/package/PKGBUILD b/tooling/package/PKGBUILD index 384a9742e..46e15f76d 100644 --- a/tooling/package/PKGBUILD +++ b/tooling/package/PKGBUILD @@ -16,7 +16,9 @@ # Arch package build. The release binaries are built by the caller # (tooling/package/build-pkg.sh) before makepkg runs; depends lists the -# base-OS packages the binaries link (FFmpeg/OCIO are statically linked). +# base-OS packages the binaries link (FFmpeg is statically linked; OCIO is +# static when built from the vendored source, and build-pkg.sh appends +# 'opencolorio' when the binaries link the system OCIO dynamically). pkgname=oak-editor pkgver=@VERSION@ pkgrel=1 diff --git a/tooling/package/build-pkg.sh b/tooling/package/build-pkg.sh index 7f59f5dd9..8e39dd81f 100755 --- a/tooling/package/build-pkg.sh +++ b/tooling/package/build-pkg.sh @@ -27,6 +27,12 @@ rm -rf "$WORK" mkdir -p "$WORK" sed "s/@VERSION@/$VERSION/" tooling/package/PKGBUILD > "$WORK/PKGBUILD" +# OCIO is linked dynamically whenever the build used the system package +# (Arch ships no static libOpenColorIO); declare the dependency then. +if ldd target/release/oak-editor 2>/dev/null | grep -q libOpenColorIO; then + sed -i "s/'fontconfig' 'freetype2')/'fontconfig' 'freetype2' 'opencolorio')/" "$WORK/PKGBUILD" +fi + if [ "$(id -u)" = "0" ]; then useradd -m builder 2>/dev/null || true chown -R builder:builder "$WORK" target/release