Skip to content

Commit

Permalink
Add NetBSD support
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Nov 25, 2021
1 parent cd973c1 commit 6870d85
Show file tree
Hide file tree
Showing 2 changed files with 733 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum Os {
Windows,
Macos,
FreeBsd,
NetBsd,
OpenBsd,
}

Expand All @@ -27,6 +28,7 @@ impl fmt::Display for Os {
Os::Windows => write!(f, "Windows"),
Os::Macos => write!(f, "MacOS"),
Os::FreeBsd => write!(f, "FreeBSD"),
Os::NetBsd => write!(f, "NetBSD"),
Os::OpenBsd => write!(f, "OpenBSD"),
}
}
Expand Down Expand Up @@ -72,6 +74,7 @@ fn get_supported_architectures(os: &Os) -> Vec<Arch> {
],
Os::Windows => vec![Arch::X86, Arch::X86_64, Arch::Aarch64],
Os::Macos => vec![Arch::Aarch64, Arch::X86_64],
Os::NetBsd => vec![Arch::Aarch64, Arch::X86, Arch::X86_64],
Os::FreeBsd => vec![
Arch::Aarch64,
Arch::Powerpc64,
Expand Down Expand Up @@ -115,6 +118,7 @@ impl Target {
target_lexicon::OperatingSystem::Windows => Os::Windows,
target_lexicon::OperatingSystem::MacOSX { .. }
| target_lexicon::OperatingSystem::Darwin => Os::Macos,
target_lexicon::OperatingSystem::Netbsd => Os::NetBsd,
target_lexicon::OperatingSystem::Freebsd => Os::FreeBsd,
target_lexicon::OperatingSystem::Openbsd => Os::OpenBsd,
unsupported => bail!("The operating system {:?} is not supported", unsupported),
Expand Down Expand Up @@ -146,10 +150,16 @@ impl Target {
/// Returns the platform part of the tag for the wheel name
pub fn get_platform_tag(&self, platform_tag: PlatformTag, universal2: bool) -> String {
match (&self.os, &self.arch) {
// FreeBSD
(Os::FreeBsd, Arch::X86_64)
| (Os::FreeBsd, Arch::Aarch64)
| (Os::FreeBsd, Arch::Powerpc64)
| (Os::FreeBsd, Arch::Powerpc64Le)
// NetBSD
| (Os::NetBsd, Arch::X86)
| (Os::NetBsd, Arch::X86_64)
| (Os::NetBsd, Arch::Aarch64)
// OpenBSD
| (Os::OpenBsd, Arch::X86)
| (Os::OpenBsd, Arch::X86_64)
| (Os::OpenBsd, Arch::Aarch64) => {
Expand Down Expand Up @@ -210,6 +220,7 @@ impl Target {
Os::Linux => "linux",
Os::Macos => "darwin",
Os::FreeBsd => "freebsd",
Os::NetBsd => "netbsd",
Os::OpenBsd => "openbsd",
}
}
Expand Down Expand Up @@ -246,7 +257,7 @@ impl Target {
pub fn is_unix(&self) -> bool {
match self.os {
Os::Windows => false,
Os::Linux | Os::Macos | Os::FreeBsd | Os::OpenBsd => true,
Os::Linux | Os::Macos | Os::FreeBsd | Os::NetBsd | Os::OpenBsd => true,
}
}

Expand Down
Loading

0 comments on commit 6870d85

Please sign in to comment.