From c6ab69ef70834b31acad69c3c367796408485c0d Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Mon, 28 Jul 2025 22:48:06 -0300 Subject: [PATCH 1/2] Fix installing debuginfo files for plugins in the wrong folder They're supposed to be side-by-side, and for plugins they were being installed in the bindir. --- src/install.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/install.rs b/src/install.rs index a934c32..dfef5da 100644 --- a/src/install.rs +++ b/src/install.rs @@ -285,9 +285,17 @@ pub fn cinstall(ws: &Workspace, packages: &[CPackage]) -> anyhow::Result<()> { ws.gctx() .shell() .status("Installing", "debugging information")?; - let destination_path = build_targets - .debug_info_file_name(&install_path_bin, &install_path_lib) - .unwrap(); + + let destination_path = if capi_config.library.install_subdir.is_none() { + build_targets + .debug_info_file_name(&install_path_bin, &install_path_lib) + .unwrap() + } else { + // We assume they are plugins, install them in the custom libdir path + build_targets + .debug_info_file_name(&install_path_lib, &install_path_lib) + .unwrap() + }; create_dir_all(destination_path.parent().unwrap())?; copy(ws, debug_info, destination_path)?; From 29eacd7b668890b3c43bd06e66e2cfbdce039f88 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Mon, 28 Jul 2025 22:48:39 -0300 Subject: [PATCH 2/2] Implement installing dSYMs if available --- src/build.rs | 30 ++++++++++++++++++++++++++++-- src/build_targets.rs | 8 ++++---- src/install.rs | 25 ++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/build.rs b/src/build.rs index 9badcfa..48a726b 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use std::hash::{DefaultHasher, Hash, Hasher}; -use std::io::Read; +use std::io::{ErrorKind, Read}; use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; @@ -1277,7 +1277,33 @@ pub fn cbuild( from_build_targets.debug_info.as_ref(), build_targets.debug_info.as_ref(), ) { - copy(from_debug_info, to_debug_info)?; + if from_debug_info.exists() { + create_dir_all(to_debug_info.parent().unwrap())?; + if from_debug_info.is_dir() { + let files = + from_debug_info.read_dir()?.collect::, _>>()?; + for f in files.iter() { + let src = f.path(); + let file_name = src.strip_prefix(from_debug_info)?; + let dst = to_debug_info.join(file_name); + match std::fs::create_dir_all( + dst.parent().expect("Source path is not complete"), + ) { + Ok(()) => Ok(()), + Err(v) => { + if v.kind() == ErrorKind::AlreadyExists { + Ok(()) + } else { + Err(v) + } + } + }?; + copy(src, dst)?; + } + } else { + copy(from_debug_info, to_debug_info)?; + } + } } } diff --git a/src/build_targets.rs b/src/build_targets.rs index 53938bf..052355b 100644 --- a/src/build_targets.rs +++ b/src/build_targets.rs @@ -171,7 +171,8 @@ impl FileNames { "macos" | "ios" | "tvos" | "visionos" => { let static_lib = targetdir.join(format!("lib{lib_name}.a")); let shared_lib = targetdir.join(format!("lib{lib_name}.dylib")); - (shared_lib, static_lib, None, None, None) + let pdb = Some(targetdir.join(format!("lib{lib_name}.dSYM"))); + (shared_lib, static_lib, None, pdb, None) } "windows" => { let shared_lib = targetdir.join(format!("{lib_name}.dll")); @@ -194,9 +195,8 @@ impl FileNames { } else { targetdir.join(format!("{lib_name}.dll.a")) }; - let pdb = None; - (shared_lib, static_lib, Some(impl_lib), pdb, Some(def)) + (shared_lib, static_lib, Some(impl_lib), None, Some(def)) } } _ => return None, @@ -269,7 +269,7 @@ mod test { static_lib: PathBuf::from("/foo/bar/libferris.a"), shared_lib: PathBuf::from("/foo/bar/libferris.dylib"), impl_lib: None, - debug_info: None, + debug_info: Some(PathBuf::from("/foo/bar/libferris.dSYM")), def: None, }; diff --git a/src/install.rs b/src/install.rs index dfef5da..f093af0 100644 --- a/src/install.rs +++ b/src/install.rs @@ -1,4 +1,5 @@ use clap::ArgMatches; +use std::io::ErrorKind; use std::path::{Component, Path, PathBuf}; use cargo::core::Workspace; @@ -298,7 +299,29 @@ pub fn cinstall(ws: &Workspace, packages: &[CPackage]) -> anyhow::Result<()> { }; create_dir_all(destination_path.parent().unwrap())?; - copy(ws, debug_info, destination_path)?; + if debug_info.is_dir() { + let files = debug_info.read_dir()?.collect::, _>>()?; + for f in files.iter() { + let src = f.path(); + let file_name = src.strip_prefix(debug_info)?; + let dst = destination_path.join(file_name); + match std::fs::create_dir_all( + dst.parent().expect("Source path is not complete"), + ) { + Ok(()) => Ok(()), + Err(v) => { + if v.kind() == ErrorKind::AlreadyExists { + Ok(()) + } else { + Err(v) + } + } + }?; + copy(ws, src, dst)?; + } + } else { + copy(ws, debug_info, destination_path)?; + } } else { ws.gctx() .shell()