Skip to content

Commit f21e944

Browse files
committed
Add support for GNU toolchain on Windows
1 parent bbf7d3e commit f21e944

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

.github/workflows/build-images.yml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- variant: windowsservercore-1809/msvc
2626
os: windows-2019
2727
version: 1.50.0
28+
- variant: windowsservercore-1809/gnu
29+
os: windows-2019
30+
version: 1.50.0
2831
#VERSIONS
2932

3033
steps:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# escape=`
2+
3+
FROM mcr.microsoft.com/windows/servercore:1809
4+
5+
SHELL ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
6+
7+
ENV RUSTUP_HOME=C:\rustup `
8+
CARGO_HOME=C:\cargo `
9+
RUST_VERSION=1.50.0
10+
11+
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
12+
$url = 'https://static.rust-lang.org/rustup/archive/1.23.1/x86_64-pc-windows-msvc/rustup-init.exe'; `
13+
$sha256 = 'beddae8ff6830419b5d24d719a6ef1dd67a280fe8e799963b257467ffc205560'; `
14+
Invoke-WebRequest -Uri $url -OutFile C:\rustup-init.exe; `
15+
$actual256 = (Get-FileHash rustup-init.exe -Algorithm sha256).Hash; `
16+
if ($actual256 -ne $sha256) { `
17+
Write-Host 'FAILED!'; `
18+
Write-Host ('expected: {0}' -f $sha256); `
19+
Write-Host ('got: {0}' -f $actual256); `
20+
exit 1; `
21+
}; `
22+
New-Item ${env:CARGO_HOME}\bin -type directory | Out-Null; `
23+
$newPath = ('{0}\bin;{1}' -f ${env:CARGO_HOME}, ${env:PATH}); `
24+
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); `
25+
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Process); `
26+
C:\rustup-init.exe -y -v --no-modify-path --default-toolchain ${env:RUST_VERSION} --default-host x86_64-pc-windows-gnu; `
27+
Remove-Item C:\rustup-init.exe; `
28+
rustup -V; `
29+
cargo -V; `
30+
rustc -V

Dockerfile-windows-gnu.template

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# escape=`
2+
3+
FROM mcr.microsoft.com/windows/servercore:%%WINDOWS-VERSION%%
4+
5+
SHELL ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
6+
7+
ENV RUSTUP_HOME=C:\rustup `
8+
CARGO_HOME=C:\cargo `
9+
RUST_VERSION=%%RUST-VERSION%%
10+
11+
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
12+
$url = 'https://static.rust-lang.org/rustup/archive/%%RUSTUP-VERSION%%/x86_64-pc-windows-msvc/rustup-init.exe'; `
13+
$sha256 = '%%RUSTUP-SHA256%%'; `
14+
Invoke-WebRequest -Uri $url -OutFile C:\rustup-init.exe; `
15+
$actual256 = (Get-FileHash rustup-init.exe -Algorithm sha256).Hash; `
16+
if ($actual256 -ne $sha256) { `
17+
Write-Host 'FAILED!'; `
18+
Write-Host ('expected: {0}' -f $sha256); `
19+
Write-Host ('got: {0}' -f $actual256); `
20+
exit 1; `
21+
}; `
22+
New-Item ${env:CARGO_HOME}\bin -type directory | Out-Null; `
23+
$newPath = ('{0}\bin;{1}' -f ${env:CARGO_HOME}, ${env:PATH}); `
24+
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); `
25+
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Process); `
26+
C:\rustup-init.exe -y -v --no-modify-path --default-toolchain ${env:RUST_VERSION} --default-host x86_64-pc-windows-gnu; `
27+
Remove-Item C:\rustup-init.exe; `
28+
rustup -V; `
29+
cargo -V; `
30+
rustc -V

x.py

+14
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ def update_windows():
124124
.replace("%%RUSTUP-SHA256%%", rustup_hash_windows("x86_64-pc-windows-msvc"))
125125
write_file(f"{rust_version}/windowsservercore-{version}/msvc/Dockerfile", rendered)
126126

127+
template = read_file("Dockerfile-windows-gnu.template")
128+
for version, build in windows_servercore_versions:
129+
rendered = template \
130+
.replace("%%RUST-VERSION%%", rust_version) \
131+
.replace("%%RUSTUP-VERSION%%", rustup_version) \
132+
.replace("%%WINDOWS-VERSION%%", version) \
133+
.replace("%%RUSTUP-SHA256%%", rustup_hash_windows("x86_64-pc-windows-gnu"))
134+
write_file(f"{rust_version}/windowsservercore-{version}/gnu/Dockerfile", rendered)
135+
127136
def update_github_actions():
128137
file = ".github/workflows/build-images.yml"
129138
config = read_file(file)
@@ -148,6 +157,11 @@ def update_github_actions():
148157
versions += f" os: windows-2019\n"
149158
versions += f" version: {rust_version}\n"
150159

160+
for version, build in windows_servercore_versions:
161+
versions += f" - variant: windowsservercore-{version}/gnu\n"
162+
versions += f" os: windows-2019\n"
163+
versions += f" version: {rust_version}\n"
164+
151165

152166
marker = "#VERSIONS\n"
153167
split = config.split(marker)

0 commit comments

Comments
 (0)