mirror of
https://github.com/Xahau/xahaud.git
synced 2026-06-03 08:46:36 +00:00
refactor: move Conan patching to separate action
- Create new xahau-patch-conan-clang-versions action - Remove patching logic from dependencies action - Call patch action after Conan initialization in main workflow - Fixes sequencing issue where settings.yml didn't exist yet
This commit is contained in:
43
.github/actions/xahau-ga-dependencies/action.yml
vendored
43
.github/actions/xahau-ga-dependencies/action.yml
vendored
@@ -69,49 +69,6 @@ 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: python
|
||||
run: |
|
||||
import yaml
|
||||
import re
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
# Extract Clang version from compiler-id (e.g., "clang-18-libcxx" -> "18")
|
||||
compiler_id = "${{ inputs.compiler-id }}"
|
||||
match = re.match(r'^clang-(\d+)', compiler_id)
|
||||
|
||||
if not match:
|
||||
print(f"No Clang version found in compiler-id: {compiler_id}")
|
||||
exit(0)
|
||||
|
||||
clang_version = match.group(1)
|
||||
print(f"Detected Clang version {clang_version} from compiler-id")
|
||||
|
||||
settings_path = Path.home() / '.conan' / 'settings.yml'
|
||||
|
||||
# Initialize Conan if settings.yml doesn't exist yet
|
||||
if not settings_path.exists():
|
||||
print("Conan not initialized, creating default profile...")
|
||||
subprocess.run(['conan', 'profile', 'new', 'default', '--detect'], check=False)
|
||||
|
||||
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")
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
53
.github/actions/xahau-patch-conan-clang-versions/action.yml
vendored
Normal file
53
.github/actions/xahau-patch-conan-clang-versions/action.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: patch-conan-clang-versions
|
||||
description: 'Patch Conan settings.yml to support newer Clang versions'
|
||||
|
||||
inputs:
|
||||
compiler-id:
|
||||
description: 'Unique identifier: compiler-version-stdlib[-gccversion] (e.g. clang-18-libcxx)'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Add Clang version support to Conan if needed
|
||||
if: contains(inputs.compiler-id, 'clang-')
|
||||
shell: python
|
||||
run: |
|
||||
import yaml
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
# Extract Clang version from compiler-id (e.g., "clang-18-libcxx" -> "18")
|
||||
compiler_id = "${{ inputs.compiler-id }}"
|
||||
match = re.match(r'^clang-(\d+)', compiler_id)
|
||||
|
||||
if not match:
|
||||
print(f"No Clang version found in compiler-id: {compiler_id}")
|
||||
exit(0)
|
||||
|
||||
clang_version = match.group(1)
|
||||
print(f"Detected Clang version {clang_version} from compiler-id")
|
||||
|
||||
settings_path = Path.home() / '.conan' / 'settings.yml'
|
||||
|
||||
# Check if settings.yml exists
|
||||
if not settings_path.exists():
|
||||
print(f"ERROR: Conan settings.yml not found at {settings_path}")
|
||||
print("Conan must be initialized before patching settings")
|
||||
exit(1)
|
||||
|
||||
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")
|
||||
5
.github/workflows/xahau-ga-nix.yml
vendored
5
.github/workflows/xahau-ga-nix.yml
vendored
@@ -250,6 +250,11 @@ jobs:
|
||||
# Display profile for verification
|
||||
conan profile show default
|
||||
|
||||
- name: Patch Conan for newer Clang versions
|
||||
uses: ./.github/actions/xahau-patch-conan-clang-versions
|
||||
with:
|
||||
compiler-id: ${{ matrix.compiler_id }}
|
||||
|
||||
- name: Check environment
|
||||
run: |
|
||||
echo "PATH:"
|
||||
|
||||
Reference in New Issue
Block a user