Skip to content

Commit 7e1105f

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 7e1105f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-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
}

0 commit comments

Comments
 (0)