Skip to content

Commit 9923bd9

Browse files
committed
Refactor Windows build steps in GitHub Actions and improve device selection logic in RayneoApi
1 parent 65bb5ad commit 9923bd9

3 files changed

Lines changed: 55 additions & 23 deletions

File tree

.github/workflows/release.yml

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ jobs:
3636
- name: Bootstrap vcpkg (Windows)
3737
if: startsWith(matrix.os, 'windows')
3838
run: |
39+
$env:VCPKG_ROOT = "$PWD\vcpkg"
3940
git clone https://github.com/microsoft/vcpkg.git "$env:VCPKG_ROOT"
40-
$env:VCPKG_ROOT\bootstrap-vcpkg.bat
41+
& "$env:VCPKG_ROOT\bootstrap-vcpkg.bat"
42+
echo "VCPKG_ROOT=$env:VCPKG_ROOT" >> $env:GITHUB_ENV
4143
echo "VCPKG_INSTALLED_DIR=$env:VCPKG_ROOT\installed" >> $env:GITHUB_ENV
4244
shell: pwsh
4345

4446
- name: Install dependencies (Windows)
4547
if: startsWith(matrix.os, 'windows')
4648
run: |
47-
$env:VCPKG_ROOT/vcpkg.exe install libusb[core]:x64-windows sdl2[sdl2main]:x64-windows sdl2-ttf:x64-windows
49+
& "$env:VCPKG_ROOT\vcpkg.exe" install libusb[core]:x64-windows sdl2:x64-windows sdl2-ttf:x64-windows
4850
shell: pwsh
4951

5052
- name: Install dependencies (Ubuntu)
@@ -59,34 +61,59 @@ jobs:
5961
brew update
6062
brew install libusb sdl2 sdl2_ttf
6163
62-
- name: Configure CMake
64+
- name: Configure CMake (Windows)
65+
if: startsWith(matrix.os, 'windows')
66+
run: |
67+
cmake -B build -DRAYNEO_BUILD_EXAMPLES=ON -DRAYNEO_BUILD_OPENVR_DRIVER=OFF -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake"
68+
shell: pwsh
69+
70+
- name: Configure CMake (POSIX)
71+
if: matrix.os != 'windows-latest'
6372
run: |
64-
cmake -B build -DRAYNEO_BUILD_EXAMPLES=ON -DRAYNEO_BUILD_OPENVR_DRIVER=OFF ${{ startsWith(matrix.os, 'windows') && '-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake' || '' }}
73+
cmake -B build -DRAYNEO_BUILD_EXAMPLES=ON -DRAYNEO_BUILD_OPENVR_DRIVER=OFF
6574
shell: bash
6675

67-
- name: Build
76+
- name: Build (Windows)
77+
if: startsWith(matrix.os, 'windows')
6878
run: |
6979
cmake --build build --config ${{ matrix.build_type }} --target RayNeoSDK
7080
cmake --build build --config ${{ matrix.build_type }} --target RayNeoExample || true
7181
cmake --build build --config ${{ matrix.build_type }} --target RayNeoOrientationDemo || true
82+
shell: pwsh
83+
84+
- name: Build (POSIX)
85+
if: matrix.os != 'windows-latest'
86+
run: |
87+
cmake --build build --target RayNeoSDK --config ${{ matrix.build_type }}
88+
cmake --build build --target RayNeoExample --config ${{ matrix.build_type }} || true
89+
cmake --build build --target RayNeoOrientationDemo --config ${{ matrix.build_type }} || true
7290
shell: bash
7391

