Skip to content

Commit 85cda71

Browse files
finish up
1 parent c67ded2 commit 85cda71

File tree

2 files changed

+145
-5
lines changed

2 files changed

+145
-5
lines changed

.github/workflows/build-ci-container-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ permissions:
55

66
on:
77
push:
8-
#branches:
9-
# - main
8+
branches:
9+
- main
1010
paths:
1111
- .github/workflows/build-ci-container-windows.yml
1212
- '.github/workflows/containers/github-action-ci-windows/**'
@@ -17,7 +17,7 @@ on:
1717

1818
jobs:
1919
build-ci-container-windows:
20-
#if: github.repository_owner == 'llvm'
20+
if: github.repository_owner == 'llvm'
2121
runs-on: windows-2022
2222
outputs:
2323
container-name: ${{ steps.vars.outputs.container-name }}
Lines changed: 142 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,142 @@
1-
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
2-
RUN echo test
1+
# Agent image for LLVM org cluster.
2+
# .net 4.8 is required by chocolately package manager.
3+
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022
4+
5+
# Restore the default Windows shell for correct batch processing.
6+
SHELL ["cmd", "/S", "/C"]
7+
8+
# Download the Build Tools bootstrapper.
9+
ADD https://aka.ms/vs/16/release/vs_buildtools.exe /TEMP/vs_buildtools.exe
10+
11+
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
12+
13+
# Download channel for fixed install.
14+
ARG CHANNEL_URL=https://aka.ms/vs/16/release/channel
15+
ADD ${CHANNEL_URL} /TEMP/VisualStudio.chman
16+
17+
# Install Build Tools with C++ workload.
18+
# - Documentation for docker installation
19+
# https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2019
20+
# - Documentation on workloads
21+
# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019#c-build-tools
22+
# - Documentation on flags
23+
# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019
24+
RUN /TEMP/vs_buildtools.exe --quiet --wait --norestart --nocache \
25+
--channelUri C:\TEMP\VisualStudio.chman \
26+
--installChannelUri C:\TEMP\VisualStudio.chman \
27+
--installPath C:\BuildTools \
28+
--add Microsoft.VisualStudio.Workload.VCTools \
29+
--add Microsoft.VisualStudio.Component.VC.ATL \
30+
--includeRecommended \
31+
|| IF "%ERRORLEVEL%"=="3010" EXIT 0
32+
33+
# Register DIA dll (Debug Interface Access) so it can be used to symbolize
34+
# the stack traces. Register dll for 32 and 64 bit.
35+
# see https://developercommunity.visualstudio.com/content/problem/290674/msdia140dll-is-not-registered-on-vs2017-hosts.html
36+
37+
RUN regsvr32 /S "C:\BuildTools\DIA SDK\bin\amd64\msdia140.dll" & \
38+
regsvr32 /S "C:\BuildTools\DIA SDK\bin\msdia140.dll"
39+
40+
# install tools as described in https://llvm.org/docs/GettingStartedVS.html
41+
# and a few more that were not documented...
42+
# Pin an older version of Python; the current Python 3.10 fails when
43+
# doing "pip install" for the other dependencies, as it fails to find libxml
44+
# while compiling some package.
45+
# We version pin the other packages as well to ensure the container build is as
46+
# reproducible as possible to prevent issues when upgrading only part of the
47+
# container.
48+
RUN choco install -y ninja --version 1.13.1 && \
49+
choco install -y git --version 2.50.1 && \
50+
choco install -y sccache --version 0.10.0 && \
51+
choco install -y python3 --version 3.9.7
52+
53+
# Testing requires psutil
54+
RUN pip install psutil
55+
56+
# configure Python encoding
57+
ENV PYTHONIOENCODING=UTF-8
58+
59+
# update the path variable
60+
# C:\Program Files\Git\usr\bin contains a usable bash and other unix tools.
61+
# C:\llvm-mingw\bin contains Clang configured for mingw targets and
62+
# corresponding sysroots. Both the 'llvm' package (with Clang defaulting
63+
# to MSVC targets) and this directory contains executables named
64+
# 'clang.exe' - add this last to let the other one have precedence.
65+
# To use these compilers, use the triple prefixed form, e.g.
66+
# x86_64-w64-mingw32-clang.
67+
# C:\buildtools and SDK paths are ones that are set by c:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 -host_arch=amd64
68+
RUN powershell -Command \
69+
[System.Environment]::SetEnvironmentVariable('PATH', \
70+
[System.Environment]::GetEnvironmentVariable('PATH', 'machine') + ';C:\Program Files\Git\usr\bin;C:\llvm-mingw\bin' \
71+
+ ';C:\BuildTools\Common7\IDE\' \
72+
+ ';C:\BuildTools\Common7\IDE\CommonExt ensions\Microsoft\TeamFoundation\Team Explorer' \
73+
+ ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin' \
74+
+ ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja' \
75+
+ ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer' \
76+
+ ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow' \
77+
+ ';C:\BuildTools\Common7\IDE\VC\VCPackages' \
78+
+ ';C:\BuildTools\Common7\Tools\' \
79+
+ ';C:\BuildTools\Common7\Tools\devinit' \
80+
+ ';C:\BuildTools\MSBuild\Current\Bin' \
81+
+ ';C:\BuildTools\MSBuild\Current\bin\Roslyn' \
82+
+ ';C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64' \
83+
+ ';C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\' \
84+
+ ';C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64' \
85+
+ ';C:\Program Files (x86)\Windows Kits\10\bin\x64' \
86+
+ ';C:\Windows\Microsoft.NET\Framework64\v4.0.30319' \
87+
,'machine')
88+
89+
# support long file names during git checkout
90+
RUN git config --system core.longpaths true & \
91+
git config --global core.autocrlf false
92+
93+
ARG RUNNER_VERSION=2.329.0
94+
ENV RUNNER_VERSION=$RUNNER_VERSION
95+
96+
RUN powershell -Command \
97+
Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v${env:RUNNER_VERSION}/actions-runner-win-x64-${env:RUNNER_VERSION}.zip -OutFile actions-runner-win.zip ; \
98+
Add-Type -AssemblyName System.IO.Compression.FileSystem ; \
99+
[System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner-win.zip', $PWD) ;\
100+
rm actions-runner-win.zip
101+
102+
# Set the LLVM_VERSION environment variable
103+
ENV LLVM_VERSION=21.1.2
104+
105+
# Download and extract Clang compiler.
106+
# Create directories, download, extract, and clean up all in one layer
107+
RUN powershell -Command \
108+
# --- Setup directories --- \
109+
Write-Host "Creating directories..."; \
110+
New-Item -Path "C:\temp-download" -ItemType "Directory" -Force ; \
111+
New-Item -Path "C:\xz-utils" -ItemType "Directory" -Force ; \
112+
New-Item -Path "C:\clang" -ItemType "Directory" -Force ; \
113+
# --- 1. Download and extract xz --- \
114+
Set-Location C:\temp-download ; \
115+
Invoke-WebRequest -Uri "http://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1-windows.zip" -OutFile "xz.zip"; \
116+
(Get-FileHash -Path "C:\temp-download\xz.zip" -Algorithm MD5).Hash -eq 'c3c69fdce3e825cc0b76123b36b0bcc2' ; \
117+
Add-Type -AssemblyName "System.IO.Compression.FileSystem"; \
118+
[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\temp-download\xz.zip', 'C:\xz-utils'); \
119+
# --- 2. Download and decompress Clang --- \
120+
Invoke-WebRequest -Uri "http://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" -OutFile "clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" ; \
121+
(Get-FileHash -Path "C:\temp-download\clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" -Algorithm MD5).Hash -eq '0ae1d3effd9ab9d323f7fa595777f0a2' ; \
122+
C:\xz-utils\bin_x86-64\xz.exe -d -qq clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz ; \
123+
# --- 3. Extract clang --- \
124+
C:\Windows\System32\tar.exe -xf clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar -C C:\clang ; \
125+
# --- 4. Clean up --- \
126+
Set-Location C:\ ; \
127+
Remove-Item C:\temp-download -Recurse -Force; \
128+
Remove-Item C:\xz-utils -Recurse -Force; \
129+
# -- 5. Shorten path to clang files & remove unnecessary files -- \
130+
Set-Location C:\clang ; \
131+
Rename-Item -Path "C:\clang\clang+llvm-21.1.2-x86_64-pc-windows-msvc" -NewName "C:\clang\clang-msvc" ; \
132+
Set-Location C:\clang\clang-msvc ; \
133+
Remove-Item -Path C:\clang\clang-msvc\libexec -Recurse -Force ; \
134+
Remove-Item -Path C:\clang\clang-msvc\share -Recurse -Force ; \
135+
Rename-Item -Path "C:\clang\clang-msvc\bin" -NewName "C:\clang\clang-msvc\bin-full" ; \
136+
New-Item -Path "C:\clang\clang-msvc\bin" -ItemType Directory -Force ; \
137+
Set-Location C:\clang\clang-msvc\bin ; \
138+
Copy-Item -Path C:\clang\clang-msvc\bin-full\*.dll -Destination C:\clang\clang-msvc\bin\. ; \
139+
Copy-Item -Path C:\clang\clang-msvc\bin-full\clang-cl.exe -Destination C:\clang\clang-msvc\bin\. ; \
140+
Copy-Item -Path C:\clang\clang-msvc\bin-full\lld-link.exe -Destination C:\clang\clang-msvc\bin\. ; \
141+
Set-Location C:\clang\clang-msvc ; \
142+
Remove-Item -Path C:\clang\clang-msvc\bin-full -Recurse -Force ;

0 commit comments

Comments
 (0)