@@ -446,6 +446,80 @@ jobs:
446446 cd ${{github.workspace}}/build
447447 ctest --parallel --output-on-failure
448448
449+ # ============================================================================
450+ # vcpkg integration
451+ # ============================================================================
452+ vcpkg-integration :
453+ strategy :
454+ fail-fast : false
455+ matrix :
456+ os : [ ubuntu-latest, macos-latest, windows-latest ]
457+ feature : [ "default", "static-shim" ]
458+ runs-on : ${{ matrix.os }}
459+ name : vcpkg - ${{ matrix.os }} ${{ matrix.feature }}
460+ steps :
461+ - uses : actions/checkout@v4
462+
463+ - name : Bootstrap vcpkg
464+ shell : bash
465+ run : |
466+ git clone https://github.com/microsoft/vcpkg.git "${{ runner.temp }}/vcpkg" --depth 1
467+ if [ "$RUNNER_OS" = "Windows" ]; then
468+ "${{ runner.temp }}/vcpkg/bootstrap-vcpkg.bat" -disableMetrics
469+ else
470+ "${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
471+ fi
472+
473+ - name : Create overlay port pointing at local source
474+ shell : bash
475+ run : |
476+ overlay="${{ runner.temp }}/overlay/snmalloc"
477+ mkdir -p "$overlay"
478+ # Copy the real port files
479+ cp ports/snmalloc/vcpkg.json "$overlay/"
480+ cp ports/snmalloc/usage "$overlay/"
481+ # Normalize workspace path to forward slashes for CMake (Windows compat)
482+ ws_path=$(echo "${{ github.workspace }}" | sed 's|\\|/|g')
483+ # Rewrite portfile to use local source instead of vcpkg_from_github
484+ {
485+ echo 'if(NOT "static-shim" IN_LIST FEATURES)'
486+ echo ' set(VCPKG_BUILD_TYPE release)'
487+ echo 'endif()'
488+ echo ''
489+ echo "set(SOURCE_PATH \"${ws_path}\")"
490+ echo ''
491+ # Keep everything from vcpkg_check_features onwards (see comment in
492+ # ports/snmalloc/portfile.cmake documenting this coupling)
493+ sed -n '/^vcpkg_check_features/,$ p' ports/snmalloc/portfile.cmake
494+ } > "$overlay/portfile.cmake"
495+
496+ - name : Install snmalloc via vcpkg
497+ shell : bash
498+ # Run from runner.temp to avoid the workspace vcpkg.json triggering
499+ # manifest mode (which forbids positional package arguments).
500+ working-directory : ${{ runner.temp }}
501+ run : |
502+ features=""
503+ if [ "${{ matrix.feature }}" = "static-shim" ]; then
504+ features="[static-shim]"
505+ fi
506+ "${{ runner.temp }}/vcpkg/vcpkg" install "snmalloc${features}" \
507+ --overlay-ports="${{ runner.temp }}/overlay"
508+
509+ - name : Build consumer project
510+ shell : bash
511+ run : |
512+ cmake -B "${{ runner.temp }}/consumer-build" \
513+ -S test/vcpkg-consumer \
514+ -DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake"
515+ cmake --build "${{ runner.temp }}/consumer-build" --config Release
516+
517+ - name : Run tests
518+ shell : bash
519+ run : |
520+ ctest --test-dir "${{ runner.temp }}/consumer-build" \
521+ --build-config Release --output-on-failure
522+
449523 # ============================================================================
450524 # Final gate check
451525 # ============================================================================
@@ -456,7 +530,8 @@ jobs:
456530 freebsd, netbsd,
457531 qemu-crossbuild,
458532 windows,
459- format
533+ format,
534+ vcpkg-integration
460535 ]
461536 runs-on : ubuntu-24.04
462537 steps :
0 commit comments