Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: Build

on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
workflow_dispatch:

# Cancel an in-flight run when a newer commit lands on the same ref.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
label: linux-x86_64
# macos-13 (Intel) is in GitHub's deprecation window — jobs sit in
# the queue for hours. Apple Silicon only for now; x86_64 Mac users
# build from source.
- os: macos-14
label: macos-arm64
- os: windows-2022
label: windows-x86_64

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

# -------------------------------------------------------------------
# Linux: Intel apt repo for librealsense, plus OpenCV + GLFW system deps.
# -------------------------------------------------------------------
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
ca-certificates curl gnupg lsb-release \
build-essential cmake ninja-build pkg-config \
libopencv-dev \
libgl1-mesa-dev libglu1-mesa-dev \
libxinerama-dev libxcursor-dev libxi-dev libxrandr-dev \
libwayland-dev libxkbcommon-dev \
libusb-1.0-0-dev libudev-dev \
libgtk-3-dev

# Intel RealSense apt repo. The .pgp file Intel hosts on their CDN
# is currently stale relative to the key that actually signs the apt
# InRelease metadata (apt logs "NO_PUBKEY FB0B24895113F120"), so we
# fetch the signing key directly from Ubuntu's keyserver over HTTP
# and dearmor it. (HTTP avoids needing dirmngr + /root/.gnupg, both
# of which were missing on the runner.)
# If this ever stops working, run `apt-get update` against the repo
# locally to find the current key ID and update the fingerprint below.
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xFB0B24895113F120&options=mr" \
| sudo gpg --dearmor -o /etc/apt/keyrings/librealsense.gpg
sudo chmod 0644 /etc/apt/keyrings/librealsense.gpg
echo "deb [signed-by=/etc/apt/keyrings/librealsense.gpg] https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/librealsense.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends librealsense2-dev librealsense2-utils

# -------------------------------------------------------------------
# macOS (Apple Silicon, macos-14). Homebrew handles everything.
# If librealsense's brew formula breaks here, the most likely cause
# is upstream brew formula state.
# -------------------------------------------------------------------
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
set -euxo pipefail
brew update
brew install cmake ninja opencv librealsense

# -------------------------------------------------------------------
# Windows: chocolatey for OpenCV, vcpkg for librealsense.
#
# Why not the Intel SDK installer: current Intel installer versions
# (InstallAware-based) have no working silent-install flag — /S and /s
# hang on a hidden GUI dialog, /silent and /VERYSILENT exit 0 but write
# nothing, and the .exe is not a format 7zip can extract. vcpkg is the
# reliable path. To avoid touching CMakeLists.txt (which hardcodes
# C:\Program Files (x86)\Intel RealSense SDK 2.0\... for Windows), we
# restage vcpkg's output into that same layout.
# -------------------------------------------------------------------
- name: Export GHA cache env (for vcpkg x-gha binary cache)
if: runner.os == 'Windows'
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Install Windows dependencies
if: runner.os == 'Windows'
timeout-minutes: 25
shell: pwsh
env:
VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite'
run: |
$ErrorActionPreference = 'Stop'

Write-Host "Installing OpenCV via chocolatey..."
choco install opencv --version=4.10.0 -y --no-progress
$opencvDir = "C:\tools\opencv\build"
if (-not (Test-Path "$opencvDir\OpenCVConfig.cmake")) {
$opencvDir = Get-ChildItem -Path "C:\tools\opencv" -Recurse -Filter "OpenCVConfig.cmake" | Select-Object -First 1 -ExpandProperty Directory | Select-Object -ExpandProperty FullName
}
"OpenCV_DIR=$opencvDir" | Out-File -FilePath $env:GITHUB_ENV -Append
"$opencvDir\x64\vc16\bin" | Out-File -FilePath $env:GITHUB_PATH -Append

Write-Host "Installing librealsense via vcpkg (first run ~10-15 min, cached runs ~30s)..."
& "C:\vcpkg\vcpkg.exe" install realsense2:x64-windows --triplet=x64-windows
if ($LASTEXITCODE -ne 0) { throw "vcpkg install realsense2:x64-windows failed (exit $LASTEXITCODE)." }

$vcpkgInstalled = "C:\vcpkg\installed\x64-windows"
$vcpkgLib = "$vcpkgInstalled\lib\realsense2.lib"
$vcpkgDll = "$vcpkgInstalled\bin\realsense2.dll"
$vcpkgInc = "$vcpkgInstalled\include\librealsense2"
foreach ($p in @($vcpkgLib, $vcpkgDll, $vcpkgInc)) {
if (-not (Test-Path $p)) { throw "vcpkg did not produce $p" }
}

$intelDir = "C:\Program Files (x86)\Intel RealSense SDK 2.0"
Write-Host "Restaging vcpkg output to $intelDir to satisfy CMakeLists.txt hardcoded paths..."
New-Item -ItemType Directory -Force -Path "$intelDir\lib\x64", "$intelDir\bin\x64", "$intelDir\include" | Out-Null
Copy-Item $vcpkgLib -Destination "$intelDir\lib\x64\realsense2.lib" -Force
Copy-Item $vcpkgDll -Destination "$intelDir\bin\x64\realsense2.dll" -Force
Copy-Item $vcpkgInc -Destination "$intelDir\include\librealsense2" -Recurse -Force

if (-not (Test-Path "$intelDir\lib\x64\realsense2.lib")) {
throw "Restage failed: $intelDir\lib\x64\realsense2.lib missing."
}
Write-Host "RealSense SDK staged at $intelDir."

# -------------------------------------------------------------------
# Configure + build. Windows is pinned to the x64 VS generator so we
# never accidentally pick up a 32-bit toolchain (the OpenCV / RealSense
# libs we install above are x64-only). /MT linkage on Windows + prebuilt
# OpenCV (/MD) relies on the /FORCE linker flag already set in CMakeLists.
# -------------------------------------------------------------------
- name: Configure (Windows x64)
if: runner.os == 'Windows'
run: cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release

- name: Configure (Linux / macOS)
if: runner.os != 'Windows'
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build build --config Release --parallel
Loading
Loading