1#[cfg(any(feature = "bundled", feature = "bundled_without_openssl"))]
2extern crate pq_src;
3
4#[allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
5mod bindings {
6 #[cfg(buildscript_run)]
7 include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
8}
9
10#[cfg(not(buildscript_run))]
11compile_error!(
12 "pq-sys relies on build scripts beeing executed. \n \
13 Please double check that you don't have a `[target.*.pq]` entry \
14 in your `.cargo/config.toml`\n \
15 These entries prevent build scripts from beeing run"
16);
17
18pub use bindings::*;
19
20#[test]
21fn check_generated_bindings_match() {
22 let libpq_include_path = concat!(
23 env!("CARGO_MANIFEST_DIR"),
24 "/pq-src/source/src/interfaces/libpq/"
25 );
26 let postgres_include_path = concat!(env!("CARGO_MANIFEST_DIR"), "/pq-src/source/src/include");
27 let additional_includes_path =
28 concat!(env!("CARGO_MANIFEST_DIR"), "/pq-src/additional_include/");
29
30 let builder = include!("make_bindings.rs").clang_args([
31 "-I",
32 libpq_include_path,
33 "-I",
34 postgres_include_path,
35 "-I",
36 additional_includes_path,
37 ]);
38
39 let generated_bindings = builder.generate().expect("Unable to generate bindings");
40
41 let mut out = Vec::<u8>::new();
42 generated_bindings.write(Box::new(&mut out)).unwrap();
43 let generated_bindings = String::from_utf8(out).unwrap();
44
45 let bundled_bindings =
46 std::fs::read_to_string(String::from(env!("OUT_DIR")) + "/bindings.rs").unwrap();
47 similar_asserts::assert_eq!(generated_bindings, bundled_bindings,)
48}