yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
570277137
master
1name : Common setup 2 3description : Performs setup common to all our actions 4 5inputs : 6os : 7required : true 8compiler : 9required : true 10platform : 11required : true 12config : 13required : true 14build-llvm : 15required : true 16runs : 17using : composite 18steps : 19- name : Add bash to PATH 20shell : pwsh 21if : ${{inputs.os == 'windows'}} 22run : | 23Add-Content -Path $env:GITHUB_PATH -Value "C:\\Program Files\\Git\\bin" 24Add-Content -Path $env:GITHUB_PATH -Value "C:\\Program Files\\Git\\usr\\bin" 25 26- name : Set up MSVC dev tools on Windows 27uses : ilammy/msvc-dev-cmd@v1 28 29- name : Install dependencies (Linux only) 30if : inputs.os == 'linux' 31shell : bash 32run : | 33sudo apt-get update 34sudo apt-get install -y libx11-dev 35 36- name : Setup Node.js (Linux only) 37if : inputs.os == 'linux' 38uses : actions/setup-node@v4 39with : 40node-version : "20.x" 41 42- shell : bash 43run : | 44# Set up system dependencies 45 46# Install Ninja 47if ! command -v ninja; then 48case "${{inputs.os}}" in 49linux*) sudo apt-get install -y ninja-build;; 50windows*) choco install ninja;; 51macos*) brew install ninja;; 52esac 53fi 54 55# Install cross tools on Ubuntu 56if [[ "${{inputs.os}}" == linux* && "${{inputs.platform}}" == "aarch64" && "$(uname -m)" != "aarch64" ]]; then 57sudo apt-get install -y crossbuild-essential-arm64 58fi 59 60# Set compiler 61CC=${{inputs.compiler}} 62CXX=${{inputs.compiler}} 63# infer C++ compiler 64CXX=${CXX/gcc/g++} 65CXX=${CXX/clang/clang++} 66# Correct gcc version on older ubuntu 67if [[ "${{inputs.os}}" == linux* ]]; then 68gcc_version=$(gcc -dumpversion | cut -d'.' -f1) 69if [ "$gcc_version" -lt 10 ]; then 70CC=${CC/gcc/gcc-10} 71CXX=${CXX/g++/g++-10} 72fi 73fi 74# Export 75echo "CC=$CC" >> "$GITHUB_ENV" 76echo "CXX=$CXX" >> "$GITHUB_ENV" 77 78# Some useful variables 79config=${{inputs.config}} 80cmake_config=$(echo "${{inputs.config}}" | sed ' 81s/^debug$/Debug/ 82s/^release$/Release/ 83s/^releaseWithDebugInfo$/RelWithDebInfo/ 84s/^minSizeRelease$/MinSizeRel/ 85') 86bin_dir=$(pwd)/build/$cmake_config/bin 87lib_dir=$(pwd)/build/$cmake_config/lib 88echo "config=$config" >> "$GITHUB_ENV" 89echo "cmake_config=$cmake_config" >> "$GITHUB_ENV" 90echo "bin_dir=$bin_dir" >> "$GITHUB_ENV" 91echo "lib_dir=$lib_dir" >> "$GITHUB_ENV" 92 93# Try to restore an LLVM install, and build it otherwise 94- uses : actions/cache/restore@v4 95id : cache-llvm 96if : inputs.build-llvm == 'true' 97with : 98path : build/llvm-project-install 99# Use os*compiler*platform in lieu of an ABI key here, which is what we really want 100key : llvm-${{ inputs.os }}-${{ inputs.compiler }}-${{ inputs.platform }}-${{ hashFiles('external/build-llvm.sh') }} 101- name : Build LLVM 102if : inputs.build-llvm == 'true' && steps.cache-llvm.outputs.cache-hit != 'true' 103shell : bash 104run : | 105./external/build-llvm.sh \ 106--install-prefix "${{github.workspace}}/build/llvm-project-install" \ 107--repo "https://${{github.token}}@github.com/llvm/llvm-project" 108- uses : actions/cache/save@v4 109if : inputs.build-llvm == 'true' && steps.cache-llvm.outputs.cache-hit != 'true' 110with : 111path : build/llvm-project-install 112key : ${{ steps.cache-llvm.outputs.cache-primary-key }} 113 114- name : Set environment variable for CMake 115shell : bash 116run : | 117if [ "${{inputs.build-llvm}}" == "true" ]; then 118echo "LLVM_DIR=${{ github.workspace }}/build/llvm-project-install" >> "$GITHUB_ENV" 119echo "Clang_DIR=${{ github.workspace }}/build/llvm-project-install" >> "$GITHUB_ENV" 120fi 121 122# Put spirv-tools in path 123- shell : bash 124run : | 125win_platform="${{ inputs.platform }}" 126win_platform="${win_platform//x86_64/x64}" 127case "${{inputs.os}}" in 128windows*) echo "${{github.workspace}}/external/slang-binaries/spirv-tools/windows-$win_platform/bin" >> "$GITHUB_PATH";; 129linux*) echo "${{github.workspace}}/external/slang-binaries/spirv-tools/$(uname -m)-linux/bin" >> "$GITHUB_PATH";; 130esac 131 132# Setup ccache for local compilation speedup (Windows self-hosted only) 133# Only use ccache if already installed - don't attempt installation 134- name : Setup ccache (if available, local only, no GitHub uploads) 135if : ${{ inputs.os == 'windows' && runner.environment == 'self-hosted' }} 136shell : bash 137run : | 138 # Check if ccache is available 139 if ! command -v ccache &> /dev/null; then 140 echo "⚠️ ccache not found on this self-hosted runner" 141 echo " Skipping ccache setup to avoid permission issues" 142 echo " Build will proceed without ccache acceleration" 143 echo " To enable ccache: manually install it on the runner with admin rights" 144 exit 0 145 fi 146 147 echo "✅ ccache found on self-hosted runner - setting up persistent caching" 148 149 # Set ccache directory to a persistent location outside workspace 150 if [[ "${{ inputs.os }}" == "windows" ]]; then 151 ccache_base_dir="C:/ccache-slang" 152 else 153 # Linux/macOS: Use home directory for persistence 154 ccache_base_dir="$HOME/.ccache-slang" 155 fi 156 ccache_dir="$ccache_base_dir/${{ inputs.os }}-${{ inputs.compiler }}-${{ inputs.platform }}" 157 mkdir -p "$ccache_dir" 158 echo "CCACHE_DIR=$ccache_dir" >> $GITHUB_ENV 159 echo "🔧 Using persistent ccache directory: $ccache_dir" 160 161 # Configure ccache settings for local use only 162 ccache --set-config=max_size=20G 163 ccache --set-config=compression=true 164 ccache --set-config=compression_level=6 165 ccache --set-config=sloppiness=pch_defines,time_macros 166 ccache --set-config=cache_dir="$ccache_dir" 167 168 # Enable ccache for CMake (set environment variables) 169 # Get the full path to ccache executable 170 ccache_path=$(which ccache) 171 echo "ccache_symlinks_path=$ccache_path" >> $GITHUB_ENV