Skip to content

Commit

Permalink
fix: try to manually specify ffmpeg header in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekmedia committed Jun 14, 2024
1 parent ba628b9 commit 02445c8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mac/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ if HARDSUBX_IS_ENABLED
ccextractor_CFLAGS += -DENABLE_HARDSUBX
libavcodec_CFLAGS = $(shell pkg-config --cflags libavcodec)
libavformat_CFLAGS = $(shell pkg-config --cflags libavformat)
libavutil_CFALGS = $(shell pkg-config --cflags libavutil)
libavutil_CFLAGS = $(shell pkg-config --cflags libavutil)
libswscale_CFLAGS = $(shell pkg-config --cflags libswscale)
libavcodec_LIBS = $(shell pkg-config --libs libavcodec)
libavformat_LIBS = $(shell pkg-config --libs libavformat)
libavutil_LIBS = $(shell pkg-config --libs libavutil)
libswscale_LIBS = $(shell pkg-config --libs libswscale)
ccextractor_CPPFLAGS+= ${libavcodec_CFLAGS}
ccextractor_CPPFLAGS+= ${libavformat_CFLAGS}
ccextractor_CPPFLAGS+= ${libavutil_CFALGS}
ccextractor_CPPFLAGS+= ${libavutil_CFLAGS}
ccextractor_CPPFLAGS+= ${libswscale_CFLAGS}
AV_LIB = ${libavcodec_LIBS}
AV_LIB += ${libavformat_LIBS}
Expand Down
1 change: 1 addition & 0 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ num-integer = "0.1.45"

[build-dependencies]
bindgen = "0.64.0"
pkg-config = "0.3.30"

[features]
hardsubx_ocr = ["rsmpeg", "tesseract-sys", "leptonica-sys"]
Expand Down
10 changes: 10 additions & 0 deletions src/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
extern crate pkg_config;
use std::env;
use std::path::PathBuf;

Expand Down Expand Up @@ -44,9 +45,18 @@ fn main() {
#[cfg(feature = "hardsubx_ocr")]
allowlist_types.extend_from_slice(&["AVRational", "AVPacket", "AVFrame"]);

std::env::set_var("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS", "1");
let library = pkg_config::probe_library("libavcodec").expect("Unable to probe `libavcodec`");

let mut builder = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.clang_args(
library
.include_paths
.iter()
.map(|path| format!("-I{}", path.to_string_lossy())),
)
.header("wrapper.h");

// enable hardsubx if and only if the feature is on
Expand Down

0 comments on commit 02445c8

Please sign in to comment.