feat: add clang-18 support with generic version detection

- Add clang-18-libcxx configuration (6 compiler configs total)
- Generic Conan settings patcher: auto-detects Clang version from compiler-id
- Works for any future Clang version without code changes
- Change minimal matrix to use clang-14 instead of clang-17 (faster)
- Sort Conan version list numerically when adding new versions

[ci-nix-full-matrix]
This commit is contained in:
Nicholas Dudfield
2025-08-19 13:54:46 +07:00
parent 3571a403f6
commit 7ced4de6f2
2 changed files with 60 additions and 6 deletions

View File

@@ -69,6 +69,49 @@ runs:
conan export external/snappy snappy/1.1.10@xahaud/stable
conan export external/soci soci/4.0.3@xahaud/stable
- name: Add Clang version support to Conan if needed
if: contains(inputs.compiler-id, 'clang-')
shell: bash
run: |
# Extract Clang version from compiler-id (e.g., "clang-18-libcxx" -> "18")
COMPILER_ID="${{ inputs.compiler-id }}"
CLANG_VERSION=$(echo "$COMPILER_ID" | sed -n 's/^clang-\([0-9]\+\).*/\1/p')
if [ -n "$CLANG_VERSION" ]; then
echo "Detected Clang version $CLANG_VERSION from compiler-id"
pip install PyYAML
python << EOF
import yaml
from pathlib import Path
import os
clang_version = os.environ.get('CLANG_VERSION', '')
if not clang_version:
print("No Clang version detected")
exit(0)
settings_path = Path.home() / '.conan' / 'settings.yml'
with open(settings_path, 'r') as f:
settings = yaml.safe_load(f)
# Add the detected version to clang versions if not already there
clang_versions = settings['compiler']['clang']['version']
if clang_version not in clang_versions:
clang_versions.append(clang_version)
# Sort versions numerically
clang_versions.sort(key=lambda x: int(x) if x.isdigit() else float('inf'))
with open(settings_path, 'w') as f:
yaml.dump(settings, f, default_flow_style=False, sort_keys=False)
print(f"Added Clang {clang_version} support to Conan settings")
else:
print(f"Clang {clang_version} already supported in Conan settings")
EOF
export CLANG_VERSION
else
echo "No Clang version found in compiler-id: $COMPILER_ID"
fi
- name: Install dependencies
shell: bash
run: |

View File

@@ -24,7 +24,7 @@ jobs:
import json
import os
# Full matrix with all 5 compiler configurations
# Full matrix with all 6 compiler configurations
# Each configuration includes all parameters needed by the build job
full_matrix = [
{
@@ -73,13 +73,24 @@ jobs:
"compiler_version": 17,
"stdlib": "libcxx",
"configuration": "Debug"
},
{
# Clang 18 - testing if it's faster than Clang 17 with libc++
# Requires patching Conan v1 settings.yml to add version 18
"compiler_id": "clang-18-libcxx",
"compiler": "clang",
"cc": "clang-18",
"cxx": "clang++-18",
"compiler_version": 18,
"stdlib": "libcxx",
"configuration": "Debug"
}
]
# Minimal matrix for PRs and feature branches (newest gcc + newest clang)
# Minimal matrix for PRs and feature branches
minimal_matrix = [
full_matrix[1], # gcc-13
full_matrix[4] # clang-17
full_matrix[1], # gcc-13 (middle-ground gcc)
full_matrix[2] # clang-14 (mature, stable clang)
]
# Determine which matrix to use based on the target branch
@@ -111,9 +122,9 @@ jobs:
# Select the appropriate matrix
if use_full:
if force_full:
print(f"Using FULL matrix (5 configs) - forced by [ci-nix-full-matrix] tag")
print(f"Using FULL matrix (6 configs) - forced by [ci-nix-full-matrix] tag")
else:
print(f"Using FULL matrix (5 configs) - targeting main branch")
print(f"Using FULL matrix (6 configs) - targeting main branch")
matrix = full_matrix
else:
print(f"Using MINIMAL matrix (2 configs) - feature branch/PR")