Skip to content

Commit 303bec8

Browse files
cfsmp3claude
andcommitted
fix(build): Support FFMPEG_INCLUDE_DIR on Linux for hardsubx
The FFMPEG_INCLUDE_DIR environment variable was only checked inside the macOS-specific block, so it had no effect on Linux builds. Changes: - Move FFMPEG_INCLUDE_DIR check outside platform-specific blocks so it works on all platforms - Add pkg-config fallback on Linux to automatically find FFmpeg include paths This fixes compilation on systems like Fedora where FFmpeg headers are installed in non-standard locations (e.g., /usr/include/ffmpeg). Fixes #1954 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 3529bb2 commit 303bec8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/rust/build.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,12 @@ fn main() {
8484
{
8585
builder = builder.clang_arg("-DENABLE_HARDSUBX");
8686

87-
// Add FFmpeg include paths for Mac
87+
// Check FFMPEG_INCLUDE_DIR environment variable (works on all platforms)
88+
if let Ok(ffmpeg_include) = env::var("FFMPEG_INCLUDE_DIR") {
89+
builder = builder.clang_arg(format!("-I{}", ffmpeg_include));
90+
}
91+
92+
// Add FFmpeg include paths for Mac (Homebrew)
8893
if cfg!(target_os = "macos") {
8994
// Try common Homebrew paths
9095
if std::path::Path::new("/opt/homebrew/include").exists() {
@@ -110,10 +115,14 @@ fn main() {
110115
}
111116
}
112117
}
118+
}
113119

114-
// Also check environment variable
115-
if let Ok(ffmpeg_include) = env::var("FFMPEG_INCLUDE_DIR") {
116-
builder = builder.clang_arg(format!("-I{}", ffmpeg_include));
120+
// On Linux, try pkg-config to find FFmpeg include paths
121+
if cfg!(target_os = "linux") {
122+
if let Ok(lib) = pkg_config::Config::new().probe("libavcodec") {
123+
for path in lib.include_paths {
124+
builder = builder.clang_arg(format!("-I{}", path.display()));
125+
}
117126
}
118127
}
119128
}

0 commit comments

Comments
 (0)