Skip to content

Windows Support #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add support for GNU toolchain on Windows
Co-authored-by: Nelson Chen <crazysim@gmail.com>
  • Loading branch information
yodaldevoid and nelsonjchen committed Feb 15, 2021
commit ba375b78b82507ebae9242b294f3183a7cb8c22d
3 changes: 3 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- variant: windowsservercore-1809/msvc
os: windows-2019
version: 1.50.0
- variant: windowsservercore-1809/gnu
os: windows-2019
version: 1.50.0
#VERSIONS

steps:
Expand Down
30 changes: 30 additions & 0 deletions 1.50.0/windowsservercore-1809/gnu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# escape=`

FROM mcr.microsoft.com/windows/servercore:1809

SHELL ["powershell.exe", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV RUSTUP_HOME=C:\rustup `
CARGO_HOME=C:\cargo `
RUST_VERSION=1.50.0

RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
$url = 'https://static.rust-lang.org/rustup/archive/1.23.1/x86_64-pc-windows-msvc/rustup-init.exe'; `
$sha256 = 'a586cf9de3e4aa791fd5796b6a5f99ca05591ccef8bb94e53af5b69f0261fb03'; `
Invoke-WebRequest -Uri $url -OutFile C:\rustup-init.exe; `
$actual256 = (Get-FileHash rustup-init.exe -Algorithm sha256).Hash; `
if ($actual256 -ne $sha256) { `
Write-Host 'FAILED!'; `
Write-Host ('expected: {0}' -f $sha256); `
Write-Host ('got: {0}' -f $actual256); `
exit 1; `
}; `
New-Item ${env:CARGO_HOME}\bin -type directory | Out-Null; `
$newPath = ('{0}\bin;{1}' -f ${env:CARGO_HOME}, ${env:PATH}); `
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); `
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Process); `
C:\rustup-init.exe -y -v --no-modify-path --default-toolchain ${env:RUST_VERSION} --default-host x86_64-pc-windows-gnu; `
Remove-Item C:\rustup-init.exe; `
rustup -V; `
cargo -V; `
rustc -V
30 changes: 30 additions & 0 deletions Dockerfile-windows-gnu.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# escape=`

FROM mcr.microsoft.com/windows/servercore:%%WINDOWS-VERSION%%

SHELL ["powershell.exe", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV RUSTUP_HOME=C:\rustup `
CARGO_HOME=C:\cargo `
RUST_VERSION=%%RUST-VERSION%%

RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
$url = 'https://static.rust-lang.org/rustup/archive/%%RUSTUP-VERSION%%/x86_64-pc-windows-msvc/rustup-init.exe'; `
$sha256 = '%%RUSTUP-SHA256%%'; `
Invoke-WebRequest -Uri $url -OutFile C:\rustup-init.exe; `
$actual256 = (Get-FileHash rustup-init.exe -Algorithm sha256).Hash; `
if ($actual256 -ne $sha256) { `
Write-Host 'FAILED!'; `
Write-Host ('expected: {0}' -f $sha256); `
Write-Host ('got: {0}' -f $actual256); `
exit 1; `
}; `
New-Item ${env:CARGO_HOME}\bin -type directory | Out-Null; `
$newPath = ('{0}\bin;{1}' -f ${env:CARGO_HOME}, ${env:PATH}); `
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); `
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Process); `
C:\rustup-init.exe -y -v --no-modify-path --default-toolchain ${env:RUST_VERSION} --default-host x86_64-pc-windows-gnu; `
Remove-Item C:\rustup-init.exe; `
rustup -V; `
cargo -V; `
rustc -V
25 changes: 25 additions & 0 deletions x.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ def update_windows():
.replace("%%RUSTUP-SHA256%%", rustup_hash_windows("x86_64-pc-windows-msvc"))
write_file(f"{rust_version}/windowsservercore-{version}/msvc/Dockerfile", rendered)

template = read_file("Dockerfile-windows-gnu.template")
for version, build in windows_servercore_versions:
rendered = template \
.replace("%%RUST-VERSION%%", rust_version) \
.replace("%%RUSTUP-VERSION%%", rustup_version) \
.replace("%%WINDOWS-VERSION%%", version) \
.replace("%%RUSTUP-SHA256%%", rustup_hash_windows("x86_64-pc-windows-msvc"))
write_file(f"{rust_version}/windowsservercore-{version}/gnu/Dockerfile", rendered)

def update_github_actions():
file = ".github/workflows/build-images.yml"
config = read_file(file)
Expand All @@ -149,6 +158,11 @@ def update_github_actions():
versions += f" os: windows-2019\n"
versions += f" version: {rust_version}\n"

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


marker = "#VERSIONS\n"
split = config.split(marker)
Expand Down Expand Up @@ -232,6 +246,17 @@ def generate_stackbrew_library():
map(lambda a: a.bashbrew, alpine_arches),
os.path.join(rust_version, f"alpine{version}"))

for version, build in windows_servercore_versions:
tags = []
for version_tag in version_tags():
tags.append(f"{version_tag}-windowsservercore-{version}-gnu")
tags.append(f"windowsservercore-{version}-gnu")

library += single_library(
tags,
["x86_64"],
os.path.join(rust_version, f"windowsservercore-{version}", "gnu"))

print(library)

def usage():
Expand Down