diff --git a/crates/header-translator/src/config.rs b/crates/header-translator/src/config.rs index 2f4def198..801865d09 100644 --- a/crates/header-translator/src/config.rs +++ b/crates/header-translator/src/config.rs @@ -134,6 +134,9 @@ pub struct LibraryConfig { #[serde(default)] pub gnustep: bool, + #[serde(default = "link_default")] + pub link: bool, + #[serde(rename = "class")] #[serde(default)] pub class_data: HashMap, @@ -289,6 +292,10 @@ fn skipped_default() -> bool { false } +fn link_default() -> bool { + true +} + impl Default for MethodData { fn default() -> Self { Self { diff --git a/crates/header-translator/src/library.rs b/crates/header-translator/src/library.rs index 957f0b18a..79bf59ab1 100644 --- a/crates/header-translator/src/library.rs +++ b/crates/header-translator/src/library.rs @@ -449,23 +449,25 @@ see that for related crates.", self.data.krate, self.link_name)?; writeln!(f)?; - // Link to the correct framework. - if self.data.gnustep { - // Allow for different linking on GNUStep - writeln!( + if self.data.link { + // Link to the correct framework. + if self.data.gnustep { + // Allow for different linking on GNUStep + writeln!( f, "#[cfg_attr(target_vendor = \"apple\", link(name = \"{}\", kind = \"framework\"))]", self.link_name )?; - } else { - writeln!( - f, - "#[link(name = \"{}\", kind = \"framework\")]", - self.link_name - )?; + } else { + writeln!( + f, + "#[link(name = \"{}\", kind = \"framework\")]", + self.link_name + )?; + } + writeln!(f, "extern \"C\" {{}}")?; + writeln!(f)?; } - writeln!(f, "extern \"C\" {{}}")?; - writeln!(f)?; if !self.module.submodules.is_empty() { write!(f, "{}", self.module.modules(config))?;