David Duarte 188a8cb3b4
ci: Make the install-{mesa,vulkan-sdk} action multiplatform (#8167)
This also allow to remove the MESA_VERSION and VULKAN_SDK_VERSION
duplication between the ci workflow and the install action.

To pass down the version in each steps, I added action inputs
because there is no way as of today to define environments
variables that are shared between steps in composite actions
(no top level `env:` like for workflows).
2025-08-29 18:53:43 -04:00

62 lines
2.3 KiB
YAML

name: 'Install Mesa'
description: 'Install Mesa'
inputs:
# Sourced from https://archive.mesa3d.org/. Bumping this requires
# updating the mesa build in https://github.com/gfx-rs/ci-build and creating a new release.
version:
default: '24.3.4'
# Corresponds to https://github.com/gfx-rs/ci-build/releases
ci-binary-build:
default: 'build20'
runs:
using: 'composite'
steps:
- name: (Linux) Install Mesa
if: runner.os == 'Linux'
shell: bash
env:
MESA_VERSION: ${{ inputs.version }}
CI_BINARY_BUILD: ${{ inputs.ci-binary-build }}
run: |
set -e
curl -L --retry 5 https://github.com/gfx-rs/ci-build/releases/download/$CI_BINARY_BUILD/mesa-$MESA_VERSION-linux-x86_64.tar.xz -o mesa.tar.xz
mkdir mesa
tar xpf mesa.tar.xz -C mesa
# The ICD provided by the mesa build is hardcoded to the build environment.
#
# We write out our own ICD file to point to the mesa vulkan
cat <<- EOF > icd.json
{
"ICD": {
"api_version": "1.1.255",
"library_path": "$PWD/mesa/lib/x86_64-linux-gnu/libvulkan_lvp.so"
},
"file_format_version": "1.0.0"
}
EOF
echo "VK_DRIVER_FILES=$PWD/icd.json" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=$PWD/mesa/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH" >> "$GITHUB_ENV"
echo "LIBGL_DRIVERS_PATH=$PWD/mesa/lib/x86_64-linux-gnu/dri" >> "$GITHUB_ENV"
- name: (Windows) Install Mesa
if: runner.os == 'Windows'
shell: bash
env:
MESA_VERSION: ${{ inputs.version }}
CI_BINARY_BUILD: ${{ inputs.ci-binary-build }}
run: |
set -e
curl.exe -L --retry 5 https://github.com/pal1000/mesa-dist-win/releases/download/$MESA_VERSION/mesa3d-$MESA_VERSION-release-msvc.7z -o mesa.7z
7z.exe e mesa.7z -omesa x64/{opengl32.dll,libgallium_wgl.dll,libglapi.dll,vulkan_lvp.dll,lvp_icd.x86_64.json}
cp -v mesa/* target/llvm-cov-target/debug/
cp -v mesa/* target/llvm-cov-target/debug/deps
# We need to use cygpath to convert PWD to a windows path as we're using bash.
echo "VK_DRIVER_FILES=`cygpath --windows $PWD/mesa/lvp_icd.x86_64.json`" >> "$GITHUB_ENV"
echo "GALLIUM_DRIVER=llvmpipe" >> "$GITHUB_ENV"