|
| 1 | +name: Bundle portable Windows gcc (MinGW-w64) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + |
| 9 | +jobs: |
| 10 | + bundle: |
| 11 | + runs-on: windows-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Download WinLibs portable gcc |
| 16 | + shell: powershell |
| 17 | + run: | |
| 18 | + $url = "https://github.com/brechtsanders/winlibs_mingw/releases/download/14.2.0posix-19.1.1-12.0.0-ucrt-r2/winlibs-x86_64-posix-seh-gcc-14.2.0-mingw-w64ucrt-12.0.0-r2.zip" |
| 19 | + Write-Host "Downloading WinLibs gcc..." |
| 20 | + Invoke-WebRequest -Uri $url -OutFile gcc.zip -UseBasicParsing |
| 21 | + Write-Host "Extracting..." |
| 22 | + Expand-Archive gcc.zip -DestinationPath gcc_extracted |
| 23 | +
|
| 24 | + - name: Extract minimal toolchain |
| 25 | + shell: powershell |
| 26 | + run: | |
| 27 | + # We only need the compiler and its immediate runtime deps. |
| 28 | + # Full mingw64 is ~700MB -- extract just what's needed to compile. |
| 29 | + $src = "gcc_extracted\mingw64" |
| 30 | + $dst = "libs\windows-x64\gcc" |
| 31 | + New-Item -ItemType Directory -Force -Path $dst |
| 32 | +
|
| 33 | + # Essential compiler binaries |
| 34 | + $bins = @("g++.exe", "gcc.exe", "as.exe", "ld.exe", "windres.exe", |
| 35 | + "cpp.exe", "cc1.exe", "cc1plus.exe", "collect2.exe", |
| 36 | + "libgcc_s_seh-1.dll", "libstdc++-6.dll", "libwinpthread-1.dll", |
| 37 | + "libgomp-1.dll") |
| 38 | + foreach ($b in $bins) { |
| 39 | + $f = Get-ChildItem -Path $src -Recurse -Filter $b -ErrorAction SilentlyContinue | Select-Object -First 1 |
| 40 | + if ($f) { Copy-Item $f.FullName -Destination $dst; Write-Host "Copied $b" } |
| 41 | + } |
| 42 | +
|
| 43 | + # Runtime libraries needed by compiled sketches |
| 44 | + Copy-Item "$src\bin\libgcc_s_seh-1.dll" $dst -ErrorAction SilentlyContinue |
| 45 | + Copy-Item "$src\bin\libstdc++-6.dll" $dst -ErrorAction SilentlyContinue |
| 46 | + Copy-Item "$src\bin\libwinpthread-1.dll" $dst -ErrorAction SilentlyContinue |
| 47 | +
|
| 48 | + # Include dirs (needed at compile time) |
| 49 | + Copy-Item "$src\include" "$dst\include" -Recurse -Force |
| 50 | + Copy-Item "$src\lib\gcc" "$dst\lib\gcc" -Recurse -Force |
| 51 | + Copy-Item "$src\lib\libstdc++*" "$dst\lib\" -Force -ErrorAction SilentlyContinue |
| 52 | + Copy-Item "$src\lib\libgcc*" "$dst\lib\" -Force -ErrorAction SilentlyContinue |
| 53 | + Copy-Item "$src\lib\libwinpthread*" "$dst\lib\" -Force -ErrorAction SilentlyContinue |
| 54 | + Copy-Item "$src\lib\crt*" "$dst\lib\" -Force -ErrorAction SilentlyContinue |
| 55 | +
|
| 56 | + Write-Host "Done. Size:" |
| 57 | + (Get-ChildItem $dst -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB |
| 58 | +
|
| 59 | + - name: Commit to repo |
| 60 | + shell: powershell |
| 61 | + run: | |
| 62 | + git config user.name "github-actions[bot]" |
| 63 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 64 | + git add libs/windows-x64/gcc/ |
| 65 | + git diff --staged --quiet |
| 66 | + if ($LASTEXITCODE -ne 0) { |
| 67 | + git commit -m "ci: bundle portable MinGW-w64 gcc for Windows" |
| 68 | + git push |
| 69 | + } else { |
| 70 | + Write-Host "No changes to commit" |
| 71 | + } |
0 commit comments