Update dsu_server_psmove.cpp #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release build (use psmoveapi prebuilt binaries) | ||
| on: | ||
| release: | ||
| types: [created, published] | ||
| workflow_dispatch: | ||
| env: | ||
| # Set the psmoveapi version tag you want to use (recommend pinning) | ||
| PSMOVE_VERSION: "4.0.12" | ||
| PSMOVE_BASE_URL: "https://github.com/thp/psmoveapi/releases/download/${{ env.PSMOVE_VERSION }}" | ||
| # Path where the prebuilt psmoveapi will be extracted | ||
| INSTALL_DIR: "${{ github.workspace }}/psmoveapi_install" | ||
| # Name prefix for produced artifacts | ||
| ARTIFACT_PREFIX: "dsu_server" | ||
| jobs: | ||
| linux: | ||
| name: Linux (x86_64) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Get CMake | ||
| uses: lukka/get-cmake@latest | ||
| - name: Download and extract psmoveapi (Linux) | ||
| run: | | ||
| mkdir -p "${INSTALL_DIR}" | ||
| curl -L -o psmoveapi.tar.gz "${{ env.PSMOVE_BASE_URL }}/psmoveapi-${{ env.PSMOVE_VERSION }}-linux.tar.gz" | ||
| tar -xzf psmoveapi.tar.gz -C "${INSTALL_DIR}" --strip-components=1 | ||
| echo "Contents of ${INSTALL_DIR}:" | ||
| ls -la "${INSTALL_DIR}" | ||
| - name: Configure & build (Linux) | ||
| run: | | ||
| mkdir -p build | ||
| cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="${INSTALL_DIR}" | ||
| cmake --build build --config Release --parallel | ||
| - name: Package binary + libs (Linux) | ||
| run: | | ||
| BIN=$(find build -type f -iname 'dsu_server*' -executable -print -quit) | ||
| if [ -z "$BIN" ]; then echo "Binary not found in build/"; ls -R build || true; exit 1; fi | ||
| echo "Found binary: $BIN" | ||
| mkdir -p release_artifacts/run | ||
| cp "$BIN" release_artifacts/run/ | ||
| # copy libpsmoveapi and any other .so files from INSTALL_DIR/lib | ||
| if [ -d "${INSTALL_DIR}/lib" ]; then | ||
| cp -v ${INSTALL_DIR}/lib/*.so* release_artifacts/run/ 2>/dev/null || true | ||
| fi | ||
| # Make packaged tar.gz | ||
| tar -C release_artifacts -czf release_artifacts/${{ env.ARTIFACT_PREFIX }}_linux_${{ env.PSMOVE_VERSION }}.tar.gz run | ||
| ls -lh release_artifacts | ||
| - name: Upload to Release (Linux) | ||
| if: ${{ github.event_name == 'release' }} | ||
| uses: actions/upload-release-asset@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| upload_url: ${{ github.event.release.upload_url }} | ||
| asset_path: release_artifacts/${{ env.ARTIFACT_PREFIX }}_linux_${{ env.PSMOVE_VERSION }}.tar.gz | ||
| asset_name: ${{ env.ARTIFACT_PREFIX }}_linux_${{ env.PSMOVE_VERSION }}.tar.gz | ||
| asset_content_type: application/gzip | ||
| macos: | ||
| name: macOS (x86_64/arm64) | ||
| runs-on: macos-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Get CMake | ||
| uses: lukka/get-cmake@latest | ||
| - name: Download and extract psmoveapi (macOS) | ||
| run: | | ||
| mkdir -p "${INSTALL_DIR}" | ||
| curl -L -o psmoveapi.tar.gz "${{ env.PSMOVE_BASE_URL }}/psmoveapi-${{ env.PSMOVE_VERSION }}-macos.tar.gz" | ||
| tar -xzf psmoveapi.tar.gz -C "${INSTALL_DIR}" --strip-components=1 | ||
| echo "Contents of ${INSTALL_DIR}:" | ||
| ls -la "${INSTALL_DIR}" | ||
| - name: Configure & build (macOS) | ||
| run: | | ||
| mkdir -p build | ||
| cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="${INSTALL_DIR}" | ||
| cmake --build build --config Release --parallel | ||
| - name: Package binary + libs (macOS) | ||
| run: | | ||
| BIN=$(find build -type f -iname 'dsu_server*' -print -quit) | ||
| if [ -z "$BIN" ]; then echo "Binary not found"; ls -R build || true; exit 1; fi | ||
| echo "Found binary: $BIN" | ||
| mkdir -p release_artifacts/run | ||
| cp "$BIN" release_artifacts/run/ | ||
| if [ -d "${INSTALL_DIR}/lib" ]; then | ||
| cp -v ${INSTALL_DIR}/lib/*.dylib release_artifacts/run/ 2>/dev/null || true | ||
| fi | ||
| tar -C release_artifacts -czf release_artifacts/${{ env.ARTIFACT_PREFIX }}_macos_${{ env.PSMOVE_VERSION }}.tar.gz run | ||
| ls -lh release_artifacts | ||
| - name: Upload to Release (macOS) | ||
| if: ${{ github.event_name == 'release' }} | ||
| uses: actions/upload-release-asset@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| upload_url: ${{ github.event.release.upload_url }} | ||
| asset_path: release_artifacts/${{ env.ARTIFACT_PREFIX }}_macos_${{ env.PSMOVE_VERSION }}.tar.gz | ||
| asset_name: ${{ env.ARTIFACT_PREFIX }}_macos_${{ env.PSMOVE_VERSION }}.tar.gz | ||
| asset_content_type: application/gzip | ||
| windows_msvc: | ||
| name: Windows (MSVC) - x64/x86 | ||
| runs-on: windows-latest | ||
| strategy: | ||
| matrix: | ||
| arch: [x64, x86] | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Download psmoveapi (Windows MSVC) | ||
| run: | | ||
| $arch = "${{ matrix.arch }}" | ||
| mkdir -p psmoveapi_install | ||
| if ($arch -eq "x64") { | ||
| $url = "${{ env.PSMOVE_BASE_URL }}/psmoveapi-${{ env.PSMOVE_VERSION }}-windows-msvc2017-x64.zip" | ||
| } else { | ||
| $url = "${{ env.PSMOVE_BASE_URL }}/psmoveapi-${{ env.PSMOVE_VERSION }}-windows-msvc2017-x86.zip" | ||
| } | ||
| Write-Host "Downloading $url" | ||
| Invoke-WebRequest -Uri $url -OutFile psmoveapi.zip | ||
| Expand-Archive psmoveapi.zip -DestinationPath psmoveapi_install | ||
| Write-Host "Listing psmoveapi_install:" | ||
| Get-ChildItem psmoveapi_install -Recurse | ||
| - name: Configure (MSVC) | ||
| shell: pwsh | ||
| run: | | ||
| $arch = "${{ matrix.arch }}" | ||
| if ($arch -eq "x64") { | ||
| cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH="${{ github.workspace }}\psmoveapi_install" | ||
| } else { | ||
| cmake -S . -B build -G "Visual Studio 17 2022" -A Win32 -DCMAKE_PREFIX_PATH="${{ github.workspace }}\psmoveapi_install" | ||
| } | ||
| - name: Build (MSVC) | ||
| shell: pwsh | ||
| run: cmake --build build --config Release | ||
| - name: Package binary + DLLs (MSVC) | ||
| shell: pwsh | ||
| run: | | ||
| $exe = Get-ChildItem -Path build -Recurse -Filter "dsu_server*.exe" -File | Select-Object -First 1 | ||
| if (-not $exe) { Write-Error "Built exe not found"; exit 1 } | ||
| Write-Host "Found $($exe.FullName)" | ||
| $outdir = "release_artifacts\run" | ||
| New-Item -ItemType Directory -Path $outdir -Force | Out-Null | ||
| Copy-Item -Path $exe.FullName -Destination $outdir | ||
| # copy DLLs from extracted psmoveapi lib or bin directories (if present) | ||
| $possible = @("psmoveapi_install\lib\*.dll","psmoveapi_install\bin\*.dll","psmoveapi_install\bin\Release\*.dll") | ||
| foreach ($pat in $possible) { | ||
| Get-ChildItem -Path $pat -ErrorAction SilentlyContinue | ForEach-Object { Copy-Item $_.FullName -Destination $outdir -Force } | ||
| } | ||
| $zip = "release_artifacts\${{ env.ARTIFACT_PREFIX }}_windows_msvc_${{ matrix.arch }}_${{ env.PSMOVE_VERSION }}.zip" | ||
| if (Test-Path $zip) { Remove-Item $zip -Force } | ||
| Compress-Archive -Path $outdir\* -DestinationPath $zip -Force | ||
| Write-Host "Packaged $zip" | ||
| - name: Upload to Release (MSVC) | ||
| if: ${{ github.event_name == 'release' }} | ||
| uses: actions/upload-release-asset@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| upload_url: ${{ github.event.release.upload_url }} | ||
| asset_path: release_artifacts/${{ env.ARTIFACT_PREFIX }}_windows_msvc_${{ matrix.arch }}_${{ env.PSMOVE_VERSION }}.zip | ||
| asset_name: ${{ env.ARTIFACT_PREFIX }}_windows_msvc_${{ matrix.arch }}_${{ env.PSMOVE_VERSION }}.zip | ||
| asset_content_type: application/zip | ||
| windows_mingw: | ||
| name: Windows (MinGW) - mingw64/mingw32 | ||
| runs-on: windows-latest | ||
| strategy: | ||
| matrix: | ||
| arch: [mingw64, mingw32] | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Set up MSYS2 | ||
| uses: msys2/setup-msys2@v2 | ||
| with: | ||
| update: true | ||
| msystem: MINGW64 | ||
| - name: Download psmoveapi (MinGW) and extract | ||
| shell: msys2 {0} | ||
| run: | | ||
| arch="${{ matrix.arch }}" | ||
| mkdir -p /c/Users/RunnerAdmin/workspace/psmoveapi_install | ||
| if [ "$arch" = "mingw64" ]; then | ||
| url="${{ env.PSMOVE_BASE_URL }}/psmoveapi-${{ env.PSMOVE_VERSION }}-mingw64.zip" | ||
| else | ||
| url="${{ env.PSMOVE_BASE_URL }}/psmoveapi-${{ env.PSMOVE_VERSION }}-mingw32.zip" | ||
| fi | ||
| echo "Downloading $url" | ||
| curl -L -o psmoveapi.zip "$url" | ||
| unzip -o psmoveapi.zip -d psmoveapi_install | ||
| ls -la psmoveapi_install | ||
| - name: Install MSYS2 toolchain (MinGW) | ||
| shell: msys2 {0} | ||
| run: | | ||
| pacman -Syu --noconfirm | ||
| pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-i686-toolchain mingw-w64-x86_64-cmake mingw-w64-i686-cmake | ||
| - name: Configure & build (MinGW) | ||
| shell: msys2 {0} | ||
| run: | | ||
| arch="${{ matrix.arch }}" | ||
| # Use MSYS Makefiles and CMAKE_PREFIX_PATH pointing to the extracted psmoveapi | ||
| mkdir -p build && cd build | ||
| cmake -G "MSYS Makefiles" -DCMAKE_PREFIX_PATH="../psmoveapi_install" .. | ||
| cmake --build . --parallel | ||
| - name: Package binary + DLLs (MinGW) | ||
| shell: msys2 {0} | ||
| run: | | ||
| exe=$(find build -type f -iname 'dsu_server*.exe' | head -n1) | ||
| if [ -z "$exe" ]; then echo "Built exe not found"; ls -R build || true; exit 1; fi | ||
| mkdir -p release_artifacts/run | ||
| cp "$exe" release_artifacts/run/ | ||
| # copy DLLs from psmoveapi_install lib or bin if present | ||
| cp -v psmoveapi_install/lib/*.dll release_artifacts/run/ 2>/dev/null || true | ||
| cp -v psmoveapi_install/bin/*.dll release_artifacts/run/ 2>/dev/null || true | ||
| zip -j release_artifacts/${{ env.ARTIFACT_PREFIX }}_windows_mingw_${{ matrix.arch }}_${{ env.PSMOVE_VERSION }}.zip release_artifacts/run/* | ||
| - name: Upload to Release (MinGW) | ||
| if: ${{ github.event_name == 'release' }} | ||
| uses: actions/upload-release-asset@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| upload_url: ${{ github.event.release.upload_url }} | ||
| asset_path: release_artifacts/${{ env.ARTIFACT_PREFIX }}_windows_mingw_${{ matrix.arch }}_${{ env.PSMOVE_VERSION }}.zip | ||
| asset_name: ${{ env.ARTIFACT_PREFIX }}_windows_mingw_${{ matrix.arch }}_${{ env.PSMOVE_VERSION }}.zip | ||
| asset_content_type: application/zip | ||