@@ -1311,30 +1311,49 @@ jobs:
13111311
13121312 - name : Fetch SDL2 and set SDL2_DIR
13131313 if : matrix.sdl2 == 'ON'
1314+ shell : pwsh
13141315 run : |
1315- C:/msys64/usr/bin/wget.exe -qO sdl2.zip https://github.com/libsdl-org/SDL/releases/download/release-${{ matrix.s2ver }}/SDL2-devel-${{ matrix.s2ver }}-VC.zip
1316+ $sdlVer = "${{ matrix.s2ver }}"
1317+ $url = "https://github.com/libsdl-org/SDL/releases/download/release-$sdlVer/SDL2-devel-$sdlVer-VC.zip"
1318+
1319+ Write-Host "Downloading SDL2 from $url..."
1320+ Invoke-WebRequest -Uri $url -OutFile "sdl2.zip"
1321+
1322+ Write-Host "Extracting SDL2..."
13161323 7z x sdl2.zip
1317- echo "SDL2_DIR=$env:GITHUB_WORKSPACE/SDL2-${{ matrix.s2ver }}/cmake" >> $env:GITHUB_ENV
13181324
1319- # Patch SDL_endian.h
1320- # This specifically fixes the "definition of builtin function '_m_prefetch'" error
1321- $headerPath = "$env:GITHUB_WORKSPACE/SDL2-${{ matrix.s2ver }}/include/SDL_endian.h"
1322- if (Test-Path $headerPath) {
1323- Write-Host "Found SDL_endian.h at $headerPath. Patching..."
1324- $content = Get-Content $headerPath -Raw
1325+ # Find the CMake directory dynamically to ensure variable is correct
1326+ $cmakeDir = Get-ChildItem -Path . -Recurse -Filter "sdl2-config.cmake" | Select-Object -First 1 | ForEach-Object { $_.DirectoryName }
1327+ if ($cmakeDir) {
1328+ Write-Host "Found SDL2 CMake dir at: $cmakeDir"
1329+ echo "SDL2_DIR=$cmakeDir" >> $env:GITHUB_ENV
1330+ } else {
1331+ Write-Error "Could not find sdl2-config.cmake inside extracted files!"
1332+ }
1333+
1334+ # Fix _m_prefetch error
1335+ Write-Host "Searching for SDL_endian.h..."
1336+ $headerFile = Get-ChildItem -Path . -Recurse -Filter "SDL_endian.h" | Select-Object -First 1
1337+
1338+ if ($headerFile) {
1339+ Write-Host "Found header at: $($headerFile.FullName)"
1340+ $content = Get-Content $headerFile.FullName -Raw
13251341
1326- # Replace the conflicting line with a comment
13271342 if ($content -match 'extern void _m_prefetch') {
13281343 $content = $content -replace 'extern void _m_prefetch\(void \*__P\);', '// extern void _m_prefetch(void *__P);'
1329- Set-Content -Path $headerPath -Value $content
1344+ Set-Content -Path $headerFile.FullName -Value $content
13301345 Write-Host "SUCCESS: Patched _m_prefetch in SDL_endian.h"
13311346 } else {
1332- Write-Host "WARNING: _m_prefetch string not found in header. Verify SDL version."
1347+ Write-Host "WARNING: _m_prefetch string not found in header. It might already be patched or this version differs ."
13331348 }
13341349 } else {
1335- Write-Error "ERROR: Could not find SDL_endian.h to patch!"
1350+ # Debugging: List directories to see what happened
1351+ Write-Host "Listing root directories:"
1352+ Get-ChildItem -Path . -Directory | Format-Table Name
1353+ Write-Error "FATAL: Could not locate SDL_endian.h in the workspace."
1354+ exit 1
13361355 }
1337- # ----------------------------------------
1356+ # -------------------------------------------
13381357
13391358 - name : Download ROCm nightly tarball
13401359 run : |
0 commit comments