Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove link attribute generation #1600

Merged
merged 2 commits into from
Sep 19, 2024
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
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"
);
}
}
Loading