yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Gangzheng TongAdd timeout to CI jobs; add mimalloc to .gitignore (#8538)55a7d2a73

master
9.0 KiB222 linesraw
1name: CI Build Workflow
2
3on:
4  workflow_call:
5    inputs:
6      os:
7        required: true
8        type: string
9      compiler:
10        required: true
11        type: string
12      platform:
13        required: true
14        type: string
15      config:
16        required: true
17        type: string
18      runs-on:
19        required: true
20        type: string
21      warnings-as-errors:
22        required: false
23        type: boolean
24        default: true
25      build-llvm:
26        required: false
27        type: boolean
28        default: true
29      server-count:
30        required: false
31        type: number
32        default: 8
33
34jobs:
35  build:
36    runs-on: ${{ fromJSON(inputs.runs-on) }}
37    timeout-minutes: 60
38
39    defaults:
40      run:
41        shell: bash
42
43    steps:
44      - uses: actions/checkout@v4
45        with:
46          submodules: "recursive"
47          fetch-depth: "2"
48
49      - name: Setup
50        uses: ./.github/actions/common-setup
51        with:
52          os: ${{ inputs.os }}
53          compiler: ${{ inputs.compiler }}
54          platform: ${{ inputs.platform }}
55          config: ${{ inputs.config }}
56          build-llvm: ${{ inputs.build-llvm }}
57
58      # Don't need to check this on every config
59      - name: Check Stable Names Table
60        if: ${{ inputs.os == 'linux' && inputs.config == 'debug' }}
61        run: ./extras/check-ir-stable-names-gh-actions.sh
62
63      - name: Check Version Constants
64        id: check-ir-versions
65        if: ${{ inputs.os == 'linux' && inputs.config == 'debug' && github.event_name == 'pull_request' }}
66        env:
67          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68          GITHUB_EVENT_NAME: ${{ github.event_name }}
69          GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
70          GITHUB_BASE_REF: ${{ github.base_ref }}
71        run: ./extras/check-inst-version-changes.sh
72
73      - name: Upload IR version check results
74        if: ${{ steps.check-ir-versions.outputs.artifact_created == 'true' }}
75        uses: actions/upload-artifact@v4
76        with:
77          name: ir-version-check-results
78          path: ir-version-check-artifact/
79          retention-days: 1
80
81      - name: Build Slang
82        run: |
83          echo "cmake version: $(cmake --version)"
84
85          # Show ccache status if available
86          if command -v ccache &> /dev/null; then
87            echo "🔧 ccache configuration:"
88            ccache --show-config | head -20 || true
89            echo "📊 ccache statistics (pre-build):"
90            ccache --show-stats || true
91          else
92            echo "â„šī¸  ccache not available"
93          fi
94
95          if [[ "${{ inputs.platform }}" == "wasm" ]]; then
96            git clone https://github.com/emscripten-core/emsdk.git
97            pushd emsdk
98              ./emsdk install latest
99              ./emsdk activate latest
100              source ./emsdk_env.sh
101            popd
102            cmake --workflow --preset generators --fresh
103            mkdir generators
104            cmake --install build --config Release --component generators --prefix generators
105            emcmake cmake -DSLANG_GENERATORS_PATH=generators/bin --preset emscripten -DSLANG_SLANG_LLVM_FLAVOR=DISABLE
106            cmake --build --preset emscripten --config "$cmake_config" --target slang-wasm
107            mkdir "build.em/$cmake_config/bin/smoke"
108            cp tests/wasm/smoke/* "build.em/$cmake_config/bin/smoke/"
109            cd "build.em/$cmake_config/bin"
110            [ -f "slang-wasm.wasm" ]
111            [ -f "slang-wasm.js" ]
112            node smoke/smoke-test.js smoke/rand_float.slang computeMain
113          else
114            # Prepare ccache launcher arguments if ccache is available
115            cmake_launcher_defines=()
116            if [[ -n "${ccache_symlinks_path:-}" ]]; then
117              echo "🔧 Using ccache with launcher: ${ccache_symlinks_path}"
118              echo "🔧 CCACHE_DIR is set to: ${CCACHE_DIR:-'not set'}"
119              cmake_launcher_defines+=("-DCMAKE_C_COMPILER_LAUNCHER=${ccache_symlinks_path}")
120              cmake_launcher_defines+=("-DCMAKE_CXX_COMPILER_LAUNCHER=${ccache_symlinks_path}")
121            else
122              echo "â„šī¸  ccache_symlinks_path not set - building without ccache"
123            fi
124
125            if [[ "${{ inputs.os }}" =~ "windows" && "${{ inputs.config }}" == "debug" ]]; then
126              # Doing a debug build will try to link against a release built llvm, this
127              # is a problem on Windows, so make slang-llvm in release build and use
128              # that as though it's a fetched binary via these presets.
129              cmake --workflow --preset slang-llvm
130              
131              # Configure, pointing to our just-generated slang-llvm archive
132              cmake --preset default --fresh \
133                -DSLANG_SLANG_LLVM_FLAVOR=FETCH_BINARY \
134                "-DSLANG_SLANG_LLVM_BINARY_URL=$(pwd)/build/dist-release/slang-llvm.zip" \
135                "-DCMAKE_COMPILE_WARNING_AS_ERROR=${{ inputs.warnings-as-errors }}" \
136                "${cmake_launcher_defines[@]}"
137              cmake --workflow --preset "${{ inputs.config }}"
138            elif [[ "${{ inputs.build-llvm }}" = "false" ]]; then
139              # linux aarch64 cannot build llvm.
140              cmake --preset default --fresh \
141                -DSLANG_SLANG_LLVM_FLAVOR=DISABLE \
142                -DCMAKE_COMPILE_WARNING_AS_ERROR=${{ inputs.warnings-as-errors }} \
143                "${cmake_launcher_defines[@]}"
144              cmake --workflow --preset "${{ inputs.config }}"
145            else
146              # Otherwise, use the "system" llvm we have just build or got from the
147              # cache in the setup phase
148              cmake --preset default --fresh \
149                -DSLANG_SLANG_LLVM_FLAVOR=USE_SYSTEM_LLVM \
150                -DCMAKE_COMPILE_WARNING_AS_ERROR=${{ inputs.warnings-as-errors }} \
151                "${cmake_launcher_defines[@]}"
152              cmake --workflow --preset "${{ inputs.config }}"
153            fi
154          fi
155
156          # Show ccache statistics after build
157          if command -v ccache &> /dev/null; then
158            echo "📊 ccache statistics (post-build):"
159            ccache --show-stats || true
160          fi
161
162      - name: Check documented compiler versions
163        run: bash extras/verify-documented-compiler-version.sh
164
165      - name: Prepare artifacts for upload
166        run: |
167          # Create a staging directory for artifacts with config-specific subdirectory
168          mkdir -p "artifacts-staging/${cmake_config}"
169
170          # Copy artifacts from the specific configuration directory
171          if [ -d "build/${cmake_config}" ]; then
172            echo "Copying artifacts from build/${cmake_config} to github_artifact/${cmake_config}..."
173            
174            # Copy bin directory excluding debug files
175            if [ -d "build/${cmake_config}/bin" ]; then
176              mkdir -p "artifacts-staging/${cmake_config}/bin"
177              find "build/${cmake_config}/bin" -type f ! -name "*.pdb" ! -name "*.ilk" ! -name "*.dwarf" ! -name "*.debug" ! -name "*.dSYM" -exec cp {} "artifacts-staging/${cmake_config}/bin/" \; || echo "Failed to copy bin directory"
178
179              cp -r "build/${cmake_config}/bin/D3D12" "artifacts-staging/${cmake_config}/bin/" || echo "Failed to copy bin/D3D12 directory"
180            fi
181            
182            # Copy everything from lib directory
183            if [ -d "build/${cmake_config}/lib" ]; then
184              cp -r "build/${cmake_config}/lib" "artifacts-staging/${cmake_config}/" || echo "Failed to copy lib directory"
185            fi
186            
187            # Copy share directory if it exists
188            if [ -d "build/${cmake_config}/share" ]; then
189              cp -r "build/${cmake_config}/share" "artifacts-staging/${cmake_config}/" || echo "Failed to copy share directory"
190            fi
191            
192            # Copy include directory if it exists
193            if [ -d "build/${cmake_config}/include" ]; then
194              cp -r "build/${cmake_config}/include" "artifacts-staging/${cmake_config}/" || echo "Failed to copy include directory"
195            fi
196            
197            # Copy examples directory if it exists (contains shader files for examples)
198            if [ -d "build/examples" ]; then
199              cp -r "build/examples" "artifacts-staging/" || echo "Failed to copy examples directory"
200            fi
201            
202          echo "Artifacts staging directory contents (recursive):"
203          ls -laR artifacts-staging/
204          else
205            echo "Configuration directory build/${cmake_config} not found!"
206            echo "Available build directories:"
207            ls -la build/ || echo "No build directory found"
208            exit 1
209          fi
210
211      - uses: actions/upload-artifact@v4
212        with:
213          name: slang-build-${{ inputs.os }}-${{ inputs.platform }}-${{ inputs.compiler }}-${{ inputs.config }}
214          path: |
215            build/dist-${{inputs.config}}/**/ZIP/slang/*
216            build.em/Release
217
218      - uses: actions/upload-artifact@v4
219        with:
220          name: slang-tests-${{ inputs.os }}-${{ inputs.platform }}-${{ inputs.compiler }}-${{ inputs.config }}
221          path: artifacts-staging/
222          retention-days: 1