Skip to content

Refactor buffer management in Rayneo_Start and enhance thread safety … #28

Refactor buffer management in Rayneo_Start and enhance thread safety …

Refactor buffer management in Rayneo_Start and enhance thread safety … #28

Workflow file for this run

name: Build & Release RayNeo SDK
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write # needed to create releases
jobs:
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [RelWithDebInfo]
env:
VCPKG_DEFAULT_TRIPLET: x64-windows
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup vcpkg (Windows only)
if: startsWith(matrix.os, 'windows')
uses: actions/setup-node@v4
with:
node-version: "20.x"
# Using setup-node to ensure Git is modern; vcpkg bootstrap uses Git.
- name: Bootstrap vcpkg (Windows)
if: startsWith(matrix.os, 'windows')
run: |
$env:VCPKG_ROOT = "$PWD\vcpkg"
git clone https://github.com/microsoft/vcpkg.git "$env:VCPKG_ROOT"
& "$env:VCPKG_ROOT\bootstrap-vcpkg.bat"
echo "VCPKG_ROOT=$env:VCPKG_ROOT" >> $env:GITHUB_ENV
echo "VCPKG_INSTALLED_DIR=$env:VCPKG_ROOT\installed" >> $env:GITHUB_ENV
shell: pwsh
- name: Install dependencies (Windows)
if: startsWith(matrix.os, 'windows')
run: |
& "$env:VCPKG_ROOT\vcpkg.exe" install libusb[core]:x64-windows sdl2:x64-windows sdl2-ttf:x64-windows
shell: pwsh
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake libusb-1.0-0-dev libsdl2-dev libsdl2-ttf-dev libgl1-mesa-dev
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew update
brew install libusb sdl2 sdl2_ttf
- name: Configure CMake (Windows)
if: startsWith(matrix.os, 'windows')
run: |
cmake -B build -DRAYNEO_BUILD_EXAMPLES=ON -DRAYNEO_BUILD_OPENVR_DRIVER=ON -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake"
shell: pwsh
- name: Configure CMake (POSIX)
if: matrix.os != 'windows-latest'
run: |
cmake -B build -DRAYNEO_BUILD_EXAMPLES=ON -DRAYNEO_BUILD_OPENVR_DRIVER=ON
shell: bash
- name: Build (Windows)
if: startsWith(matrix.os, 'windows')
run: |
cmake --build build --config ${{ matrix.build_type }} --target RayNeoSDK
cmake --build build --config ${{ matrix.build_type }} --target RayNeoExample || true
cmake --build build --config ${{ matrix.build_type }} --target RayNeoOrientationDemo || true
cmake --build build --config ${{ matrix.build_type }} --target openvr_stub_driver || true
shell: pwsh
- name: Build (POSIX)
if: matrix.os != 'windows-latest'
run: |
cmake --build build --target RayNeoSDK --config ${{ matrix.build_type }}
cmake --build build --target RayNeoExample --config ${{ matrix.build_type }} || true
cmake --build build --target RayNeoOrientationDemo --config ${{ matrix.build_type }} || true
cmake --build build --target openvr_stub_driver --config ${{ matrix.build_type }} || true
shell: bash
- name: Package artifacts
run: |
mkdir -p package/include package/bin package/examples
if [ -d include ]; then
cp -R include/. package/include/
else
echo "WARNING: include directory missing"
fi
# Copy library (handle multi vs single config)
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp build/${{ matrix.build_type }}/RayNeoSDK.dll package/bin/ || echo "Missing RayNeoSDK.dll"
cp build/${{ matrix.build_type }}/RayNeoSDK.lib package/bin/ || echo "Missing RayNeoSDK.lib"
# OpenVR driver binary (Windows) - search recursively (handles config subdir patterns)
WIN_DRIVER=$(find build/openvr_driver -type f -name driver_rayneo.dll -print -quit 2>/dev/null || true)
if [ -n "$WIN_DRIVER" ]; then
mkdir -p openvr_driver_artifacts/rayneo/bin/win64
cp "$WIN_DRIVER" openvr_driver_artifacts/rayneo/bin/win64/driver_rayneo.dll
echo "Found Windows driver at $WIN_DRIVER"
# Bundle libusb runtime (Windows) from vcpkg into driver artifacts
VCPKG_POSIX="${VCPKG_ROOT//\\//}"
VCPKG_INSTALLED_POSIX="${VCPKG_INSTALLED_DIR//\\//}"
CANDIDATES=()
if [ -n "$VCPKG_INSTALLED_POSIX" ]; then
CANDIDATES+=("$VCPKG_INSTALLED_POSIX/x64-windows/bin/libusb-1.0.dll")
CANDIDATES+=("$VCPKG_INSTALLED_POSIX/x64-windows/debug/bin/libusb-1.0.dll")
fi
if [ -n "$VCPKG_POSIX" ]; then
CANDIDATES+=("$VCPKG_POSIX/installed/x64-windows/bin/libusb-1.0.dll")
CANDIDATES+=("$VCPKG_POSIX/installed/x64-windows/debug/bin/libusb-1.0.dll")
CANDIDATES+=("$VCPKG_POSIX/packages/libusb_x64-windows/bin/libusb-1.0.dll")
CANDIDATES+=("$VCPKG_POSIX/packages/libusb_x64-windows/debug/bin/libusb-1.0.dll")
fi
WIN_USB=""
for p in "${CANDIDATES[@]}"; do
if [ -f "$p" ]; then WIN_USB="$p"; break; fi
done
if [ -z "$WIN_USB" ]; then
WIN_USB=$(find "${VCPKG_POSIX:-.}" -type f -iname "libusb-1.0.dll" -print -quit 2>/dev/null || true)
fi
if [ -n "$WIN_USB" ]; then
cp "$WIN_USB" openvr_driver_artifacts/rayneo/bin/win64/ || echo "Copy libusb-1.0.dll failed"
else
echo "libusb-1.0.dll not found in vcpkg installation"
fi
else
echo "OpenVR Windows driver not found; tree of build/openvr_driver:";
ls -R build/openvr_driver || true
fi
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
cp build/libRayNeoSDK.dylib package/bin/ || echo "Missing libRayNeoSDK.dylib"
else
cp build/libRayNeoSDK.so package/bin/ || echo "Missing libRayNeoSDK.so"
# OpenVR driver binary (Linux)
DRIVER_SO=$(find build/openvr_driver -name driver_rayneo.so -print -quit || true)
if [ -n "$DRIVER_SO" ]; then
mkdir -p openvr_driver_artifacts/rayneo/bin/linux64
cp "$DRIVER_SO" openvr_driver_artifacts/rayneo/bin/linux64/driver_rayneo.so
echo "Found Linux driver at $DRIVER_SO"
# Bundle libusb runtime (Linux) into driver artifacts
USB_SO="/usr/lib/x86_64-linux-gnu/libusb-1.0.so.0"
if [ -f "$USB_SO" ]; then
cp "$USB_SO" openvr_driver_artifacts/rayneo/bin/linux64/ || echo "Copy libusb .so failed"
else
USB_SO=$(ldconfig -p | awk '/libusb-1\.0\.so(\.0)?/ {print $NF; exit}' || true)
if [ -n "$USB_SO" ] && [ -f "$USB_SO" ]; then
cp "$USB_SO" openvr_driver_artifacts/rayneo/bin/linux64/ || echo "Copy libusb .so failed"
else
echo "libusb runtime .so not found on system"
fi
fi
else
echo "OpenVR Linux driver not found; listing build/openvr_driver:";
ls -R build/openvr_driver || true
fi
fi
# Copy examples (Windows uses config dirs; others direct)
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp build/examples/simple/${{ matrix.build_type }}/* package/examples/ 2>/dev/null || true
cp build/examples/orientation_demo/${{ matrix.build_type }}/* package/examples/ 2>/dev/null || true
else
cp build/examples/simple/* package/examples/ 2>/dev/null || true
cp build/examples/orientation_demo/* package/examples/ 2>/dev/null || true
fi
tar -czf rayneo-sdk-${{ matrix.os }}.tar.gz package
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rayneo-sdk-${{ matrix.os }}
path: rayneo-sdk-${{ matrix.os }}.tar.gz
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Generate Release Notes
id: notes
run: |
echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "RayNeo SDK release triggered by $GITHUB_REF" >> $GITHUB_OUTPUT
echo "Includes prebuilt binaries for Windows, macOS, and Linux." >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Compose Release Meta
id: meta
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF_NAME}"
NAME="RayNeo SDK ${GITHUB_REF_NAME}"
else
TS=$(date -u +%Y%m%d-%H%M%S)
SHORT_SHA=$(git rev-parse --short HEAD)
TAG="sdk-${TS}-${SHORT_SHA}"
NAME="RayNeo SDK ${TS}-${SHORT_SHA}"
fi
echo "tag_name=$TAG" >> "$GITHUB_OUTPUT"
echo "release_name=$NAME" >> "$GITHUB_OUTPUT"
shell: bash
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag_name }}
name: ${{ steps.meta.outputs.release_name }}
body: ${{ steps.notes.outputs.release_body }}
files: |
dist/*/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}