diff --git a/Cargo.toml b/Cargo.toml index 28d1eba1e..3999d9a63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/build_context.rs b/src/build_context.rs index 150c90f8b..55a3dc6b6 100644 --- a/src/build_context.rs +++ b/src/build_context.rs @@ -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() diff --git a/src/module_writer.rs b/src/module_writer.rs index 4b35581c4..02ea901e3 100644 --- a/src/module_writer.rs +++ b/src/module_writer.rs @@ -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() => { diff --git a/src/python_interpreter/mod.rs b/src/python_interpreter/mod.rs index eaacaca81..2050f8a3f 100644 --- a/src/python_interpreter/mod.rs +++ b/src/python_interpreter/mod.rs @@ -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 ಠ_ಠ", diff --git a/src/target/mod.rs b/src/target/mod.rs index 8f5a98bf9..5744e03b5 100644 --- a/src/target/mod.rs +++ b/src/target/mod.rs @@ -43,6 +43,7 @@ pub enum Os { Wasi, Aix, Hurd, + Cygwin, } impl fmt::Display for Os { @@ -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"), } } } @@ -209,6 +211,7 @@ fn get_supported_architectures(os: &Os) -> Vec { 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], } } @@ -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), }; @@ -463,6 +467,7 @@ impl Target { Os::Wasi => "wasi", Os::Aix => "aix", Os::Hurd => "gnu", + Os::Cygwin => "cygwin", } } @@ -558,7 +563,8 @@ impl Target { | Os::Emscripten | Os::Wasi | Os::Aix - | Os::Hurd => true, + | Os::Hurd + | Os::Cygwin => true, } } @@ -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 {