7492
- name: Package artifacts
7593
run: |
7694
mkdir -p package/include package/bin package/examples
77-
cp -R include/rayneo package/include/
78-
# Copy library
95+
if [ -d include ]; then
96+
cp -R include/. package/include/
97+
else
98+
echo "WARNING: include directory missing"
99+
fi
100+
# Copy library (handle multi vs single config)
79101
if [ "${{ matrix.os }}" = "windows-latest" ]; then
80-
cp build/${{ matrix.build_type }}/RayNeoSDK.dll package/bin/ || true
81-
cp build/${{ matrix.build_type }}/RayNeoSDK.lib package/bin/ || true
102+
cp build/${{ matrix.build_type }}/RayNeoSDK.dll package/bin/ || echo "Missing RayNeoSDK.dll"
103+
cp build/${{ matrix.build_type }}/RayNeoSDK.lib package/bin/ || echo "Missing RayNeoSDK.lib"
82104
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
83-
cp build/RayNeoSDK.dylib package/bin/ || true
105+
cp build/libRayNeoSDK.dylib package/bin/ || echo "Missing libRayNeoSDK.dylib"
106+
else
107+
cp build/libRayNeoSDK.so package/bin/ || echo "Missing libRayNeoSDK.so"
108+
fi
109+
# Copy examples (Windows uses config dirs; others direct)
110+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
111+
cp build/examples/simple/${{ matrix.build_type }}/* package/examples/ 2>/dev/null || true
112+
cp build/examples/orientation_demo/${{ matrix.build_type }}/* package/examples/ 2>/dev/null || true
84113
else
85-
cp build/libRayNeoSDK.so package/bin/ || true
114+
cp build/examples/simple/* package/examples/ 2>/dev/null || true
115+
cp build/examples/orientation_demo/* package/examples/ 2>/dev/null || true
86116
fi
87-
# Copy examples if built
88-
cp build/examples/simple/${{ matrix.build_type }}/* package/examples/ 2>/dev/null || true
89-
cp build/examples/orientation_demo/${{ matrix.build_type }}/* package/examples/ 2>/dev/null || true
90117
tar -czf rayneo-sdk-${{ matrix.os }}.tar.gz package
91118
shell: bash
92119

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ endif()
4646

4747
# Provide a unified interface target that downstream code can link against
4848
add_library(LibUsb INTERFACE)
49+
add_library(RayNeo::LibUsb ALIAS LibUsb)
4950

5051
if (TARGET PkgConfig::libusb)
5152
# pkg-config found: reuse its imported target and propagate its compile flags
@@ -90,7 +91,7 @@ if (NOT APPLE)
9091
endif()
9192
else()
9293
# On Linux we usually rely on system loader; attempt to find .so for optional copy.
93-
get_target_property(_rayneo_libusb_lib RayNeo::LibUsb INTERFACE_LINK_LIBRARIES)
94+
get_target_property(_rayneo_libusb_lib LibUsb INTERFACE_LINK_LIBRARIES)
9495
# _rayneo_libusb_lib may list several; attempt to locate a libusb shared object hint.
9596
foreach(lib IN LISTS _rayneo_libusb_lib)
9697
if (lib MATCHES "libusb" AND EXISTS "${lib}")
@@ -104,7 +105,10 @@ if (NOT APPLE)
104105
endif()
105106
endif()
106107

107-
add_library(RayNeo::LibUsb ALIAS LibUsb)
108+
# OpenGL policy to prefer GLVND when available (silences warning)
109+
if (POLICY CMP0072)
110+
cmake_policy(SET CMP0072 NEW)
111+
endif()
108112

109113
# Platform-specific dependencies ----------------------------------------------
110114
if (APPLE)

src/RayneoApi.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,17 @@ static bool macEnsureDeviceSelected(RayneoContext__ *ctx)
338338
if (!set)
339339
return false;
340340
CFIndex count = CFSetGetCount(set);
341-
// CFSetGetValues expects an array of const void*. Casting directly from
342-
// IOHIDDeviceRef* to const void** is rejected by Clang due to qualifier loss.
343-
// Use an intermediate buffer of CFTypeRef (alias of const void*) then cast
344-
// each element to IOHIDDeviceRef.
345-
std::vector<CFTypeRef> raw(static_cast<size_t>(count));
341+
// CFSetGetValues fills an array of const void* values. We store them as such
342+
// then cast to IOHIDDeviceRef (opaque pointer) for inspection. Removing const
343+
// is safe: we do not mutate device objects here, only read properties.
344+
std::vector<const void *> raw(static_cast<size_t>(count));
346345
if (count > 0)
347346
CFSetGetValues(set, raw.data());
348-
for (auto entry : raw)
347+
for (const void *entry : raw)
349348
{
350-
IOHIDDeviceRef dev = static_cast<IOHIDDeviceRef>(entry);
349+
// Convert const void* from CFSet to IOHIDDeviceRef without triggering
350+
// qualifier warnings: IOHIDDeviceRef is an opaque pointer typedef.
351+
IOHIDDeviceRef dev = reinterpret_cast<IOHIDDeviceRef>(const_cast<void *>(entry));
351352
if (!dev)
352353
continue;
353354
int vid = macGetDeviceInt(dev, CFSTR(kIOHIDVendorIDKey));

0 commit comments

Comments
 (0)