Skip to content

Commit 50fa947

Browse files
committed
CI
1 parent fa5fc14 commit 50fa947

File tree

4 files changed

+178
-54
lines changed

4 files changed

+178
-54
lines changed

.github/workflows/build.yml

Lines changed: 128 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,152 @@ name: Check-Build
33
on: [push]
44

55
jobs:
6-
build:
7-
8-
runs-on: windows-latest
6+
build-driver:
7+
name: Build C++ driver (${{ matrix.os }} • ${{ matrix.preset }})
8+
runs-on: ${{ matrix.os }}
99
strategy:
10+
fail-fast: false
1011
matrix:
11-
dotnet-version: ['7.0.203' ]
12+
include:
13+
# Windows release presets
14+
- os: windows-latest
15+
preset: x64-release
16+
triplet: x64-windows-static
17+
vcpkgPkgs: "capnproto minhook"
18+
use_hooks: "ON"
19+
- os: windows-latest
20+
preset: x64-release-nohooks
21+
triplet: x64-windows-static
22+
vcpkgPkgs: "capnproto"
23+
use_hooks: "OFF"
24+
# Linux release preset
25+
- os: ubuntu-latest
26+
preset: linux-x64-release
27+
triplet: x64-linux
28+
vcpkgPkgs: "capnproto"
29+
use_hooks: "OFF"
1230

1331
steps:
14-
- uses: actions/checkout@v3
15-
with:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
with:
1635
submodules: true
1736

18-
- uses: actions/setup-dotnet@v3
37+
- name: Set up Ninja (Linux)
38+
if: runner.os == 'Linux'
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y ninja-build
42+
43+
- name: Set up Ninja (cross-platform)
44+
uses: seanmiddleditch/gha-setup-ninja@v4
45+
46+
- name: Set up MSVC developer command prompt (Windows)
47+
if: runner.os == 'Windows'
48+
uses: ilammy/msvc-dev-cmd@v1
49+
50+
- name: Set up CMake
51+
uses: lukka/get-cmake@latest
52+
53+
- name: Set up vcpkg
54+
id: runvcpkg
55+
uses: lukka/run-vcpkg@v11
1956
with:
20-
dotnet-version: '7.0.203'
21-
22-
- name: Add MSBuild to PATH
23-
uses: microsoft/[email protected]
57+
setupOnly: true
58+
vcpkgGitCommitId: 0d9d4684352ba8de70bdf251c6fc9a3c464fa12b
2459

