Small CMake related tweaks #65
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: binary artifacts | |
permissions: | |
contents: read | |
on: | |
push: | |
pull_request: | |
jobs: | |
windows-binaries: | |
name: Windows (x86_64 MSVC) | |
runs-on: windows-2022 # x86_64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install stable Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install cargo-c | |
env: | |
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download | |
CARGO_C_FILE: cargo-c-windows-msvc.zip | |
run: | | |
curl -L "$env:LINK/$env:CARGO_C_FILE" -o cargo-c-windows-msvc.zip | |
powershell -Command "Expand-Archive -Path cargo-c-windows-msvc.zip -DestinationPath $env:USERPROFILE\\.cargo\\bin -Force" | |
- name: Build rusts-ffi | |
run: | | |
cargo cinstall --locked --target x86_64-pc-windows-msvc --features cert_compression --release --prefix dist | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rustls-ffi-x86_64-windows | |
path: dist | |
linux-binaries: | |
name: Linux (x86_64 GNU) | |
runs-on: ubuntu-20.04 # x86_64. Using older Ubuntu for greater GLIBC compat. | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install stable Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install cargo-c | |
env: | |
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download | |
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz | |
run: | | |
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin | |
- name: Build rusts-ffi | |
# The Ubuntu 20.04 GCC is too old to build aws-lc. | |
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189. | |
env: | |
CC: clang | |
CXX: clang | |
run: | | |
cargo cinstall --locked --target x86_64-unknown-linux-gnu --features cert_compression --release --prefix dist | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rustls-ffi-x86_64-linux-gnu | |
path: dist | |
linux-deb: | |
name: Linux (x86-64 GNU Deb) | |
runs-on: ubuntu-20.04 # x86_64. Using older Ubuntu for greater GLIBC compat. | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install stable Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install cargo-c | |
env: | |
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download | |
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz | |
run: | | |
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin | |
- name: Build deb | |
run: ./debian/build.sh | |
- name: Upload deb | |
uses: actions/upload-artifact@v4 | |
with: | |
name: librustls_0.15.0_amd64.deb | |
path: librustls_0.15.0_amd64.deb | |
macos-binaries: | |
name: MacOS (Arm64 and x86_64) | |
runs-on: macos-14 # arm64. | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install stable Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
# Install both the arm64 and x86_64 targets. | |
targets: aarch64-apple-darwin, x86_64-apple-darwin | |
- name: Install cargo-c | |
env: | |
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download | |
CARGO_C_FILE: cargo-c-macos.zip | |
run: | | |
curl -L $LINK/$CARGO_C_FILE -o cargo-c-macos.zip | |
unzip cargo-c-macos.zip -d ~/.cargo/bin | |
- name: Build rusts-ffi (arm64) | |
run: | | |
cargo cinstall --target aarch64-apple-darwin --locked --features cert_compression --release --prefix arm64-dist | |
- name: Fix rpath (arm64) | |
run: | | |
install_name_tool -id @rpath/librustls.dylib arm64-dist/lib/librustls.dylib | |
- name: Upload binaries (arm64) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rustls-ffi-arm64-macos | |
path: arm64-dist | |
- name: Build rusts-ffi (x86_64) | |
run: | | |
cargo cinstall --target x86_64-apple-darwin --locked --features cert_compression --release --prefix x86-dist | |
- name: Fix rpath (x86_64) | |
run: | | |
install_name_tool -id @rpath/librustls.dylib x86-dist/lib/librustls.dylib | |
- name: Upload binaries (x86_64) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rustls-ffi-x86_64-macos | |
path: x86-dist | |
test-archives: | |
name: "Test (${{ matrix.os }})" | |
runs-on: ${{ matrix.os }} | |
needs: [ windows-binaries, linux-binaries, macos-binaries ] | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
artifact: rustls-ffi-x86_64-windows | |
- os: ubuntu-latest | |
artifact: rustls-ffi-x86_64-linux-gnu | |
- os: macos-14 | |
artifact: rustls-ffi-arm64-macos | |
- os: macos-13 | |
artifact: rustls-ffi-x86_64-macos | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Download rustls-ffi artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.artifact }} | |
path: ${{ matrix.artifact }} | |
# .pc files aren't relocatable. We need to update the prefix to point to | |
# the correct location that we extracted the archive. This seems more reliable | |
# than using `--define-prefix` - it seems to tack an extra 'lib/' subcomponent | |
# onto the include path that breaks the build. | |
- name: Fix pkg-config prefix (UNIX) | |
if: runner.os != 'Windows' | |
shell: bash | |
# For further fun, sed isn't consistent between macOS and Linux. | |
run: | | |
case "${{ runner.os }}" in | |
"macOS") | |
sed -i '' "s|prefix=.*|prefix=$(pwd)/${{ matrix.artifact }}|" ${{ matrix.artifact }}/lib/pkgconfig/rustls.pc | |
;; | |
*) | |
sed -i "s|prefix=.*|prefix=$(pwd)/${{ matrix.artifact }}|" ${{ matrix.artifact }}/lib/pkgconfig/rustls.pc | |
;; | |
esac | |
- name: Fix pkg-config prefix (Windows) | |
if: runner.os == 'Windows' | |
shell: pwsh | |
run: | | |
$prefix = (Get-Location).Path + "/${{ matrix.artifact }}" | |
$prefix = $prefix -replace '\\', '/' | |
$content = Get-Content "${{ matrix.artifact }}\lib\pkgconfig\rustls.pc" | |
$content = $content -replace "prefix=.*", "prefix=$prefix" | |
Set-Content "${{ matrix.artifact }}\lib\pkgconfig\rustls.pc" $content | |
# Dump out what pkg-config says about the rustls package. | |
- name: Debug pkg-config | |
run: | | |
pkg-config --cflags rustls | |
pkg-config --libs rustls | |
env: | |
PKG_CONFIG_PATH: ${{ matrix.artifact }}/lib/pkgconfig | |
# Set up the cmake build, overriding PKG_CONFIG_PATH to | |
# point to the extracted rustls-ffi archive. | |
- name: Setup cmake build (UNIX) | |
if: runner.os != 'Windows' | |
env: | |
PKG_CONFIG_PATH: ${{ matrix.artifact }}/lib/pkgconfig | |
run: cmake -S librustls -B build -DCMAKE_BUILD_TYPE=Release -DFORCE_SYSTEM_RUSTLS=ON | |
# Set up the cmake build, overriding PKG_CONFIG_PATH to | |
# point to the extracted rustls-ffi archive. | |
# | |
# For Windows cmake needs some help finding the strawberry perl pkg-config | |
# that's installed in the runner's PATH. | |
- name: Setup cmake build (Windows) | |
if: runner.os == 'Windows' | |
env: | |
PKG_CONFIG_PATH: ${{ matrix.artifact }}/lib/pkgconfig | |
run: cmake -DPKG_CONFIG_EXECUTABLE=C:\Strawberry\perl\bin\pkg-config.bat -DFORCE_SYSTEM_RUSTLS=ON -S librustls -B build | |
# Build the client and server binaries | |
- name: Build rustls-ffi client/server (UNIX) | |
if: runner.os != 'Windows' | |
run: cmake --build build -v | |
# Build the client and server binaries | |
# On Windows we need to specify a configuration to avoid a warning about using the default | |
# debug MSCRT runtime with a lib built with the release MSCRT runtime. | |
- name: Build rustls-ffi client/server (Windows) | |
if: runner.os == 'Windows' | |
run: cmake --build build --config Release -v | |
# Run the rustls-ffi client binary. | |
- name: Run rustls-ffi client (UNIX) | |
if: runner.os != 'Windows' | |
env: | |
RUSTLS_PLATFORM_VERIFIER: 1 | |
run: ./build/tests/client example.com 443 / 1 | |
# Run the rustls-ffi-test binary. | |
# On Windows it's in a different output location under build. | |
- name: Run rustls-ffi client (Windows) | |
if: runner.os == 'Windows' | |
env: | |
RUSTLS_PLATFORM_VERIFIER: 1 | |
run: .\build\tests\Release\client.exe example.com 443 / 1 | |
test-deb: | |
name: "Test Linux Deb (${{ matrix.os }})" | |
runs-on: ${{ matrix.os }} | |
needs: [ linux-deb ] | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, ubuntu-20.04 ] | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Download rustls-ffi deb artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: librustls_0.15.0_amd64.deb | |
- name: Install deb | |
run: sudo dpkg --install ./librustls_0.15.0_amd64.deb | |
# Dump out what pkg-config says about the rustls package. | |
- name: Debug pkg-config | |
run: | | |
pkg-config --cflags rustls | |
pkg-config --libs rustls | |
# Set up the cmake build, no pkg-config ENV overrides needed. | |
- name: Setup cmake build | |
run: cmake -S librustls -B build -DCMAKE_BUILD_TYPE=Release -DFORCE_SYSTEM_RUSTLS=ON | |
# Build the client and server binaries | |
- name: Build rustls-ffi client/server | |
run: cmake --build build -v | |
# Run the rustls-ffi client binary. | |
- name: Run rustls-ffi client | |
env: | |
RUSTLS_PLATFORM_VERIFIER: 1 | |
run: ./build/tests/client example.com 443 / 1 |