Skip to content

Commit 3e6560f

Browse files
authored
feat(Rust): Enable Rust build on macOS and update Arrow linking (#857)
1 parent eab0fa5 commit 3e6560f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

rust/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ cxx = "1.0.190"
2828
[build-dependencies]
2929
cxx-build = "1.0.190"
3030
cmake = "0.1.54"
31+
pkg-config = "0.3.32"
3132

3233
[dev-dependencies]
3334
tempfile = "3"

rust/build.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ use std::env;
2121
use std::path::{Path, PathBuf};
2222

2323
fn link_libraries() {
24-
// TODO: Link to system Arrow, `libarrow` is under `/usr/lib/x86_64-linux-gnu/` on Ubuntu
25-
println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
26-
println!("cargo:rustc-link-lib=dylib=arrow_compute");
27-
println!("cargo:rustc-link-lib=dylib=arrow_dataset");
28-
println!("cargo:rustc-link-lib=dylib=arrow_acero");
29-
println!("cargo:rustc-link-lib=dylib=arrow");
24+
println!("cargo:rerun-if-env-changed=PKG_CONFIG_PATH");
25+
26+
let _arrow = pkg_config::Config::new()
27+
.statik(false)
28+
.cargo_metadata(true)
29+
.probe("arrow")
30+
.expect("Arrow development files not found via pkg-config. Set PKG_CONFIG_PATH if needed.");
3031

3132
println!("cargo:rustc-link-lib=graphar");
3233
}
@@ -63,6 +64,11 @@ fn build_graphar() -> Vec<PathBuf> {
6364
.define("CMAKE_BUILD_TYPE", cmake_build_type)
6465
.define("GRAPHAR_BUILD_STATIC", "ON")
6566
.define("GRAPHAR_ENABLE_SANITIZER", "OFF");
67+
68+
if let Ok(prefix) = pkg_config::get_variable("arrow", "prefix") {
69+
build.define("CMAKE_PREFIX_PATH", prefix);
70+
}
71+
println!("cargo:rerun-if-env-changed=PKG_CONFIG_PATH");
6672
let build_dir = build.build();
6773

6874
let lib_path = build_dir.join("build");

0 commit comments

Comments
 (0)