Include Swift in rpath on linux
This commit is contained in:
parent
dae4f63955
commit
592692c004
@ -5,6 +5,10 @@ edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[build-dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
[dependencies]
|
||||
activitystreams = "0.7.0-alpha.22"
|
||||
activitystreams-ext = "0.1.0-alpha.3"
|
||||
|
41
build.rs
41
build.rs
@ -1,5 +1,42 @@
|
||||
// generated by `sqlx migrate build-script`
|
||||
use serde::Deserialize;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
// trigger recompilation when a new migration is added
|
||||
println!("cargo:rerun-if-changed=migrations");
|
||||
}
|
||||
|
||||
let target = get_swift_target_info();
|
||||
if target.target.unversioned_triple.contains("linux") {
|
||||
target.paths.runtime_library_paths.iter().for_each(|path| {
|
||||
println!("cargo:rustc-link-arg=-Wl,-rpath={}", path);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SwiftTargetInfo {
|
||||
pub unversioned_triple: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SwiftPaths {
|
||||
pub runtime_library_paths: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct SwiftTarget {
|
||||
pub target: SwiftTargetInfo,
|
||||
pub paths: SwiftPaths,
|
||||
}
|
||||
|
||||
pub fn get_swift_target_info() -> SwiftTarget {
|
||||
let swift_target_info_str = Command::new("swift")
|
||||
.args(&["-print-target-info"])
|
||||
.output()
|
||||
.unwrap()
|
||||
.stdout;
|
||||
|
||||
serde_json::from_slice(&swift_target_info_str).unwrap()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user