25-
- name: Build the OpenVR Emulation driver
60+
- name: Install vcpkg packages (Windows)
61+
if: runner.os == 'Windows'
62+
shell: pwsh
2663
run: |
27-
nuget restore
28-
msbuild /restore /p:Platform=x64 /p:PlatformTarget=x64 /p:Configuration=Release /p:RuntimeIdentifier=win-x64 /t:driver_00Amethyst
29-
30-
- name: Build the OpenVR driver
64+
$triplet = '${{ matrix.triplet }}'
65+
$pkgsRaw = '${{ matrix.vcpkgPkgs }}'
66+
$pkgs = $pkgsRaw -split '\s+' | Where-Object { $_ -and $_.Trim().Length -gt 0 }
67+
[string[]]$args = @()
68+
foreach ($p in $pkgs) { $args += ("$($p.Trim()):$triplet") }
69+
if ($args.Count -eq 0) { Write-Host 'No vcpkg packages to install.' } else { & "$env:VCPKG_ROOT\vcpkg.exe" install @args }
70+
71+
- name: Install vcpkg packages (Linux)
72+
if: runner.os == 'Linux'
73+
shell: bash
3174
run: |
32-
nuget restore
33-
msbuild /restore /p:Platform=x64 /p:PlatformTarget=x64 /p:Configuration=Release /p:RuntimeIdentifier=win-x64 /t:driver_Amethyst
34-
35-
- name: Restore and build (publish)
36-
run: msbuild /restore /p:Platform=x64 /p:PlatformTarget=x64 /p:Configuration=Release /p:RuntimeIdentifier=win-x64 /t:plugin_OpenVR:Publish /p:PublishProfile=plugin_OpenVR\Properties\PublishProfiles\FolderProfile.pubxml
75+
set -euo pipefail
76+
triplet='${{ matrix.triplet }}'
77+
pkgs='${{ matrix.vcpkgPkgs }}'
78+
args=""
79+
for p in $pkgs; do args+="$p:$triplet "; done
80+
"$VCPKG_ROOT/vcpkg" install $args
81+
82+
- name: Configure (CMake preset)
83+
working-directory: ${{ github.workspace }}
84+
run: >-
85+
cmake
86+
--preset "${{ matrix.preset }}"
87+
-DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake"
88+
-DUSE_HOOKS=${{ matrix.use_hooks }}
89+
90+
- name: Build (CMake preset)
91+
working-directory: ${{ github.workspace }}
92+
run: cmake --build --preset "${{ matrix.preset }}" --parallel
93+
94+
- name: Upload driver pack artifact
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: driver_${{ matrix.preset }}_${{ runner.os }}
98+
path: |
99+
out/build/${{ matrix.preset }}/driver_Amethyst/Pack/**
100+
if-no-files-found: error
101+
102+
package-all:
103+
name: Package plugin + all drivers (single zip)
104+
needs: build-driver
105+
runs-on: windows-latest
106+
steps:
107+
- name: Checkout
108+
uses: actions/checkout@v4
109+
with:
110+
submodules: true
111+
112+
- name: Download all driver artifacts
113+
uses: actions/download-artifact@v4
114+
with:
115+
pattern: driver_*
116+
path: drivers
117+
merge-multiple: true
118+
119+
- name: Merge driver outputs into out/build
120+
shell: pwsh
121+
run: |
122+
$presets = @('x64-release','x64-release-nohooks','linux-x64-release')
123+
foreach ($p in $presets) {
124+
$src = Join-Path 'drivers' 'out/build' $p
125+
if (Test-Path $src) {
126+
$dst = Join-Path 'out/build' $p
127+
New-Item -ItemType Directory -Force -Path $dst | Out-Null
128+
Copy-Item -Recurse -Force (Join-Path $src '*') $dst
129+
}
130+
}
37131
132+
- name: Set up .NET
133+
uses: actions/setup-dotnet@v3
134+
with:
135+
dotnet-version: '10.0.x'
136+
137+
- name: Restore and build (publish)
138+
run: dotnet publish /p:Configuration=Release /p:TargetFramework=net8.0 /p:PublishProfile=FolderProfile
139+
38140
- name: Pack published files
39141
run: |
40-
cd plugin_OpenVR/bin/Release/net8.0/win-x64/publish
142+
cd plugin_OpenVR/bin/Release/publish
41143
7z a plugin_OpenVR.zip *
42-
144+
43145
- name: Upload plugin artifact
44146
uses: "marvinpinto/action-automatic-releases@latest"
45147
with:
46148
repo_token: "${{ secrets.GITHUB_TOKEN }}"
47-
automatic_release_tag: "latest"
149+
automatic_release_tag: "ame2-latest"
48150
prerelease: true
49151
title: "plugin_OpenVR Build Artifact"
50152
files: |
51-
./plugin_OpenVR/bin/Release/net8.0/win-x64/publish/plugin_OpenVR.zip
52-
./external/manifest.json
153+
./plugin_OpenVR/bin/Release/publish/plugin_OpenVR.zip
154+
./external/manifest.json

driver_Amethyst/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ endif()
3737
# ----------------------- MinHook support ----------------------
3838
if (WIN32 AND USE_HOOKS)
3939
find_package(minhook CONFIG REQUIRED)
40-
target_link_libraries(${DRIVER_TARGET_NAME} PRIVATE minhook::minhook)
40+
set(MINHOOK_LIB minhook::minhook)
4141
endif()
4242
# --------------------------------------------------------------
4343

@@ -124,6 +124,11 @@ target_include_directories(${DRIVER_TARGET_NAME} PRIVATE "${CAPNP_OUT_DIR}")
124124
target_link_libraries(${DRIVER_TARGET_NAME} PRIVATE openvr_api)
125125
target_include_directories(${DRIVER_TARGET_NAME} PRIVATE "${OPENVR_INCLUDE_DIR}")
126126

127+
# Link MinHook after target exists
128+
if (WIN32 AND USE_HOOKS)
129+
target_link_libraries(${DRIVER_TARGET_NAME} PRIVATE ${MINHOOK_LIB})
130+
endif()
131+
127132
if (UNIX AND NOT APPLE)
128133
set_target_properties(${DRIVER_TARGET_NAME} PROPERTIES
129134
BUILD_RPATH "$ORIGIN"

plugin_OpenVR/Properties/PublishProfiles/FolderProfile.pubxml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
66
<PropertyGroup>
77
<Configuration>Release</Configuration>
88
<Platform>x64</Platform>
9-
<PublishDir>bin\Release\net8.0\win-x64\publish\</PublishDir>
9+
<PublishDir>bin\Release\Publish</PublishDir>
1010
<PublishProtocol>FileSystem</PublishProtocol>
1111
<_TargetId>Folder</_TargetId>
1212
<TargetFramework>net8.0</TargetFramework>
13-
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1413
<SelfContained>true</SelfContained>
1514
<PublishSingleFile>false</PublishSingleFile>
16-
<PublishReadyToRun>true</PublishReadyToRun>
15+
<PublishReadyToRun>false</PublishReadyToRun>
1716
<PublishTrimmed>false</PublishTrimmed>
1817
</PropertyGroup>
19-
</Project>
18+
</Project>

plugin_OpenVR/plugin_OpenVR.csproj

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,28 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<TrimmerRootAssembly Include="MessagePack" />
24-
<TrimmerRootAssembly Include="Microsoft.VisualStudio.Threading" />
25-
<TrimmerRootAssembly Include="Newtonsoft.Json" />
26-
<TrimmerRootAssembly Include="StreamJsonRpc" />
23+
<TrimmerRootAssembly Include="MessagePack"/>
24+
<TrimmerRootAssembly Include="Microsoft.VisualStudio.Threading"/>
25+
<TrimmerRootAssembly Include="Newtonsoft.Json"/>
26+
<TrimmerRootAssembly Include="StreamJsonRpc"/>
2727
</ItemGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Avalonia" Version="11.3.2" />
31-
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.3.0" />
32-
<PackageReference Include="Capnp.Net.Runtime" Version="1.3.118" />
33-
<!-- <PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="1.3.118" />-->
34-
<PackageReference Include="FluentAvaloniaUI" Version="2.4.0" />
35-
<PackageReference Include="FluentAvaloniaUI" Version="2.4.0" />
36-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.14.0" />
37-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
38-
<PackageReference Include="System.ComponentModel.Composition" Version="9.0.6" />
39-
<PackageReference Include="System.ComponentModel.Composition.Registration" Version="9.0.6" />
30+
<PackageReference Include="Avalonia" Version="11.3.2"/>
31+
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.3.0"/>
32+
<PackageReference Include="Capnp.Net.Runtime" Version="1.3.118"/>
33+
<!-- <PackageReference Include="CapnpC.CSharp.MsBuild.Generation" Version="1.3.118" />-->
34+
<PackageReference Include="Amethyst.Contract" Version="2.0.0"/>
35+
<PackageReference Include="FluentAvaloniaUI" Version="2.4.0"/>
36+
<PackageReference Include="FluentAvaloniaUI" Version="2.4.0"/>
37+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.14.0"/>
38+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
39+
<PackageReference Include="System.ComponentModel.Composition" Version="9.0.6"/>
40+
<PackageReference Include="System.ComponentModel.Composition.Registration" Version="9.0.6"/>
4041
</ItemGroup>
4142

4243
<ItemGroup Condition="'$(TargetFramework)'=='net8.0-windows'">
43-
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4188" />
44-
</ItemGroup>
45-
46-
<!--TODO REMOVE THIS AND USE NUGET-->
47-
<ItemGroup>
48-
<Reference Include="Amethyst.Contract">
49-
<HintPath>..\..\..\Amethyst.Contract\bin\x64\Debug\net8.0\Amethyst.Contract.dll</HintPath>
50-
</Reference>
44+
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4188"/>
5145
</ItemGroup>
5246

5347
<ItemGroup>
@@ -59,6 +53,30 @@
5953
</Compile>
6054
</ItemGroup>
6155

56+
<ItemGroup Condition="Exists('..\out\build\linux-x64-release\driver_Amethyst\Pack')">
57+
<Content Include="..\out\build\linux-x64-release\driver_Amethyst\Pack\**"
58+
CopyToOutputDirectory="PreserveNewest"
59+
CopyToPublishDirectory="PreserveNewest"
60+
Link="Driver\%(RecursiveDir)\%(Filename)%(Extension)"
61+
Visible="False"/>
62+
</ItemGroup>
63+
64+
<ItemGroup Condition="Exists('..\out\build\x64-release\driver_Amethyst\Pack')">
65+
<Content Include="..\out\build\x64-release\driver_Amethyst\Pack\**"
66+
CopyToOutputDirectory="PreserveNewest"
67+
CopyToPublishDirectory="PreserveNewest"
68+
Link="Driver\%(RecursiveDir)\%(Filename)%(Extension)"
69+
Visible="False"/>
70+
</ItemGroup>
71+
72+
<ItemGroup Condition="Exists('..\out\build\x64-release-nohooks\driver_Amethyst\Pack')">
73+
<Content Include="..\out\build\x64-release-nohooks\driver_Amethyst\Pack\**"
74+
CopyToOutputDirectory="PreserveNewest"
75+
CopyToPublishDirectory="PreserveNewest"
76+
Link="Driver\%(RecursiveDir)\%(Filename)%(Extension)"
77+
Visible="False"/>
78+
</ItemGroup>
79+
6280
<ItemGroup>
6381
<!-- Windows x64 -->
6482
<Content Include="..\vendor\openvr\bin\win64\openvr_api.dll" Link="openvr_api.dll"
@@ -125,6 +143,6 @@
125143
</ItemGroup>
126144

127145
<ItemGroup>
128-
<Folder Include="Assets\Resources\" />
146+
<Folder Include="Assets\Resources\"/>
129147
</ItemGroup>
130148
</Project>

0 commit comments

Comments
 (0)