Skip to content

Commit 359863b

Browse files
committed
xtask/build_docker_image: Add windows/amd64 platform handling
As listed at for example https://docs.docker.com/build/building/multi-platform/. Allows using `--platform windows/amd64` rather than `--platform x86_64-pc-windows-msvc`.
1 parent a6cffa0 commit 359863b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/docker/image.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ impl ImagePlatform {
180180
ImagePlatform::from_const_target(TargetTriple::X86_64UnknownLinuxGnu);
181181
pub const AARCH64_UNKNOWN_LINUX_GNU: Self =
182182
ImagePlatform::from_const_target(TargetTriple::Aarch64UnknownLinuxGnu);
183+
pub const X86_64_PC_WINDOWS_MSVC: Self =
184+
ImagePlatform::from_const_target(TargetTriple::X86_64PcWindowsMsvc);
183185

184186
/// Get a representative version of this platform specifier for usage in `--platform`
185187
///
@@ -199,6 +201,7 @@ impl ImagePlatform {
199201
TargetTriple::Aarch64UnknownLinuxGnu => {
200202
Some("ImagePlatform::AARCH64_UNKNOWN_LINUX_GNU")
201203
}
204+
TargetTriple::X86_64PcWindowsMsvc => Some("ImagePlatform::X86_64_PC_WINDOWS_MSVC"),
202205
_ => None,
203206
}
204207
}
@@ -237,6 +240,7 @@ impl std::str::FromStr for ImagePlatform {
237240
match s {
238241
"linux/amd64" => return Ok(Self::X86_64_UNKNOWN_LINUX_GNU),
239242
"linux/arm64" | "linux/arm64/v8" => return Ok(Self::AARCH64_UNKNOWN_LINUX_GNU),
243+
"windows/amd64" => return Ok(Self::X86_64_PC_WINDOWS_MSVC),
240244
_ => {}
241245
};
242246

@@ -542,6 +546,11 @@ pub mod tests {
542546
ImagePlatform::AARCH64_UNKNOWN_LINUX_GNU
543547
);
544548

549+
assert_eq!(
550+
"windows/amd64".parse::<ImagePlatform>()?,
551+
ImagePlatform::X86_64_PC_WINDOWS_MSVC
552+
);
553+
545554
Ok(())
546555
}
547556
}

xtask/src/build_docker_image.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ fn has_native_image(
363363
Ok(match target.sub.as_deref() {
364364
// FIXME: add additional subs for new Linux distros, such as alpine.
365365
None | Some("centos") => match (platform, target.name.as_str()) {
366+
// TODO: "windows/amd64"?
366367
("linux/386", "i686-unknown-linux-gnu")
367368
| ("linux/amd64", "x86_64-unknown-linux-gnu")
368369
| ("linux/arm64" | "linux/arm64/v8", "aarch64-unknown-linux-gnu")

0 commit comments

Comments
 (0)