-
Notifications
You must be signed in to change notification settings - Fork 0
194 lines (167 loc) · 8.31 KB
/
Copy pathgfortran-on-windows.yaml
File metadata and controls
194 lines (167 loc) · 8.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: GFortran on Windows
run-name: minpack compiled with GFortran from MSYS2 on Windows
on:
push:
paths-ignore:
- "**/*.md"
- "doc/**"
pull_request:
paths-ignore:
- "**/*.md"
- "doc/**"
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
USE_DOWNLOAD: ['OFF']
CMAKE_BUILD_TYPE: ['Release', 'Debug']
LIBRARY_KIND: ['SHARED', 'STATIC']
MSYS2_CONFIG: [{ sys: mingw64, env: x86_64, fc: gfortran.exe }, { sys: ucrt64, env: ucrt-x86_64, fc: gfortran.exe }]
env:
# Fortran compiler + C compiler + GNU Make
MSYS2_PACKAGES_TO_INSTALL: "mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-fc mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-make"
steps:
- name: Restore MSYS2 (${{ matrix.MSYS2_CONFIG.env }}) packages
id: restore-msys2-packages
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: 'C:\msys64\tmp\*-${{ matrix.MSYS2_CONFIG.env }}-*'
key: minpack-builder-${{ matrix.MSYS2_CONFIG.env }}
# Here, instead of installing packages in the conventional way,
# we grab a list of mirrors for the environment (${{ matrix.MSYS2_CONFIG.env }}),
# then each package content is downloaded separetely from a different mirror.
# After all packages have been downloaded to disk, we install them.
#
# This workaround takes place to avoid a kind of "flooding" on the main MSYS2
# servers, due the amount of content we have to download in parallel builds.
- name: Download Fortran compiler + GNU Make
if: ${{ steps.restore-msys2-packages.outputs.cache-hit != 'true' }}
shell: pwsh
run: |
C:\msys64\usr\bin\bash.exe -lc "pacman -S ${{ env.MSYS2_PACKAGES_TO_INSTALL }} --print > /tmp/url.list"
C:\msys64\usr\bin\bash.exe -lc "for e in `$(cat /tmp/url.list); do echo `$(basename `$e); done" > $env:RUNNER_TEMP\packages.list
$raw_mirrors = New-Object 'System.Collections.Generic.List[string]';
Get-Content C:\msys64\etc\pacman.d\mirrorlist.${{ matrix.MSYS2_CONFIG.sys }} |
Where-Object { $_ -match "Server\s+=\s+https" } |
Foreach-Object {
$raw_mirrors.Add($_.Substring($_.IndexOf("https")));
}
$mirrors = $raw_mirrors.ToArray();
$ProgressPreference = 'SilentlyContinue';
[System.IO.File]::ReadAllLines((Get-Item $env:RUNNER_TEMP\packages.list).FullName) | ForEach-Object {
[System.Security.Cryptography.RandomNumberGenerator]::Shuffle[string]($mirrors);
$package = $_;
$retries = 0;
$success = $false;
$max_retries = $mirrors.Length;
$connection_timeout = 30;
$read_timeout = 1;
while ((-not $success) -and ($retries -lt $max_retries))
{
$mirror = $mirrors[$retries];
$uri = "${mirror}${package}";
if ($retries -gt 0)
{
C:\msys64\usr\bin\bash.exe -lc "echo -e '\e[32mRetry[\e[33m$retries\e[37m / \e[31m$max_retries\e[32m] >> \e[37mDownloading \e[35m$package\e[37m from \e[36m$uri\e[37m'";
}
else
{
Write-Host "Downloading $package from $uri";
}
try
{
Invoke-WebRequest -Uri $uri -MaximumRetryCount 0 -ConnectionTimeoutSeconds $connection_timeout -OperationTimeoutSeconds $read_timeout -OutFile C:\msys64\tmp\$package;
$success = $true;
}
catch
{
C:\msys64\usr\bin\bash.exe -lc "echo -e '\e[33mFailed to download $package from $mirror\e[37m'";
$retries++;
}
}
if (-not $success)
{
Write-Host "Failed to download $package";
exit 1;
}
}
- name: Save MSYS2 packages on cache
if: ${{ steps.restore-msys2-packages.outputs.cache-hit != 'true' }}
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: 'C:\msys64\tmp\*-${{ matrix.MSYS2_CONFIG.env }}-*'
key: minpack-builder-${{ matrix.MSYS2_CONFIG.env }}
- name: Install MSYS2 packages
run: |
C:\msys64\usr\bin\bash.exe -lc "pacman -U /tmp/*.pkg.tar.zst --noconfirm"
- name: Add MSYS2 tools to system environment PATH, and set FC environment variables
shell: pwsh
run: |
Add-Content $env:GITHUB_PATH "C:\msys64\${{ matrix.MSYS2_CONFIG.sys }}\bin"
Add-Content $env:GITHUB_ENV "FC=${{ matrix.MSYS2_CONFIG.fc }}"
- name: Restore assets
id: restore-assets
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: assets-cache
key: minpack-assets
enableCrossOsArchive: true
- name: Checkout assets
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
if: ${{ matrix.USE_DOWNLOAD=='OFF' && steps.restore-assets.outputs.cache-hit != 'true' }}
with:
ref: assets-ci-v1
path: assets
- name: Place minpack sources in the cache directory
if: ${{ matrix.USE_DOWNLOAD=='OFF' && steps.restore-assets.outputs.cache-hit != 'true' }}
shell: pwsh
run: |
New-Item "assets-cache" -ItemType Directory | Out-Null;
foreach ($current_file in "disclaimer", "chkder.f", "dogleg.f", "dpmpar.f", "enorm.f", "fdjac1.f", "fdjac2.f", "hybrd1.f", "hybrd.f", "hybrj1.f", "hybrj.f", "lmder1.f", "lmder.f", "lmdif1.f", "lmdif.f", "lmpar.f", "lmstr1.f", "lmstr.f", "qform.f", "qrfac.f", "qrsolv.f", "r1mpyq.f", "r1updt.f", "rwupdt.f")
{
$filePath = Join-Path -Path "assets" -ChildPath $current_file;
Copy-Item -Path $filePath -Destination "assets-cache";
}
- name: Save assets
if: ${{ matrix.USE_DOWNLOAD=='OFF' && steps.restore-assets.outputs.cache-hit != 'true' }}
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: assets-cache
key: minpack-assets
enableCrossOsArchive: true
- name: Checkout repository to minpack-builder directory
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
path: minpack-builder
- name: Place minpack sources in the correct directory for minpack-builder
if: ${{ matrix.USE_DOWNLOAD=='OFF' }}
shell: pwsh
run: |
foreach ($current_file in "disclaimer", "chkder.f", "dogleg.f", "dpmpar.f", "enorm.f", "fdjac1.f", "fdjac2.f", "hybrd1.f", "hybrd.f", "hybrj1.f", "hybrj.f", "lmder1.f", "lmder.f", "lmdif1.f", "lmdif.f", "lmpar.f", "lmstr1.f", "lmstr.f", "qform.f", "qrfac.f", "qrsolv.f", "r1mpyq.f", "r1updt.f", "rwupdt.f")
{
$filePath = Join-Path -Path "assets-cache" -ChildPath $current_file;
Copy-Item -Path $filePath -Destination "minpack-builder";
}
- name: Set environment variables to build and install directories
shell: pwsh
run: |
Add-Content $env:GITHUB_ENV "BUILDDIR=$env:RUNNER_TEMP\build"
Add-Content $env:GITHUB_ENV "INSTALLDIR=$env:RUNNER_TEMP\install-gfortran"
- name: Configure the build of minpack
shell: cmd
run: |
IF "${{ matrix.LIBRARY_KIND }}"=="SHARED" (
cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DUSE_DOWNLOAD=${{ matrix.USE_DOWNLOAD }} --install-prefix %INSTALLDIR% -S minpack-builder -B %BUILDDIR%
) ELSE IF "${{ matrix.LIBRARY_KIND }}"=="STATIC" (
cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DUSE_DOWNLOAD=${{ matrix.USE_DOWNLOAD }} --install-prefix %INSTALLDIR% -S minpack-builder -B %BUILDDIR%
) ELSE (
ECHO Unknown LIBRARY_KIND in the build matrix
EXIT /B 1
)
- name: Build minpack
shell: cmd
run: cmake --build %BUILDDIR% --config ${{ matrix.CMAKE_BUILD_TYPE }}
- name: Install minpack
shell: cmd
run: cmake --install %BUILDDIR% --config ${{ matrix.CMAKE_BUILD_TYPE }}