Skip to content

Commit 01ba3b6

Browse files
feat(FreeBSD): Add backend support
Refactors CI into reusable workflow-call pipelines (`ci-driver`, `ci-build`, `ci-results`) and updates the top-level `ci.yml` to orchestrate release setup, Windows driver packaging/signing, cross-platform library builds (now including FreeBSD), and Codecov uploads. Adds FreeBSD platform support details across build and runtime behavior: enables threaded use on FreeBSD, applies required Clang libc++ experimental flags, extends the Linux/uhid backend implementation to support FreeBSD uinput paths and platform-specific capability/effective-profile handling, and wires in new FreeBSD integration tests. Documentation is updated to describe FreeBSD’s uinput-based feature subset and integration expectations.
1 parent a0560b7 commit 01ba3b6

13 files changed

Lines changed: 1266 additions & 783 deletions

.github/workflows/ci-build.yml

Lines changed: 611 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/ci-driver.yml

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
---
2+
name: CI-Driver
3+
permissions: {}
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
azure_signing_account:
9+
required: false
10+
type: string
11+
default: ''
12+
azure_signing_cert_profile:
13+
required: false
14+
type: string
15+
default: ''
16+
azure_signing_endpoint:
17+
required: false
18+
type: string
19+
default: ''
20+
publish_release:
21+
required: true
22+
type: string
23+
release_commit:
24+
required: true
25+
type: string
26+
release_version:
27+
required: true
28+
type: string
29+
secrets:
30+
AZURE_CLIENT_ID:
31+
required: false
32+
AZURE_CLIENT_SECRET:
33+
required: false
34+
AZURE_TENANT_ID:
35+
required: false
36+
37+
env:
38+
DRIVER_BUILD_CONFIG: Release
39+
40+
jobs:
41+
windows_driver:
42+
name: Windows Driver Installer
43+
permissions:
44+
contents: read
45+
runs-on: windows-2022
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
49+
with:
50+
submodules: recursive
51+
52+
- name: Setup dotnet
53+
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
54+
with:
55+
dotnet-version: '10.x'
56+
57+
- name: Configure Windows driver package
58+
shell: pwsh
59+
env:
60+
BRANCH: ${{ github.head_ref || github.ref_name }}
61+
BUILD_VERSION: ${{ inputs.release_version }}
62+
COMMIT: ${{ inputs.release_commit }}
63+
run: |
64+
$certificatePath = Join-Path $env:GITHUB_WORKSPACE "cmake-build-driver\certificates\libvirtualhid-ci-test.cer"
65+
cmake `
66+
-DBUILD_DOCS=OFF `
67+
-DBUILD_EXAMPLES=ON `
68+
-DBUILD_TESTS=OFF `
69+
-DLIBVIRTUALHID_BUILD_WINDOWS_DRIVER=ON `
70+
-DLIBVIRTUALHID_ENABLE_PACKAGING=ON `
71+
"-DLIBVIRTUALHID_DRIVER_TEST_CERTIFICATE=$certificatePath" `
72+
-A x64 `
73+
-B cmake-build-driver `
74+
-G "Visual Studio 17 2022" `
75+
-S .
76+
77+
- name: Build Windows driver package
78+
shell: pwsh
79+
run: >-
80+
cmake --build cmake-build-driver
81+
--config ${{ env.DRIVER_BUILD_CONFIG }}
82+
--target libvirtualhid_windows_catalog libvirtualhid_broker gamepad_adapter virtualhid_control
83+
--parallel 2
84+
85+
- name: Validate Azure signing configuration
86+
if: >-
87+
github.event_name == 'push' &&
88+
inputs.publish_release == 'true' &&
89+
inputs.azure_signing_account == ''
90+
shell: pwsh
91+
run: throw "Release builds must use Azure Trusted Signing for the Windows driver package."
92+
93+
- name: Sign Windows driver package with local test certificate
94+
if: >-
95+
github.event_name == 'pull_request' ||
96+
inputs.publish_release != 'true'
97+
shell: pwsh
98+
run: |
99+
$packagePath = Join-Path `
100+
$env:GITHUB_WORKSPACE `
101+
"cmake-build-driver\src\platform\windows\driver\package\$env:DRIVER_BUILD_CONFIG"
102+
$certificatePath = Join-Path `
103+
$env:GITHUB_WORKSPACE `
104+
"cmake-build-driver\certificates\libvirtualhid-ci-test.cer"
105+
.\scripts\windows\sign-driver-package.ps1 `
106+
-PackagePath $packagePath `
107+
-CertificatePath $certificatePath
108+
109+
- name: Locate Windows driver catalog
110+
id: driver_catalog
111+
if: >-
112+
github.event_name == 'push' &&
113+
inputs.publish_release == 'true' &&
114+
inputs.azure_signing_account != ''
115+
shell: pwsh
116+
run: |
117+
$catalogPath = Join-Path `
118+
$env:GITHUB_WORKSPACE `
119+
"cmake-build-driver\src\platform\windows\driver\package\$env:DRIVER_BUILD_CONFIG\libvirtualhid.cat"
120+
"path=$catalogPath" >> $env:GITHUB_OUTPUT
121+
122+
- name: Sign Windows driver package with Azure Trusted Signing
123+
if: >-
124+
github.event_name == 'push' &&
125+
inputs.publish_release == 'true' &&
126+
inputs.azure_signing_account != ''
127+
uses: azure/trusted-signing-action@c7ab2a863ab5f9a846ddb8265964877ef296ee82 # v2.0.0
128+
with:
129+
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
130+
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
131+
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
132+
certificate-profile-name: ${{ inputs.azure_signing_cert_profile }}
133+
endpoint: ${{ inputs.azure_signing_endpoint }}
134+
files: |
135+
${{ steps.driver_catalog.outputs.path }}
136+
signing-account-name: ${{ inputs.azure_signing_account }}
137+
138+
- name: Package Windows driver installer
139+
shell: pwsh
140+
run: |
141+
Push-Location .\cmake-build-driver
142+
cpack -G WIX -C $env:DRIVER_BUILD_CONFIG
143+
$packageExitCode = $LASTEXITCODE
144+
Pop-Location
145+
if ($packageExitCode -ne 0) {
146+
exit $packageExitCode
147+
}
148+
New-Item -ItemType Directory -Force -Path artifacts | Out-Null
149+
Copy-Item `
150+
-LiteralPath .\cmake-build-driver\cpack_artifacts\libvirtualhid.msi `
151+
-Destination `
152+
".\artifacts\libvirtualhid-Windows-AMD64-driver-installer.msi"
153+
154+
- name: Export Azure driver signing certificate
155+
if: >-
156+
github.event_name == 'push' &&
157+
inputs.publish_release == 'true' &&
158+
inputs.azure_signing_account != ''
159+
shell: pwsh
160+
run: |
161+
$catalogPath = Join-Path `
162+
$env:GITHUB_WORKSPACE `
163+
"cmake-build-driver\src\platform\windows\driver\package\$env:DRIVER_BUILD_CONFIG\libvirtualhid.cat"
164+
$signature = Get-AuthenticodeSignature -FilePath $catalogPath
165+
if ($signature.Status -ne "Valid") {
166+
throw "Azure signed driver catalog is not valid: $($signature.StatusMessage)"
167+
}
168+
if (!$signature.SignerCertificate) {
169+
throw "Azure signed driver catalog did not expose a signer certificate."
170+
}
171+
172+
$certificatePath = Join-Path $env:GITHUB_WORKSPACE "artifacts\libvirtualhid-driver-signing.cer"
173+
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $certificatePath) | Out-Null
174+
Export-Certificate -Cert $signature.SignerCertificate -FilePath $certificatePath -Force | Out-Null
175+
Write-Host (
176+
"Exported Azure driver signing certificate " +
177+
"$($signature.SignerCertificate.Subject) [$($signature.SignerCertificate.Thumbprint)]."
178+
)
179+
180+
- name: Sign Windows driver installer with Azure Trusted Signing
181+
if: >-
182+
github.event_name == 'push' &&
183+
inputs.publish_release == 'true' &&
184+
inputs.azure_signing_account != ''
185+
uses: azure/trusted-signing-action@c7ab2a863ab5f9a846ddb8265964877ef296ee82 # v2.0.0
186+
with:
187+
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
188+
azure-client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
189+
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
190+
certificate-profile-name: ${{ inputs.azure_signing_cert_profile }}
191+
endpoint: ${{ inputs.azure_signing_endpoint }}
192+
files-folder: artifacts
193+
files-folder-filter: msi
194+
files-folder-recurse: false
195+
signing-account-name: ${{ inputs.azure_signing_account }}
196+
197+
- name: Validate release signing identities
198+
if: >-
199+
github.event_name == 'push' &&
200+
inputs.publish_release == 'true' &&
201+
inputs.azure_signing_account != ''
202+
shell: pwsh
203+
run: |
204+
$catalogPath = Join-Path `
205+
$env:GITHUB_WORKSPACE `
206+
"cmake-build-driver\src\platform\windows\driver\package\$env:DRIVER_BUILD_CONFIG\libvirtualhid.cat"
207+
$installerPath = Get-ChildItem -LiteralPath .\artifacts -Filter *.msi |
208+
Select-Object -ExpandProperty FullName -First 1
209+
if (!$installerPath) {
210+
throw "The signed Windows driver installer was not found."
211+
}
212+
213+
$catalogSignature = Get-AuthenticodeSignature -FilePath $catalogPath
214+
$installerSignature = Get-AuthenticodeSignature -FilePath $installerPath
215+
foreach ($signature in @($catalogSignature, $installerSignature)) {
216+
if ($signature.Status -ne "Valid" -or !$signature.SignerCertificate) {
217+
throw "A release signature is invalid: $($signature.StatusMessage)"
218+
}
219+
}
220+
if ($catalogSignature.SignerCertificate.Subject -cne `
221+
$installerSignature.SignerCertificate.Subject) {
222+
throw "The catalog and MSI were signed with different identities."
223+
}
224+
Write-Host (
225+
"Validated release signer " +
226+
"$($installerSignature.SignerCertificate.Subject) " +
227+
"[$($installerSignature.SignerCertificate.Thumbprint)]."
228+
)
229+
230+
- name: Debug wix
231+
if: always()
232+
shell: pwsh
233+
run: |
234+
Get-Content .\cmake-build-driver\cpack_artifacts\_CPack_Packages\win64\WIX\wix.log `
235+
-ErrorAction SilentlyContinue
236+
237+
- name: Upload Windows driver installer artifact
238+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
239+
with:
240+
name: windows-driver-installer
241+
path: artifacts
242+
if-no-files-found: error

.github/workflows/ci-results.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
name: CI-Results
3+
permissions: {}
4+
5+
on:
6+
workflow_call:
7+
secrets:
8+
CODECOV_TOKEN:
9+
required: false
10+
11+
jobs:
12+
codecov:
13+
name: Codecov-${{ matrix.flag }}
14+
if: startsWith(github.repository, 'LizardByte/')
15+
permissions:
16+
contents: read
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- build_name: FreeBSD
23+
flag: FreeBSD
24+
has_coverage: true
25+
- build_name: Linux-GCC
26+
flag: Linux-GCC
27+
has_coverage: true
28+
- build_name: Linux-Clang
29+
flag: Linux-Clang
30+
has_coverage: true
31+
- build_name: macOS
32+
flag: macOS
33+
has_coverage: true
34+
- build_name: Windows-MinGW-UCRT64
35+
flag: Windows-MinGW-UCRT64
36+
has_coverage: true
37+
- build_name: Windows-MSVC
38+
flag: Windows-MSVC
39+
has_coverage: true
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
43+
44+
- name: Download report artifact
45+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
46+
with:
47+
name: reports-${{ matrix.build_name }}
48+
path: _reports
49+
50+
- name: Debug coverage file
51+
if: matrix.has_coverage
52+
run: cat _reports/coverage.xml
53+
54+
- name: Upload test coverage
55+
if: matrix.has_coverage
56+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
57+
with:
58+
disable_search: true
59+
fail_ci_if_error: true
60+
files: ./_reports/coverage.xml
61+
report_type: coverage
62+
flags: ${{ matrix.flag }}
63+
token: ${{ secrets.CODECOV_TOKEN }}
64+
verbose: true
65+
66+
- name: Upload test results
67+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
68+
with:
69+
disable_search: true
70+
fail_ci_if_error: true
71+
files: ./_reports/junit.xml
72+
report_type: test_results
73+
flags: ${{ matrix.flag }}
74+
token: ${{ secrets.CODECOV_TOKEN }}
75+
verbose: true

0 commit comments

Comments
 (0)