This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sedona-db.git
The following commit(s) were added to refs/heads/main by this push:
new df8f720 chore(c/sedona-s2geography): Remove build time bindgen
dependency (#221)
df8f720 is described below
commit df8f7205a0a99bd75195933084ae4216781f067c
Author: Dewey Dunnington <[email protected]>
AuthorDate: Tue Oct 14 16:42:56 2025 -0500
chore(c/sedona-s2geography): Remove build time bindgen dependency (#221)
---
Cargo.lock | 1 -
c/sedona-s2geography/Cargo.toml | 1 -
c/sedona-s2geography/build.rs | 15 ----
c/sedona-s2geography/src/geography_glue_bindgen.rs | 81 ++++++++++++++++++++--
4 files changed, 76 insertions(+), 22 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 8540082..7eca687 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5093,7 +5093,6 @@ version = "0.2.0"
dependencies = [
"arrow-array",
"arrow-schema",
- "bindgen 0.71.1",
"cmake",
"criterion",
"datafusion-common",
diff --git a/c/sedona-s2geography/Cargo.toml b/c/sedona-s2geography/Cargo.toml
index bdeb3d7..77aabff 100644
--- a/c/sedona-s2geography/Cargo.toml
+++ b/c/sedona-s2geography/Cargo.toml
@@ -27,7 +27,6 @@ edition.workspace = true
rust-version.workspace = true
[build-dependencies]
-bindgen = "0.71.0"
cmake = { version = "0.1" }
regex = { workspace = true }
diff --git a/c/sedona-s2geography/build.rs b/c/sedona-s2geography/build.rs
index 6eadb11..b43cf0f 100644
--- a/c/sedona-s2geography/build.rs
+++ b/c/sedona-s2geography/build.rs
@@ -16,7 +16,6 @@
// under the License.
use std::{
collections::HashSet,
- env,
path::{Path, PathBuf},
};
@@ -59,20 +58,6 @@ fn main() {
// Parse the output we wrote from CMake that is the linker flags
// that CMake thinks we need for Abseil and OpenSSL.
parse_cmake_linker_flags(&dst);
-
- // Generate bindings from the header
- println!("cargo::rerun-if-changed=src/geography_glue.h");
- let bindings = bindgen::Builder::default()
- .header("src/geography_glue.h")
- .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
- .generate()
- .expect("Unable to generate bindings");
-
- // Write the bindings to the $OUT_DIR/bindings.rs file.
- let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
- bindings
- .write_to_file(out_path.join("bindings.rs"))
- .expect("Couldn't write bindings!");
}
fn parse_cmake_linker_flags(binary_dir: &Path) {
diff --git a/c/sedona-s2geography/src/geography_glue_bindgen.rs
b/c/sedona-s2geography/src/geography_glue_bindgen.rs
index 5d8a395..0865b88 100644
--- a/c/sedona-s2geography/src/geography_glue_bindgen.rs
+++ b/c/sedona-s2geography/src/geography_glue_bindgen.rs
@@ -14,9 +14,80 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-#![allow(non_upper_case_globals)]
-#![allow(non_camel_case_types)]
-#![allow(non_snake_case)]
-#![allow(dead_code)]
-include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
+use std::os::raw::{c_char, c_int, c_void};
+
+#[repr(C)]
+pub struct ArrowSchema {
+ _private: [u8; 0],
+}
+
+#[repr(C)]
+pub struct ArrowArray {
+ _private: [u8; 0],
+}
+
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct SedonaGeographyArrowUdf {
+ pub init: Option<
+ unsafe extern "C" fn(
+ self_: *mut SedonaGeographyArrowUdf,
+ arg_schema: *mut ArrowSchema,
+ options: *const c_char,
+ out: *mut ArrowSchema,
+ ) -> c_int,
+ >,
+ pub execute: Option<
+ unsafe extern "C" fn(
+ self_: *mut SedonaGeographyArrowUdf,
+ args: *mut *mut ArrowArray,
+ n_args: i64,
+ out: *mut ArrowArray,
+ ) -> c_int,
+ >,
+ pub get_last_error:
+ Option<unsafe extern "C" fn(self_: *mut SedonaGeographyArrowUdf) ->
*const c_char>,
+ pub release: Option<unsafe extern "C" fn(self_: *mut
SedonaGeographyArrowUdf)>,
+ pub private_data: *mut c_void,
+}
+
+macro_rules! declare_s2_c_udfs {
+ ($($name:ident),*) => {
+ $(
+ paste::item! {
+ pub fn [<SedonaGeographyInitUdf $name>](out: *mut
SedonaGeographyArrowUdf);
+ }
+ )*
+ }
+}
+
+unsafe extern "C" {
+ pub fn SedonaGeographyGlueNanoarrowVersion() -> *const c_char;
+ pub fn SedonaGeographyGlueGeoArrowVersion() -> *const c_char;
+ pub fn SedonaGeographyGlueOpenSSLVersion() -> *const c_char;
+ pub fn SedonaGeographyGlueS2GeometryVersion() -> *const c_char;
+ pub fn SedonaGeographyGlueAbseilVersion() -> *const c_char;
+ pub fn SedonaGeographyGlueTestLinkage() -> f64;
+
+ declare_s2_c_udfs!(
+ Area,
+ Centroid,
+ ClosestPoint,
+ Contains,
+ ConvexHull,
+ Difference,
+ Distance,
+ Equals,
+ Intersection,
+ Intersects,
+ Length,
+ LineInterpolatePoint,
+ LineLocatePoint,
+ MaxDistance,
+ Perimeter,
+ ShortestLine,
+ SymDifference,
+ Union
+ );
+}