This is an automated email from the ASF dual-hosted git repository.

jinyewu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-graphar.git


The following commit(s) were added to refs/heads/main by this push:
     new 3e6560f6 feat(Rust): Enable Rust build on macOS and update Arrow 
linking (#857)
3e6560f6 is described below

commit 3e6560f6fa31d056d2aa5c44a8e6bab80e86ea8d
Author: 姚军 <[email protected]>
AuthorDate: Wed Feb 18 20:14:07 2026 +0800

    feat(Rust): Enable Rust build on macOS and update Arrow linking (#857)
---
 rust/Cargo.lock |  7 +++++++
 rust/Cargo.toml |  1 +
 rust/build.rs   | 18 ++++++++++++------
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 9faaed42..052f39a9 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -191,6 +191,7 @@ dependencies = [
  "cmake",
  "cxx",
  "cxx-build",
+ "pkg-config",
  "tempfile",
 ]
 
@@ -237,6 +238,12 @@ version = "1.21.3"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
 
+[[package]]
+name = "pkg-config"
+version = "0.3.32"
+source = "registry+https://github.com/rust-lang/crates.io-index";
+checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c"
+
 [[package]]
 name = "proc-macro2"
 version = "1.0.103"
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index ba5c9108..7a66444f 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -28,6 +28,7 @@ cxx = "1.0.190"
 [build-dependencies]
 cxx-build = "1.0.190"
 cmake = "0.1.54"
+pkg-config = "0.3.32"
 
 [dev-dependencies]
 tempfile = "3"
diff --git a/rust/build.rs b/rust/build.rs
index 73542f84..4f3f45e0 100644
--- a/rust/build.rs
+++ b/rust/build.rs
@@ -21,12 +21,13 @@ use std::env;
 use std::path::{Path, PathBuf};
 
 fn link_libraries() {
-    // TODO: Link to system Arrow, `libarrow` is under 
`/usr/lib/x86_64-linux-gnu/` on Ubuntu
-    println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
-    println!("cargo:rustc-link-lib=dylib=arrow_compute");
-    println!("cargo:rustc-link-lib=dylib=arrow_dataset");
-    println!("cargo:rustc-link-lib=dylib=arrow_acero");
-    println!("cargo:rustc-link-lib=dylib=arrow");
+    println!("cargo:rerun-if-env-changed=PKG_CONFIG_PATH");
+
+    let _arrow = pkg_config::Config::new()
+        .statik(false)
+        .cargo_metadata(true)
+        .probe("arrow")
+        .expect("Arrow development files not found via pkg-config. Set 
PKG_CONFIG_PATH if needed.");
 
     println!("cargo:rustc-link-lib=graphar");
 }
@@ -63,6 +64,11 @@ fn build_graphar() -> Vec<PathBuf> {
         .define("CMAKE_BUILD_TYPE", cmake_build_type)
         .define("GRAPHAR_BUILD_STATIC", "ON")
         .define("GRAPHAR_ENABLE_SANITIZER", "OFF");
+
+    if let Ok(prefix) = pkg_config::get_variable("arrow", "prefix") {
+        build.define("CMAKE_PREFIX_PATH", prefix);
+    }
+    println!("cargo:rerun-if-env-changed=PKG_CONFIG_PATH");
     let build_dir = build.build();
 
     let lib_path = build_dir.join("build");


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to