Skip to content

Commit 808ef15

Browse files
committed
Unified: Ensure extractor can find the Swift .so when built with cargo
1 parent 8d9792a commit 808ef15

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

unified/extractor/build.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn main() {
2+
if let Ok(dir) = std::env::var("DEP_SWIFTSYNTAXFFI_LIBDIR") {
3+
println!("cargo:rustc-link-search=native={dir}");
4+
println!("cargo:rustc-link-lib=dylib=SwiftSyntaxFFI");
5+
println!("cargo:rustc-link-arg=-Wl,-rpath,{dir}");
6+
}
7+
if let Ok(dir) = std::env::var("DEP_SWIFTSYNTAXFFI_RUNTIMEDIR") {
8+
println!("cargo:rustc-link-arg=-Wl,-rpath,{dir}");
9+
}
10+
}

unified/swift-syntax-rs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description = "Rust wrapper around the swift-syntax package for parsing Swift so
44
version = "0.1.0"
55
authors = ["GitHub"]
66
edition = "2024"
7+
links = "SwiftSyntaxFFI"
78

89
[lib]
910
name = "swift_syntax_rs"

unified/swift-syntax-rs/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ fn main() {
5656
println!("cargo:rustc-link-search=native={}", build_dir.display());
5757
println!("cargo:rustc-link-lib=dylib=SwiftSyntaxFFI");
5858
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", build_dir.display());
59+
println!("cargo:libdir={}", build_dir.display());
5960

6061
// The executable also needs to find the Swift runtime libraries at run time.
6162
if let Some(runtime) = swift_runtime_dir() {
6263
println!("cargo:rustc-link-search=native={}", runtime.display());
6364
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", runtime.display());
65+
println!("cargo:runtimedir={}", runtime.display());
6466
}
6567
}
6668

0 commit comments

Comments
 (0)