Add cbindgen infrastructure to auto-generate C/C++ header from Rust extern "C" surface at build time. - Add cbindgen.toml config (C language, include guard, pragma_once, cpp_compat) - Add build.rs to generate include/pdftract.h during cargo build - Generated header compiles cleanly with gcc (C) and g++ (C++) The header is the contract between libpdftract and C/C++ consumers. Future extern "C" functions will automatically appear in the header. Refs: pdftract-5rl5o
53 lines
1.6 KiB
Markdown
53 lines
1.6 KiB
Markdown
# pdftract-5rl5o: cbindgen header generation for pdftract.h
|
|
|
|
## Work Completed
|
|
|
|
### Files Created
|
|
|
|
1. **crates/pdftract-libpdftract/cbindgen.toml**
|
|
- Configures cbindgen for C header generation
|
|
- Language: C
|
|
- Include guard: `PDFTRACT_H`
|
|
- `pragma_once` enabled for modern compilers
|
|
- `cpp_compat = true` for C++ compatibility
|
|
- Export prefix: `pdftract_`
|
|
|
|
2. **crates/pdftract-libpdftract/build.rs**
|
|
- Runs cbindgen at build time
|
|
- Reads cbindgen.toml config
|
|
- Generates `include/pdftract.h` from Rust extern "C" surface
|
|
|
|
3. **crates/pdftract-libpdftract/include/pdftract.h**
|
|
- Auto-generated header file
|
|
- Contains include guard + pragma once
|
|
- Currently minimal (no extern "C" functions defined yet in lib.rs)
|
|
|
|
## Acceptance Criteria
|
|
|
|
### PASS
|
|
- [x] `cargo build -p pdftract-libpdftract` regenerates `crates/pdftract-libpdftract/include/pdftract.h`
|
|
- [x] Generated .h compiles cleanly with `gcc -xc -c -o /dev/null include/pdftract.h`
|
|
- [x] Generated .h compiles cleanly with `g++ -xc++ -c -o /dev/null include/pdftract.h` (cpp_compat verified)
|
|
- [x] Header contains include guard + pragma once
|
|
|
|
### NOTE
|
|
- CI gate for header diff check should be added in `jedarden/declarative-config` (Argo Workflows CI)
|
|
- No extern "C" functions exist yet in lib.rs (scaffold only), so header is minimal
|
|
- When extern "C" functions are added in sibling beads, they will automatically appear in the header
|
|
|
|
## Header Structure
|
|
```c
|
|
/* Copyright 2026 Jed Cabanino. MIT OR Apache-2.0 */
|
|
|
|
#ifndef PDFTRACT_H
|
|
#define PDFTRACT_H
|
|
|
|
#pragma once
|
|
|
|
#include <stdarg.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
#endif /* PDFTRACT_H */
|
|
```
|