Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 200M
CCACHE_COMPILERCHECK: content
strategy:
fail-fast: false
matrix:
Expand All @@ -23,7 +27,26 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -y \
build-essential cmake pkg-config \
libusb-1.0-0-dev libjpeg-dev
libusb-1.0-0-dev libjpeg-dev ccache

- name: Record compiler identity
id: compiler
run: |
fingerprint="$({ cc --version; c++ --version; } | sha256sum | cut -d' ' -f1)"
echo "fingerprint=$fingerprint" >> "$GITHUB_OUTPUT"

- name: Cache ccache
uses: actions/cache@v6
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.os }}-${{ steps.compiler.outputs.fingerprint }}-${{ hashFiles('CMakeLists.txt', 'cmake/**', 'include/**', 'src/**', '.github/workflows/build.yml') }}
restore-keys: |
ccache-${{ runner.os }}-${{ runner.arch }}-${{ matrix.os }}-${{ steps.compiler.outputs.fingerprint }}-

- name: Configure bounded ccache
run: |
ccache -M "$CCACHE_MAXSIZE"
ccache --zero-stats

- name: Configure (auto-detach ON)
run: |
Expand All @@ -32,7 +55,9 @@ jobs:
-DBUILD_SHARED_LIBS=ON \
-DBUILD_EXAMPLE=OFF \
-DBUILD_TEST=OFF \
-DLIBUVC_AUTO_DETACH_KERNEL_DRIVER=ON
-DLIBUVC_AUTO_DETACH_KERNEL_DRIVER=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache

- name: Build
run: cmake --build build --parallel
Expand All @@ -55,7 +80,9 @@ jobs:
-DBUILD_SHARED_LIBS=ON \
-DBUILD_EXAMPLE=OFF \
-DBUILD_TEST=OFF \
-DLIBUVC_AUTO_DETACH_KERNEL_DRIVER=OFF
-DLIBUVC_AUTO_DETACH_KERNEL_DRIVER=OFF \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build build-off --parallel
echo "PASS: OFF variant builds cleanly"

Expand All @@ -65,3 +92,11 @@ jobs:
echo "PASS: shared library produced"
test -f build/libuvc.a
echo "PASS: static library produced"

- name: Show ccache statistics
if: ${{ always() }}
run: ccache --show-stats

- name: Enforce ccache bound
if: ${{ always() }}
run: ccache -c
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,14 @@ Then you can start them with `./example` and `./uvc_test` respectively. Note tha

The documentation for `libuvc` can currently be found at https://libuvc.github.io/.

The GitHub Actions build check uses a bounded compiler cache for both CMake build
variants. It caches only the workspace-local `.ccache` directory, keyed by the
runner, compiler identity, and source/build workflow inputs; the `build/` and
`build-off/` directories are never cached. Local builds do not require ccache, but
you can enable it with CMake's compiler launcher options:

cmake -B build \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache

Happy hacking!
Loading