Skip to content

Commit

Permalink
Support frameworks that don't have anything to link to
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 9, 2024
1 parent 4961dda commit 5a6cc13
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
7 changes: 7 additions & 0 deletions crates/header-translator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, ClassData>,
Expand Down Expand Up @@ -289,6 +292,10 @@ fn skipped_default() -> bool {
false
}

fn link_default() -> bool {
true
}

impl Default for MethodData {
fn default() -> Self {
Self {
Expand Down
26 changes: 14 additions & 12 deletions crates/header-translator/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
Expand Down

0 comments on commit 5a6cc13

Please sign in to comment.