From 58113b0777281705f97db6598465d44bf423e365 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 8 Jul 2023 10:39:36 +0200 Subject: [PATCH] Simplify bindgen generation `rusqlite` users cannot use old versions (< 3.8.3) of SQLite anymore. And `libsqlite3-sys` users should not use SQLITE_DETERMINISTIC when using SQLite < 3.8.3. --- libsqlite3-sys/build.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 52f918f..c1a00a7 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -522,7 +522,6 @@ mod bindings { pub fn write_to_out_dir(header: HeaderLocation, out_path: &Path) { 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() @@ -631,21 +630,7 @@ mod bindings { .layout_tests(false) .generate() .unwrap_or_else(|_| panic!("could not run bindgen on header {}", header)) - .write(Box::new(&mut output)) - .expect("could not write output of bindgen"); - let mut output = String::from_utf8(output).expect("bindgen output was not UTF-8?!"); - - // rusqlite's functions feature ors in the SQLITE_DETERMINISTIC flag when it - // can. This flag was added in SQLite 3.8.3, but oring it in in prior - // versions of SQLite is harmless. We don't want to not build just - // because this flag is missing (e.g., if we're linking against - // SQLite 3.7.x), so append the flag manually if it isn't present in bindgen's - // output. - if !output.contains("pub const SQLITE_DETERMINISTIC") { - output.push_str("\npub const SQLITE_DETERMINISTIC: i32 = 2048;\n"); - } - - fs::write(out_path, output.as_bytes()) + .write_to_file(out_path) .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); } }