Skip to content

Commit 4fcafbd

Browse files
Lebei2046proggeramlug
authored andcommitted
feat: add libDirs support
Add support for specifying library search paths in native library target configurations via the new `libDirs` field in package.json. Changes: - Add `lib_dirs` field to TargetNativeConfig - Parse `libDirs` from package.json - Add `-L` flags for libDirs before linking
1 parent 2f3a82c commit 4fcafbd

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

crates/perry/src/commands/compile.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ pub struct TargetNativeConfig {
555555
pub lib_name: String,
556556
pub frameworks: Vec<String>,
557557
pub libs: Vec<String>,
558+
pub lib_dirs: Vec<String>,
558559
pub pkg_config: Vec<String>,
559560
/// Swift sources (absolute paths) to compile via swiftc and link into the
560561
/// final binary. Used by `--features watchos-swift-app` so a native lib

crates/perry/src/commands/compile/link.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,11 @@ pub(super) fn build_and_run_link(
18581858
cmd.arg("-framework").arg(framework);
18591859
}
18601860

1861+
// Add library search paths
1862+
for lib_dir in &target_config.lib_dirs {
1863+
cmd.arg(format!("-L{}", lib_dir));
1864+
}
1865+
18611866
// Add platform libraries
18621867
for lib in &target_config.libs {
18631868
if is_windows {

crates/perry/src/commands/compile/resolve.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ pub(super) fn parse_native_library_manifest(
205205
.collect()
206206
})
207207
.unwrap_or_default(),
208+
lib_dirs: tc
209+
.get("libDirs")
210+
.and_then(|l| l.as_array())
211+
.map(|a| {
212+
a.iter()
213+
.filter_map(|v| v.as_str().map(String::from))
214+
.collect()
215+
})
216+
.unwrap_or_default(),
208217
pkg_config: tc
209218
.get("pkgConfig")
210219
.and_then(|p| p.as_array())

0 commit comments

Comments
 (0)