Skip to content

Commit 831515f

Browse files
committed
add VulkanSDK & Ninja Tracing, fire packer per component to leverage layer cache, update unpack.ps1 & Dockerfile
1 parent 8aa6a18 commit 831515f

File tree

2 files changed

+125
-35
lines changed

2 files changed

+125
-35
lines changed

Dockerfile

Lines changed: 102 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ARG WINDOWS_11_SDK_VERSION=22621
1212
ARG WINDOWS_SDK_VERSION=10.0.${WINDOWS_11_SDK_VERSION}.0
1313
ARG VC_VERSION=14.43.17.13
1414
ARG VS_BOOTSTRAP_VERSION=17.13.6
15+
ARG VULKAN_SDK_VERSION=1.4.313.0
16+
ARG NINJATRACING_VERSION=0.0.2
1517

1618
# note: it seems we cannot pass version within any workflow ID to installer, though as I look at VS package cache I see it being done in json payloads!
1719
# henceforth we enforce fixed versions with nasty bootstrap URL, more details:
@@ -33,24 +35,68 @@ ARG IMPL_COMPRESSION_LEVEL=3
3335
ARG IMPL_NANO_BASE=mcr.microsoft.com/powershell
3436
ARG IMPL_NANO_TAG=lts-nanoserver-ltsc2022
3537

36-
# ---------------- BUILD TOOLS ----------------
37-
FROM mcr.microsoft.com/windows/servercore:ltsc2022 as buildtools
38+
# ---------------- REDIST ----------------
39+
FROM mcr.microsoft.com/windows/servercore:ltsc2022 as redist
3840

39-
ARG WINDOWS_11_SDK_VERSION
40-
ARG VC_VERSION
41-
ARG MSVC_VERSION
4241
ARG BUILD_TOOLS_URL
4342
ARG IMPL_ARTIFACTS_DIR
4443

