2626 python_version : " cp313-*"
2727
2828 steps :
29- - name : Checkout repository
29+ - name : Checkout repository (for non-windows)
30+ if : matrix.os != 'windows-latest'
3031 uses : actions/checkout@v4
3132 with :
3233 submodules : true
@@ -123,47 +124,107 @@ jobs:
123124 with :
124125 python-version : ' 3.13'
125126
126- - name : Install Windows Dependencies (Part 0a - Setup Build Env)
127- uses : ilammy/msvc-dev-cmd@v1
127+ - name : Clean Windows Workspace
128+ if : ${{ matrix.os == 'windows-latest'}}
129+ run : Remove-Item * -Recurse -Force
128130
129- - name : Install Windows Dependencies (Part 0b - Fetch LLVM Build Dependencies )
130- if : matrix.os == 'windows-latest' # works on any OS, but we only need windows here(?)
131+ - name : Install Windows Dependencies (Part 0a - Setup Flang Source Code )
132+ if : ${{ matrix.os == 'windows-latest'}}
131133 run : |
132- choco install ninja wget 7zip llvm -y
134+ git clone --depth 1 https://github.com/flang-compiler/flang.git ${{ github.workspace }}
133135
134- - name : Install Windows Dependencies (Part 1 - Build Flang)
135- if : matrix.os == 'windows-latest' # works on any OS, but we only need windows here(?)
136+ - name : Install Windows Dependencies (Part 0b - Setup LLVM Build Env)
137+ if : ${{ matrix.os == 'windows-latest'}}
138+ uses : llvm/actions/setup-windows@main
139+ with :
140+ arch : amd64
141+
142+ - name : Install Windows Dependencies (Part 0c - Setup LLVM-style Ninja Build Env)
143+ if : ${{ matrix.os == 'windows-latest'}}
144+ uses : llvm/actions/setup-windows@main
145+ with :
146+ arch : amd64
147+
148+ - name : Install Windows Dependencies (Part 0d - Setup Graphviz for Doxygen)
149+ if : ${{ matrix.os == 'windows-latest'}}
150+ run : choco install graphviz wget
151+
152+ - name : Install Windows Dependencies (Part 0e - Setup Sphinx for Python)
153+ if : ${{ matrix.os == 'windows-latest'}}
154+ run : pip install sphinx
155+
156+ - name : Install Windows Dependencies (Part 0f - Prepare Flang source)
157+ if : ${{ matrix.os == 'windows-latest'}}
158+ run : |
159+ git clone --depth 1 https://github.com/flang-compiler/flang.git /flang_build
160+
161+ - name : Install Windows Dependencies (Part 0g - Download pre-built "cmade" LLVM)
162+ run : |
163+ cd ../..
164+ # Search backwards in the workflow history for the specified branch
165+ # for the first successful run that produced the desired artifact.
166+ $build_name="llvm_build_win_amd64_clangcl_release_19x"
167+ Invoke-WebRequest -Uri https://api.github.com/repos/flang-compiler/classic-flang-llvm-project/actions/workflows/pre-compile_llvm.yml/runs -OutFile llvm_runs.json
168+ $urls = @($(jq -r --arg b release_19x '.workflow_runs[] | select(.head_branch == $b) | select (.conclusion == "success") | .artifacts_url?' llvm_runs.json))
169+ Invoke-WebRequest "$(jq -r '.workflow_runs[0].artifacts_url?' llvm_runs.json)" -OutFile llvm_artifacts.json
170+ for ($i = 0; $i -lt $urls.Count; $i++) {
171+ $artifacts_url = $urls[$i]
172+ Invoke-WebRequest -Uri "$artifacts_url" -OutFile llvm_artifacts.json
173+ $archive_url = "$(jq -r --arg b $build_name '.artifacts[] | select(.name == $b) | .archive_download_url' llvm_artifacts.json)"
174+ if (! $archive_url) {
175+ Write-Output "$artifacts_url did not contain a $build_name archive; too old?"
176+ continue
177+ }
178+ Write-Output "Downloading $archive_url."
179+ $artifact_path = "$pwd\${build_name}.zip"
180+ try {
181+ $response = Invoke-WebRequest -Method Get -Uri $archive_url -OutFile $artifact_path -Headers @{ "Authorization" = "Bearer ${{ secrets.GITHUB_TOKEN }}" }
182+ if ($response.StatusCode -lt 300) {
183+ break
184+ }
185+ } catch {}
186+ }
187+ if (!(Test-Path "$artifact_path")) {
188+ Write-Output "Could not download the correct prebuilt compiler; aborting."
189+ exit 1
190+ }
191+ Expand-Archive -Force -Path "${build_name}.zip" -DestinationPath .
192+ & 7z x "$pwd\llvm_build.7z" -o"$pwd\classic-flang-llvm-project\" -y
193+ Write-Output "$(Get-ChildItem)"
194+
195+
196+ - name : Install Windows Dependencies (Part 1a - Build Flang)
197+ if : matrix.os == 'windows-latest'
198+ shell : powershell
199+ run : |
200+ $pcount = $($(Get-WmiObject -class Win32_ComputerSystem).numberoflogicalprocessors)
201+ python .\scripts\build_flang.py -b "Release" -d build -t X86 -p "$(pwd)\..\..\classic-flang-llvm-project\classic-flang-llvm-project\build\" -j $pcount -v
202+ $resolved = Resolve-Path "$(pwd)\..\..\classic-flang-llvm-project\classic-flang-llvm-project\build\"
203+ $resolved.Path | Set-Content -Path $env:GITHUB_PATH
204+
205+ - name : Install Windows Dependencies (Part 1b - Confirm Neccessary LLVM Tools are Installed)
206+ if : matrix.os == 'windows-latest'
136207 run : |
137- mkdir -p /flang_build/build
138- wget https://github.com/llvm/llvm-project/releases/download/llvmorg-20.1.2/flang-20.1.2.src.tar.xz
139- echo 'Unpacking with 7-zip...' # for some reason, `tar` doesn't load properly...
140- 7z x "flang-20.1.2.src.tar.xz" -so | 7z x -aoa -si -ttar -o"d:\\flang_build"
141- mv /flang_build/*.src/* /flang_build
142- rm -r /flang_build/*.src
143- echo "running cmake"
144- cmake /flang_build -B /flang_build/build
145- cmake --build /flang_build/build --config Release -j
146- cmake --install /flang_build/build
147-
148208 clang --version
149209 clang++ --version
150210 flang --version
211+ which flang
212+
213+ - name : Install Windows Dependencies (Part 2a - Reclean Windows Workspace)
214+ if : ${{ matrix.os == 'windows-latest'}}
215+ run : Remove-Item * -Recurse -Force
151216
152- # - name: Install Windows Dependencies (Part X - Clang set-up)
153- # uses: KyleMayes/install-llvm-action@v2
154- # if: matrix.os == 'windows-latest' # works on any OS, but we only need windows here(?)
155- # with:
156- # version: "19"
157- # env: true # Sets CC and CXX to clang variants
217+ - name : Install Windows Dependencies (Part 2b - Setup Flang Source Code)
218+ if : ${{ matrix.os == 'windows-latest'}}
219+ uses : actions/checkout@v4
158220
159- - name : Install Windows Dependencies (Part 2 - Remainder)
221+ - name : Install Windows Dependencies (Part 2c - Remainder)
160222 if : matrix.os == 'windows-latest'
161223 run : |
162224 choco install conan -y
163225 conan profile detect --force
164226 conan install . --output-folder=build --build=missing
165227
166-
167228 - name : Build Wheels (Windows)
168229169230 if : matrix.os == 'windows-latest'
@@ -175,6 +236,7 @@ jobs:
175236 CIBW_ENVIRONMENT : >
176237 CC=clang
177238 CXX=clang++
239+ FC=flang
178240 CMAKE_GENERATOR=Ninja
179241 # with:
180242 # package-dir: .
0 commit comments