Skip to content

Commit

Permalink
Add support for Haiku
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 7, 2021
1 parent 5b6a2ac commit 6ef73f2
Show file tree
Hide file tree
Showing 4 changed files with 740 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

* Fix docs for `new` and `init` commands in `maturin --help` in [#734](https://github.com/PyO3/maturin/pull/734)
* Add support for x86_64 Haiku in [#735](https://github.com/PyO3/maturin/pull/735)

## [0.12.4] - 2021-12-06

Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def run(self):
cargo_args.extend(
["--no-default-features", "--features=upload,log,human-panic"]
)
elif sys.platform.startswith("haiku"):
# mio and ring doesn't build on haiku
cargo_args.extend(
["--no-default-features", "--features=log,human-panic"]
)

try:
metadata = json.loads(
Expand Down
18 changes: 16 additions & 2 deletions src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum Os {
OpenBsd,
Dragonfly,
Illumos,
Haiku,
}

impl fmt::Display for Os {
Expand All @@ -35,6 +36,7 @@ impl fmt::Display for Os {
Os::OpenBsd => write!(f, "OpenBSD"),
Os::Dragonfly => write!(f, "DragonFly"),
Os::Illumos => write!(f, "Illumos"),
Os::Haiku => write!(f, "Haiku"),
}
}
}
Expand Down Expand Up @@ -89,6 +91,7 @@ fn get_supported_architectures(os: &Os) -> Vec<Arch> {
Os::OpenBsd => vec![Arch::X86, Arch::X86_64, Arch::Aarch64],
Os::Dragonfly => vec![Arch::X86_64],
Os::Illumos => vec![Arch::X86_64],
Os::Haiku => vec![Arch::X86_64],
}
}

Expand Down Expand Up @@ -131,6 +134,7 @@ impl Target {
target_lexicon::OperatingSystem::Openbsd => Os::OpenBsd,
target_lexicon::OperatingSystem::Dragonfly => Os::Dragonfly,
target_lexicon::OperatingSystem::Illumos => Os::Illumos,
target_lexicon::OperatingSystem::Haiku => Os::Haiku,
unsupported => bail!("The operating system {:?} is not supported", unsupported),
};

Expand Down Expand Up @@ -195,7 +199,10 @@ impl Target {
arch
)
}
(Os::Dragonfly, Arch::X86_64) => {
// DragonFly
(Os::Dragonfly, Arch::X86_64)
// Haiku
| (Os::Haiku, Arch::X86_64) => {
let info = PlatformInfo::new()?;
let release = info.release().replace(".", "_").replace("-", "_");
format!(
Expand Down Expand Up @@ -289,6 +296,7 @@ impl Target {
Os::OpenBsd => "openbsd",
Os::Dragonfly => "dragonfly",
Os::Illumos => "sunos",
Os::Haiku => "haiku",
}
}

Expand Down Expand Up @@ -330,7 +338,8 @@ impl Target {
| Os::NetBsd
| Os::OpenBsd
| Os::Dragonfly
| Os::Illumos => true,
| Os::Illumos
| Os::Haiku => true,
}
}

Expand Down Expand Up @@ -364,6 +373,11 @@ impl Target {
self.os == Os::Illumos
}

/// Returns true if the current platform is haiku
pub fn is_haiku(&self) -> bool {
self.os == Os::Haiku
}

/// Returns true if the current platform's target env is Musl
pub fn is_musl_target(&self) -> bool {
matches!(
Expand Down
Loading

0 comments on commit 6ef73f2

Please sign in to comment.