4544
RUN mkdir C:\Temp && cd C:\Temp `
4645
&& curl -SL --output vs_buildtools.exe %BUILD_TOOLS_URL% `
4746
&& (start /w vs_buildtools.exe --quiet --wait --norestart --nocache `
47+
--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest `
48+
--installPath %IMPL_ARTIFACTS_DIR% `
49+
|| IF "%ERRORLEVEL%"=="3010" EXIT 0)
50+
51+
# ---------------- COMMON BUILD TOOLS ----------------
52+
FROM redist as bootstrap
53+
54+
ARG BUILD_TOOLS_URL
55+
ARG IMPL_ARTIFACTS_DIR
56+
57+
RUN (start /w C:\Temp\vs_buildtools.exe --quiet --wait --norestart --nocache `
58+
--add Microsoft.VisualCpp.DIA.SDK `
59+
--add Microsoft.VisualStudio.Component.VC.Llvm.Clang `
60+
--installPath %IMPL_ARTIFACTS_DIR% `
61+
|| IF "%ERRORLEVEL%"=="3010" EXIT 0)
62+
63+
SHELL ["powershell", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
64+
65+
# version depends on channel (see BUILD_TOOLS_URL)
66+
ARG CLANGCL_VERSION
67+
RUN $version = "$env:CLANGCL_VERSION" ; `
68+
$clangcl = Join-Path $env:IMPL_ARTIFACTS_DIR "VC\Tools\Llvm\bin\clang-cl.exe" ; `
69+
$pipe = & "$clangcl" -v 2>&1 ; `
70+
if ($pipe -match "$version") { exit 0 } else { `
71+
Write-Host "Validation failed due to requested version mismatch! Note: CLANGCL_VERSION = $version" ; `
72+
Write-Host "$pipe" ; `
73+
exit -1 `
74+
}
75+
76+
SHELL ["cmd", "/S", "/C"]
77+
78+
# ---------------- WINDOWS SDK ----------------
79+
FROM bootstrap as winsdk
80+
81+
ARG WINDOWS_11_SDK_VERSION
82+
ARG IMPL_ARTIFACTS_DIR
83+
84+
RUN (start /w C:\Temp\vs_buildtools.exe --quiet --wait --norestart --nocache `
85+
--add Microsoft.VisualStudio.Component.Windows11SDK.%WINDOWS_11_SDK_VERSION% `
86+
--installPath %IMPL_ARTIFACTS_DIR% `
87+
|| IF "%ERRORLEVEL%"=="3010" EXIT 0)
88+
89+
# ---------------- VC BUILD TOOLS ----------------
90+
FROM bootstrap as buildtools
91+
92+
ARG VC_VERSION
93+
ARG MSVC_VERSION
94+
ARG IMPL_ARTIFACTS_DIR
95+
96+
RUN (start /w C:\Temp\vs_buildtools.exe --quiet --wait --norestart --nocache `
4897
--add Microsoft.VisualStudio.Component.VC.%VC_VERSION%.x86.x64 `
4998
--add Microsoft.VisualStudio.Component.VC.%VC_VERSION%.ATL `
5099
--add Microsoft.VisualStudio.Component.VC.%VC_VERSION%.MFC `
51-
--add Microsoft.VisualStudio.Component.Windows11SDK.%WINDOWS_11_SDK_VERSION% `
52-
--add Microsoft.VisualCpp.DIA.SDK `
53-
--add Microsoft.VisualStudio.Component.VC.Llvm.Clang `
54100
--installPath %IMPL_ARTIFACTS_DIR% `
55101
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) && dir %IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC `
56102
&& if exist %IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC\%MSVC_VERSION% ( `
@@ -59,7 +105,7 @@ for /d %i in (%IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC\*) do if /I not "%i"=="%IMPL_AR
59105
echo "Error: Expected MSVC version directory %MSVC_VERSION% does not exist!" && exit /b 1 `
60106
)
61107

62-
SHELL ["powershell", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
108+
# SHELL ["powershell", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
63109
# important note: msc ships compiler which minor version doesn't match the toolset directory name
64110
# eg. dir name: 14.43.34808 (MSVC_VERSION) but version reported by cl.exe: 19.43.34810
65111
# more over, all package cache payloads (by default at C:\ProgramData\Microsoft\VisualStudio)
@@ -76,16 +122,19 @@ SHELL ["powershell", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Co
76122
# exit -1 `
77123
# }
78124

79-
# on the other hand here version depends on channel (see BUILD_TOOLS_URL)
80-
ARG CLANGCL_VERSION
81-
RUN $version = "$env:CLANGCL_VERSION" ; `
82-
$clangcl = Join-Path $env:IMPL_ARTIFACTS_DIR "VC\Tools\Llvm\bin\clang-cl.exe" ; `
83-
$pipe = & "$clangcl" -v 2>&1 ; `
84-
if ($pipe -match "$version") { exit 0 } else { `
85-
Write-Host "Validation failed due to requested version mismatch! Note: CLANGCL_VERSION = $version" ; `
86-
Write-Host "$pipe" ; `
87-
exit -1 `
88-
}
125+
# ---------------- VULKAN SDK ----------------
126+
FROM redist as vulkan
127+
128+
ARG VULKAN_SDK_VERSION
129+
ARG IMPL_ARTIFACTS_DIR
130+
SHELL ["powershell", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
131+
132+
RUN Write-Host "Installing Vulkan SDK $env:VULKAN_SDK_VERSION" ; `
133+
Remove-Item -Recurse -Force $env:IMPL_ARTIFACTS_DIR -ErrorAction SilentlyContinue ; `
134+
New-Item -ItemType Directory -Force -Path C:\Temp, $env:IMPL_ARTIFACTS_DIR ; `
135+
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/$env:VULKAN_SDK_VERSION/windows/vulkansdk-windows-X64-$env:VULKAN_SDK_VERSION.exe" -OutFile C:\Temp\vulkan-sdk.exe ; `
136+
& C:\Temp\vulkan-sdk.exe install --root "$env:IMPL_ARTIFACTS_DIR" --default-answer --accept-licenses --confirm-command ; `
137+
Remove-Item C:\Temp\vulkan-sdk.exe
89138

90139
# ---------------- CMAKE ----------------
91140
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as cmake
@@ -134,6 +183,19 @@ Invoke-WebRequest -Uri "https://github.com/ninja-build/ninja/releases/download/v
134183
tar -xf C:\Temp\ninja.zip -C $env:IMPL_ARTIFACTS_DIR ; `
135184
Remove-Item C:\Temp\ninja.zip
136185

186+
# ---------------- NINJA ----------------
187+
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as ninjatracing
188+
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
189+
190+
ARG NINJATRACING_VERSION
191+
ARG IMPL_ARTIFACTS_DIR
192+
193+
RUN Write-Host "Installing Ninja-Tracing $env:NINJATRACING_VERSION" ; `
194+
New-Item -ItemType Directory -Force -Path C:\Temp, $env:IMPL_ARTIFACTS_DIR ; `
195+
Invoke-WebRequest -Uri "https://github.com/Devsh-Graphics-Programming/ninjatracing/archive/refs/tags/$env:NINJATRACING_VERSION.zip" -OutFile C:\Temp\ninjatracing.zip ; `
196+
tar -xf C:\Temp\ninjatracing.zip -C $env:IMPL_ARTIFACTS_DIR ; `
197+
Remove-Item C:\Temp\ninjatracing.zip
198+
137199
# ---------------- NASM ----------------
138200
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as nasm
139201
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
@@ -178,11 +240,13 @@ FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as compress
178240
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
179241

180242
ARG IMPL_ARTIFACTS_DIR
181-
COPY --link --from=buildtools ["C:/Program Files (x86)/Windows Kits/10", "C:/pack/WindowsKits10SDK"]
243+
COPY --link --from=winsdk ["C:/Program Files (x86)/Windows Kits/10", "C:/pack/WindowsKits10SDK"]
182244
COPY --link --from=buildtools ["${IMPL_ARTIFACTS_DIR}", "C:/pack/BuildTools"]
245+
COPY --link --from=vulkan ["${IMPL_ARTIFACTS_DIR}", "C:/pack/vulkan-sdk"]
183246
COPY --link --from=cmake ["${IMPL_ARTIFACTS_DIR}", "C:/pack/CMake"]
184247
COPY --link --from=python ["${IMPL_ARTIFACTS_DIR}", "C:/pack/Python"]
185248
COPY --link --from=ninja ["${IMPL_ARTIFACTS_DIR}", "C:/pack/Ninja"]
249+
COPY --link --from=ninjatracing ["${IMPL_ARTIFACTS_DIR}", "C:/pack/NinjaTracing"]
186250
COPY --link --from=nasm ["${IMPL_ARTIFACTS_DIR}", "C:/pack/Nasm"]
187251
COPY --link --from=git ["${IMPL_ARTIFACTS_DIR}", "C:/pack/Git"]
188252
COPY --link --from=zstd ["${IMPL_ARTIFACTS_DIR}", "C:/compress"]
@@ -192,10 +256,17 @@ ARG IMPL_COMPRESSION_OPTIONS
192256
ARG IMPL_COMPRESSION_LEVEL
193257

194258
WORKDIR C:\pack
195-
RUN $dirs = Get-ChildItem -Directory | ForEach-Object { $_.Name }; $dirs; `
196-
tar -cf artifacts.tar @dirs; dir artifacts.tar; $compressionOpts = $env:IMPL_COMPRESSION_OPTIONS -split ' '; `
197-
& "C:\compress\zstd-v$env:ZSTD_VERSION-win64\zstd.exe" @compressionOpts artifacts.tar "-$env:IMPL_COMPRESSION_LEVEL"; dir artifacts.tar.zst; `
198-
rm artifacts.tar
259+
RUN $dirs=Get-ChildItem -Directory|Select-Object -Expand Name; `
260+
New-Item -ItemType Directory -Force -Path "zst"; `
261+
foreach($d in $dirs){ `
262+
Write-Host "=== Compressing $d ==="; `
263+
tar -cf "${d}-artifacts.tar" "$d"; `
264+
& "C:\compress\zstd-v$env:ZSTD_VERSION-win64\zstd.exe" `
265+
$env:IMPL_COMPRESSION_OPTIONS.Split(' ') `
266+
"${d}-artifacts.tar" "-$env:IMPL_COMPRESSION_LEVEL" `
267+
"-o" "zst/${d}-artifacts.tar.zst"; `
268+
Remove-Item "${d}-artifacts.tar"; `
269+
}
199270

200271
# ---------------- FINAL IMAGE ----------------
201272
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG}
@@ -208,7 +279,7 @@ LABEL org.opencontainers.image.description="Build MSVC/ClangCL + WinSDK projects
208279
LABEL org.opencontainers.image.licenses=Apache-2.0
209280

210281
ARG IMPL_ARTIFACTS_DIR
211-
COPY --link --from=compress ["C:/pack/artifacts.tar.zst", "C:/artifacts.tar.zst"]
282+
COPY --link --from=compress ["C:/pack/zst", "C:/pack"]
212283
COPY --link --from=zstd ["${IMPL_ARTIFACTS_DIR}", "C:/compress"]
213284

214285
ARG CMAKE_VERSION
@@ -223,6 +294,8 @@ ARG MSVC_VERSION
223294
ARG CLANGCL_VERSION
224295
ARG BUILD_TOOLS_URL
225296
ARG VS_BOOTSTRAP_VERSION
297+
ARG VULKAN_SDK_VERSION
298+
ARG NINJATRACING_VERSION
226299
ARG ZSTD_VERSION
227300

228301
ENV CMAKE_WINDOWS_KITS_10_DIR="C:\WindowsKits10SDK" `
@@ -239,11 +312,14 @@ MSVC_VERSION=${MSVC_VERSION} `
239312
CLANGCL_VERSION=${CLANGCL_VERSION} `
240313
BUILD_TOOLS_URL=${BUILD_TOOLS_URL} `
241314
VS_BOOTSTRAP_VERSION=${VS_BOOTSTRAP_VERSION} `
315+
VULKAN_SDK_VERSION=${VULKAN_SDK_VERSION} `
316+
NINJATRACING_VERSION=${NINJATRACING_VERSION} `
242317
MSVC_TOOLSET_DIR=C:\BuildTools\VC\Tools\MSVC\${MSVC_VERSION} `
243318
LLVM_TOOLSET_DIR=C:\BuildTools\VC\Tools\Llvm `
244-
PATH="C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;C:\Git\cmd;C:\Git\bin;C:\Git\usr\bin;C:\Git\mingw64\bin;C:\CMake\cmake-${CMAKE_VERSION}-windows-x86_64\bin;C:\Python;C:\Nasm;C:\Nasm\nasm-${NASM_VERSION};C:\Ninja;C:\compress\zstd-v${ZSTD_VERSION}-win64;"
319+
PATH="C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;C:\Git\cmd;C:\Git\bin;C:\Git\usr\bin;C:\Git\mingw64\bin;C:\CMake\cmake-${CMAKE_VERSION}-windows-x86_64\bin;C:\Python;C:\Nasm;C:\Nasm\nasm-${NASM_VERSION};C:\Ninja;C:\compress\zstd-v${ZSTD_VERSION}-win64;C:\vulkan-sdk\Bin;C:\NinjaTracing\ninjatracing-${NINJATRACING_VERSION}"
245320

246321
COPY . sample/
247322
COPY unpack.ps1 .
248323
WORKDIR C:\sample\tests
324+
ENTRYPOINT ["pwsh.exe", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-NoExit", "-File", "C:/unpack.ps1"]
249325
CMD ["pwsh.exe", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass"]

unpack.ps1

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
$oldLocation = Get-Location
22
try {
33
Set-Location -Path 'C:\'
4-
5-
if (Test-Path -Path 'artifacts.tar.zst') {
6-
if (-not (Test-Path -Path 'artifacts.tar')) {
7-
& zstd -d -T0 artifacts.tar.zst -o artifacts.tar
4+
$files = Get-ChildItem -Path 'C:\pack' -Filter '*-artifacts.tar.zst'
5+
if ($files.Count -gt 0) {
6+
$start = Get-Date
7+
Write-Host "Unpack started at $start"
8+
foreach ($z in $files) {
9+
$zst = $z.FullName
10+
$tar = [IO.Path]::ChangeExtension($zst, '.tar')
11+
if (-not (Test-Path $tar)) {
12+
& zstd -d -T0 $zst -o $tar
13+
}
14+
tar -xf $tar
15+
Remove-Item $tar, $zst -ErrorAction SilentlyContinue
816
}
9-
tar -xf artifacts.tar
10-
}
17+
dir
18+
$end = Get-Date
19+
Write-Host "Unpack finished at $end"
20+
$duration = $end - $start
21+
Write-Host "Total duration: $($duration.ToString())"
1122

12-
Remove-Item -Path 'artifacts.tar' -ErrorAction SilentlyContinue
13-
Remove-Item -Path 'artifacts.tar.zst' -ErrorAction SilentlyContinue
14-
dir
23+
git config --global --add safe.directory '*'
24+
Write-Host "All directories marked safe for Git."
25+
}
26+
else {
27+
Write-Host "No artifacts to unpack."
28+
}
1529
}
1630
finally {
1731
Set-Location -Path $oldLocation

0 commit comments

Comments
 (0)