Skip to content

Commit 9465edd

Browse files
author
eulegang
committed
Adding rpath support
1 parent d442626 commit 9465edd

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub struct Library {
9898
pub frameworks: Vec<String>,
9999
pub framework_paths: Vec<PathBuf>,
100100
pub include_paths: Vec<PathBuf>,
101+
pub rpaths: Vec<PathBuf>,
101102
pub defines: HashMap<String, Option<String>>,
102103
pub version: String,
103104
_priv: (),
@@ -557,6 +558,7 @@ impl Library {
557558
libs: Vec::new(),
558559
link_paths: Vec::new(),
559560
include_paths: Vec::new(),
561+
rpaths: Vec::new(),
560562
frameworks: Vec::new(),
561563
framework_paths: Vec::new(),
562564
defines: HashMap::new(),
@@ -667,6 +669,13 @@ impl Library {
667669
self.include_paths.push(PathBuf::from(inc));
668670
}
669671
}
672+
"-rpath" => {
673+
if let Some(rpath) = iter.next() {
674+
let meta = format!("rustc-link-arg=-Wl,-rpath,{}", rpath);
675+
config.print_metadata(&meta);
676+
self.rpaths.push(PathBuf::from(rpath));
677+
}
678+
}
670679
_ => (),
671680
}
672681
}

tests/rpath.pc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
prefix=/usr/local
2+
3+
Name: rpath
4+
Version: 4.2.0
5+
Description: RPath example library
6+
Libs: -L${prefix}/lib -Wl,-rpath,${prefix}/lib -lrpath
7+
Cflags: -I${prefix}/include

tests/test.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,11 @@ fn range_version_full() {
311311
.probe("escape")
312312
.unwrap();
313313
}
314+
315+
#[test]
316+
fn rpath() {
317+
let _g = LOCK.lock();
318+
reset();
319+
let lib = find("rpath").unwrap();
320+
assert!(lib.rpaths.contains(&PathBuf::from("/usr/local/lib")));
321+
}

0 commit comments

Comments
 (0)