Add cross-platform Windows and Linux CI builds
Introduce a reproducible CMake build and GitHub Actions matrix for Ubuntu Linux x64 and Windows x64. Each platform installs libusb, builds the usbboot executable, and publishes a platform-specific artifact containing the executable, required boot binaries, and documentation. The Windows artifact also includes libusb-1.0.dll. Add a small Windows getopt_long compatibility layer because the Microsoft CRT does not provide the POSIX GNU option parser used by usbboot. Add Windows sleep support and make the source explicitly include the fixed-width integer and time headers needed by the cross-platform build. Replace C99 variable-length arrays with checked heap allocations so the source compiles with MSVC, which does not support VLAs. Cast libusb request-type flags to avoid MSVC enum warnings, and use a conforming cleanup(void) callback signature for atexit(). Correct the existing cleanup NULL check so an open libusb handle is actually closed. Document local CMake builds, CI artifacts, the Windows libusb DLL, and the requirement to bind the boot-mode device to WinUSB before use. Credit: OpenAI Codex (GPT-5), collaborating with dark98 on the Windows port and CI implementation.
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
name: Build usbboot
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{ matrix.platform }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
platform: linux-x64
|
||||
- os: windows-latest
|
||||
platform: windows-x64
|
||||
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Linux dependencies
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install --no-install-recommends --yes cmake libusb-1.0-0-dev
|
||||
|
||||
- name: Install Windows dependencies
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: vcpkg install libusb:x64-windows
|
||||
|
||||
- name: Configure (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
- name: Configure (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: >-
|
||||
cmake -S . -B build -A x64
|
||||
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
|
||||
-DVCPKG_TARGET_TRIPLET=x64-windows
|
||||
|
||||
- name: Build (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: cmake --build build --config Release --parallel
|
||||
|
||||
- name: Build (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: cmake --build build --config Release --parallel
|
||||
|
||||
- name: Package Linux artifact
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
mkdir dist
|
||||
cp build/usbboot dist/usbboot
|
||||
cp spl.bin uboot.bin README.md dist/
|
||||
|
||||
- name: Package Windows artifact
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force dist | Out-Null
|
||||
Copy-Item build\Release\usbboot.exe dist\
|
||||
Copy-Item "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin\libusb-1.0.dll" dist\
|
||||
Copy-Item spl.bin, uboot.bin, README.md dist\
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: usbboot-${{ matrix.platform }}
|
||||
path: dist
|
||||
Reference in New Issue
Block a user