pdftract/crates/pdftract-libpdftract/build.rs
jedarden 9c7f9d3e37 test(pdftract-5ya9x): update memory roundtrip test to 10,000 iterations
- Updated test_api_null.c to run 10,000 alloc/free cycles (was 100)
- Updated verification note to mark memory roundtrip as PASS
- Improved stream_next implementation to use reference-based approach
  instead of Box::from_raw/leak dance for cleaner memory handling

All acceptance criteria for pdftract-5ya9x now PASS:
- 12 exported symbols verified via nm -D
- C client tests (test_api.c, test_api_null.c)
- C++ client test (test_extract.cpp)
- Null pointer safety
- Panic safety (catch_unwind on all entry points)
- Memory roundtrip (10,000 iterations)
- Thread safety (8 pthreads)

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-05-23 08:13:31 -04:00

26 lines
842 B
Rust

fn main() {
let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
// Try to generate bindings with cbindgen, but don't fail if it can't parse
let config = match cbindgen::Config::from_file(format!("{crate_dir}/cbindgen.toml")) {
Ok(cfg) => cfg,
Err(_) => {
eprintln!("Warning: cbindgen config not found, skipping header generation");
return;
}
};
match cbindgen::Builder::new()
.with_crate(&crate_dir)
.with_config(config)
.generate()
{
Ok(bindings) => {
bindings.write_to_file(format!("{crate_dir}/include/pdftract.h"));
}
Err(e) => {
eprintln!("Warning: cbindgen failed to generate bindings: {}", e);
eprintln!("Using manually maintained header instead");
}
}
}