# Copyright 2023-2026, Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause

name: Compiler Warnings

permissions: read-all

on:
  pull_request:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  clang:
    runs-on: ubuntu-24.04

    steps:
    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      with:
        submodules: true

    - name: Install dependencies
      run: |
        .github/workflows/scripts/install-build-deps.sh

    - name: Check environment
      run: |
        cat /proc/cpuinfo
        which -a clang
        clang -v

    - name: Build ISPC with clang in -Werror mode
      run: |
          cmake \
            -B build \
            -DCMAKE_C_COMPILER=clang \
            -DCMAKE_CXX_COMPILER=clang++ \
            -DCMAKE_C_FLAGS="-Werror" \
            -DCMAKE_CXX_FLAGS="-Werror"
          cmake --build build --target all -j4

  gcc-13:
    runs-on: ubuntu-24.04

    steps:
    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      with:
        submodules: true

    - name: Install dependencies
      run: |
        .github/workflows/scripts/install-build-deps.sh

    - name: Check environment
      run: |
        cat /proc/cpuinfo
        which -a clang
        gcc-13 -v

    - name: Build ISPC with gcc in -Werror mode
      run: |
          cmake \
            -B build \
            -DCMAKE_C_COMPILER=gcc-13 \
            -DCMAKE_CXX_COMPILER=g++-13 \
            -DCMAKE_C_FLAGS="-Werror" \
            -DCMAKE_CXX_FLAGS="-Werror"
          cmake --build build --target all -j4

  msvc-2022:
    runs-on: windows-2022

    steps:
    - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      with:
        submodules: true

    - name: Install dependencies
      run: |
        .github/workflows/scripts/install-build-deps.ps1

    - name: Check environment
      shell: cmd
      run: |
        wmic cpu get caption, deviceid, name, numberofcores, maxclockspeed, status

    - name: Build ISPC with MSVC in -Werror mode
      shell: cmd
      run: |
        cmake ^
          -B build ^
          -DISPC_PREPARE_PACKAGE=ON ^
          -DCMAKE_C_FLAGS="/WX" ^
          -DCMAKE_CXX_FLAGS="/WX" ^
          -DISPC_CROSS=ON ^
          -DCMAKE_BUILD_TYPE=Release ^
          -DISPC_GNUWIN32_PATH=%CROSS_TOOLS_GNUWIN32%
        cmake --build build --target package -j4 --config Release
