Skip to content

Commit

Permalink
Merge pull request #1600 from eerii/nolink
Browse files Browse the repository at this point in the history
Remove link attribute generation
  • Loading branch information
sdroege authored Sep 19, 2024
2 parents eddf3e7 + ea1ee40 commit a11b11f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 43 deletions.
4 changes: 3 additions & 1 deletion src/codegen/sys/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ fn fill_empty(root: &mut Table, env: &Env, crate_name: &str) {
fn fill_in(root: &mut Table, env: &Env) {
{
let package = upsert_table(root, "package");
set_string(package, "build", "build.rs");
package
.entry("build")
.or_insert_with(|| Value::String("build.rs".into()));
// set_string(package, "version", "0.2.0");
}

Expand Down
13 changes: 0 additions & 13 deletions src/codegen/sys/lib_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ pub fn generate(env: &Env) {
save_to_file(&path, env.config.make_backup, |w| generate_lib(w, env));
}

fn write_link_attr(w: &mut dyn Write, shared_libs: &[String]) -> Result<()> {
for it in shared_libs {
writeln!(
w,
"#[link(name = \"{}\")]",
shared_lib_name_to_link_name(it)
)?;
}

Ok(())
}

fn generate_lib(w: &mut dyn Write, env: &Env) -> Result<()> {
general::start_comments(w, &env.config)?;
statics::begin(w)?;
Expand Down Expand Up @@ -89,7 +77,6 @@ fn generate_lib(w: &mut dyn Write, env: &Env) -> Result<()> {
}

if !env.namespaces.main().shared_libs.is_empty() {
write_link_attr(w, &env.namespaces.main().shared_libs)?;
writeln!(w, "extern \"C\" {{")?;
functions::generate_enums_funcs(w, env, &enums)?;
functions::generate_bitfields_funcs(w, env, &bitfields)?;
Expand Down
29 changes: 0 additions & 29 deletions src/nameutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,6 @@ pub fn lib_name_to_toml(name: &str) -> String {
name.to_string().replace(['-', '.'], "_")
}

pub fn shared_lib_name_to_link_name(name: &str) -> &str {
let mut s = name;

if s.starts_with("lib") {
s = &s[3..];
}

if let Some(offset) = s.rfind(".so") {
s = &s[..offset];
} else if let Some(offset) = s.rfind(".dll") {
s = &s[..offset];
if let Some(offset) = s.rfind('-') {
s = &s[..offset];
}
}

s
}

pub fn use_glib_type(env: &crate::env::Env, import: &str) -> String {
format!(
"{}::{}",
Expand Down Expand Up @@ -253,14 +234,4 @@ mod tests {
fn lib_name_to_toml_works() {
assert_eq!(lib_name_to_toml("gstreamer-1.0"), "gstreamer_1_0");
}

#[test]
fn shared_lib_name_to_link_name_works() {
assert_eq!(shared_lib_name_to_link_name("libgtk-4-1.dll"), "gtk-4");
assert_eq!(shared_lib_name_to_link_name("libatk-1.0.so.0"), "atk-1.0");
assert_eq!(
shared_lib_name_to_link_name("libgdk_pixbuf-2.0.so.0"),
"gdk_pixbuf-2.0"
);
}
}

0 comments on commit a11b11f

Please sign in to comment.