Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak bindgen #1352

Merged
merged 1 commit into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 3 additions & 11 deletions libsqlite3-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ mod build_bundled {
fs::copy(format!("{lib_name}/bindgen_bundled_version.rs"), out_path)
.expect("Could not copy bindings to output directory");
}
// println!("cargo:rerun-if-changed=sqlite3/sqlite3.c");
// println!("cargo:rerun-if-changed=sqlcipher/sqlite3.c");
println!("cargo:rerun-if-changed={lib_name}/sqlite3.c");
println!("cargo:rerun-if-changed=sqlite3/wasm32-wasi-vfs.c");
let mut cfg = cc::Build::new();
Expand Down Expand Up @@ -499,24 +497,16 @@ mod bindings {
struct SqliteTypeChooser;

impl ParseCallbacks for SqliteTypeChooser {
fn int_macro(&self, name: &str, value: i64) -> Option<IntKind> {
fn int_macro(&self, name: &str, _value: i64) -> Option<IntKind> {
if name == "SQLITE_SERIALIZE_NOCOPY"
|| name.starts_with("SQLITE_DESERIALIZE_")
|| name.starts_with("SQLITE_PREPARE_")
{
Some(IntKind::UInt)
} else if value >= i32::MIN as i64 && value <= i32::MAX as i64 {
Some(IntKind::I32)
} else {
None
}
}

fn item_name(&self, original_item_name: &str) -> Option<String> {
original_item_name
.strip_prefix("sqlite3_index_info_")
.map(|s| s.to_owned())
}
}

// Are we generating the bundled bindings? Used to avoid emitting things
Expand All @@ -535,6 +525,8 @@ mod bindings {
let header: String = header.into();
let mut output = Vec::new();
let mut bindings = bindgen::builder()
.default_macro_constant_type(bindgen::MacroTypeVariation::Signed)
.disable_nested_struct_naming()
.trust_clang_mangling(false)
.header(header.clone())
.parse_callbacks(Box::new(SqliteTypeChooser))
Expand Down