Skip to content

Commit

Permalink
build: use cassandra.h from top-level include directory
Browse files Browse the repository at this point in the history
Currently, we use two cassandra.h files during build.
- include/cassandra.h -> an original file, copied from cpp-driver
- scylla-rust-wrapper/extern/cassandra.h -> a copy of the above file,
  used to generate bindings in build.rs.

Having both of the files is error-prone, since we need to remember
to update both of the files in case of some changes. We also need to
make sure that their contents are the same.

In this commit, I update `build.rs` to point to original cassandra.h
file (which is out of the scope of Cargo project, but it does not
seem to be a problem).
  • Loading branch information
muzarski committed Oct 21, 2024
1 parent 3bb9a49 commit 0bd5e0d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scylla-rust-wrapper/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ extern crate bindgen;
use std::env;
use std::path::{Path, PathBuf};

const RELATIVE_PATH_TO_CASSANDRA_H: &str = "../include/cassandra.h";

fn prepare_full_bindings(out_path: &Path) {
let bindings = bindgen::Builder::default()
.header("extern/cassandra.h")
.header(RELATIVE_PATH_TO_CASSANDRA_H)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.layout_tests(false)
.generate_comments(false)
Expand All @@ -23,7 +25,7 @@ fn prepare_full_bindings(out_path: &Path) {

fn prepare_basic_types(out_path: &Path) {
let basic_bindings = bindgen::Builder::default()
.header("extern/cassandra.h")
.header(RELATIVE_PATH_TO_CASSANDRA_H)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.layout_tests(true)
.generate_comments(false)
Expand Down Expand Up @@ -56,7 +58,7 @@ fn prepare_basic_types(out_path: &Path) {

fn prepare_cppdriver_data(outfile: &str, allowed_types: &[&str], out_path: &Path) {
let mut type_bindings = bindgen::Builder::default()
.header("extern/cassandra.h")
.header(RELATIVE_PATH_TO_CASSANDRA_H)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.layout_tests(true)
.generate_comments(false)
Expand All @@ -79,7 +81,7 @@ fn prepare_cppdriver_data(outfile: &str, allowed_types: &[&str], out_path: &Path
}

fn main() {
println!("cargo:rerun-if-changed=extern/cassandra.h");
println!("cargo:rerun-if-changed={}", RELATIVE_PATH_TO_CASSANDRA_H);
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
prepare_full_bindings(&out_path);
prepare_basic_types(&out_path);
Expand Down

0 comments on commit 0bd5e0d

Please sign in to comment.