Skip to content

Commit

Permalink
Update build.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
qxrein authored Dec 26, 2024
1 parent 37cb83a commit 5a93b25
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"version",
"set_binary_mode",
]);

#[cfg(feature = "hardsubx_ocr")]
allowlist_functions.extend_from_slice(&[
"edit_distance",
"convert_pts_to_.*",
"av_rescale_q",
"mprint",
]);

let mut allowlist_types = Vec::new();
allowlist_types.extend_from_slice(&[
".*(?i)_?dtvcc_.*",
Expand All @@ -45,29 +47,37 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"uint8_t",
"word_list",
]);

#[cfg(feature = "hardsubx_ocr")]
allowlist_types.extend_from_slice(&["AVRational", "AVPacket", "AVFrame"]);

let mut builder = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.header("wrapper.h");

// enable hardsubx if and only if the feature is on
#[cfg(feature = "hardsubx_ocr")]
{
builder = builder.clang_arg("-DENABLE_HARDSUBX");
}

// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
builder = builder.parse_callbacks(Box::new(bindgen::CargoCallbacks));

for type_name in allowlist_types {
builder = builder.allowlist_type(type_name);
}

for fn_name in allowlist_functions {
builder = builder.allowlist_function(fn_name);
}

for rust_enum in RUSTIFIED_ENUMS {
builder = builder.rustified_enum(rust_enum);
}

let bindings = builder
.derive_default(true)
.no_default("dtvcc_pen_attribs|dtvcc_pen_color|dtvcc_symbol")
Expand Down

0 comments on commit 5a93b25

Please sign in to comment.