Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fat-macho = { version = "0.4.8", default-features = false }
once_cell = "1.7.2"
rustc_version = "0.4.0"
semver = "1.0.22"
target-lexicon = "0.13.0"
target-lexicon = "0.13.3"
indexmap = "2.2.3"
pyproject-toml = { version = "0.13.5", features = ["pep639-glob"] }
python-pkginfo = "0.6.6"
Expand Down
8 changes: 8 additions & 0 deletions src/build_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,14 @@ impl BuildContext {
(Os::Wasi, Arch::Wasm32) => {
"any".to_string()
}
// Cygwin
(Os::Cygwin, _) => {
format!(
"{}_{}",
target.target_os().to_string().to_ascii_lowercase(),
target.get_platform_arch()?,
)
}
// osname_release_machine fallback for any POSIX system
(_, _) => {
let info = PlatformInfo::new()
Expand Down
6 changes: 5 additions & 1 deletion src/module_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,11 @@ pub fn write_bindings_module(
let ext_name = &project_layout.extension_name;
let so_filename = if is_abi3 {
if target.is_unix() {
format!("{ext_name}.abi3.so")
if target.is_cygwin() {
format!("{ext_name}.abi3.dll")
} else {
format!("{ext_name}.abi3.so")
}
} else {
match python_interpreter {
Some(python_interpreter) if python_interpreter.is_windows_debug() => {
Expand Down
2 changes: 2 additions & 0 deletions src/python_interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ fn fun_with_abiflags(
if bridge != &BridgeModel::Cffi
&& target.get_python_os() != message.system
&& !target.cross_compiling()
&& !(target.get_python_os() == "cygwin"
&& message.system.to_lowercase().starts_with("cygwin"))
{
bail!(
"platform.system() in python, {}, and the rust target, {:?}, don't match ಠ_ಠ",
Expand Down
14 changes: 13 additions & 1 deletion src/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub enum Os {
Wasi,
Aix,
Hurd,
Cygwin,
}

impl fmt::Display for Os {
Expand All @@ -63,6 +64,7 @@ impl fmt::Display for Os {
Os::Wasi => write!(f, "Wasi"),
Os::Aix => write!(f, "AIX"),
Os::Hurd => write!(f, "Hurd"),
Os::Cygwin => write!(f, "Cygwin"),
}
}
}
Expand Down Expand Up @@ -209,6 +211,7 @@ fn get_supported_architectures(os: &Os) -> Vec<Arch> {
Os::Emscripten | Os::Wasi => vec![Arch::Wasm32],
Os::Aix => vec![Arch::Powerpc64],
Os::Hurd => vec![Arch::X86, Arch::X86_64],
Os::Cygwin => vec![Arch::X86, Arch::X86_64],
}
}

Expand Down Expand Up @@ -283,6 +286,7 @@ impl Target {
OperatingSystem::Wasi | OperatingSystem::WasiP1 | OperatingSystem::WasiP2 => Os::Wasi,
OperatingSystem::Aix => Os::Aix,
OperatingSystem::Hurd => Os::Hurd,
OperatingSystem::Cygwin => Os::Cygwin,
unsupported => bail!("The operating system {:?} is not supported", unsupported),
};

Expand Down Expand Up @@ -463,6 +467,7 @@ impl Target {
Os::Wasi => "wasi",
Os::Aix => "aix",
Os::Hurd => "gnu",
Os::Cygwin => "cygwin",
}
}

Expand Down Expand Up @@ -558,7 +563,8 @@ impl Target {
| Os::Emscripten
| Os::Wasi
| Os::Aix
| Os::Hurd => true,
| Os::Hurd
| Os::Cygwin => true,
}
}

Expand Down Expand Up @@ -610,6 +616,12 @@ impl Target {
self.env == Environment::Msvc
}

/// Returns true if the current platform is cygwin
#[inline]
pub fn is_cygwin(&self) -> bool {
self.os == Os::Cygwin
}

/// Returns true if the current platform is illumos
#[inline]
pub fn is_illumos(&self) -> bool {
Expand Down
Loading