Skip to content

Commit

Permalink
Include libavutil/hwcontext_drm.h only when it exists
Browse files Browse the repository at this point in the history
This header was introduced in FFmpeg 3.4 so doesn't exist in earlier
versions.
  • Loading branch information
zmwangx committed Oct 3, 2020
1 parent 4482b37 commit a62e1e7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,15 @@ fn search_include(include_paths: &[PathBuf], header: &str) -> String {
format!("/usr/include/{}", header)
}

fn maybe_search_include(include_paths: &[PathBuf], header: &str) -> Option<String> {
let path = search_include(include_paths, header);
if fs::metadata(&path).is_ok() {
Some(path)
} else {
None
}
}

fn link_to_libraries(statik: bool) {
let ffmpeg_ty = if statik { "static" } else { "dylib" };
for lib in LIBRARIES {
Expand Down Expand Up @@ -1200,7 +1209,6 @@ fn main() {
.header(search_include(&include_paths, "libavutil/hash.h"))
.header(search_include(&include_paths, "libavutil/hmac.h"))
.header(search_include(&include_paths, "libavutil/hwcontext.h"))
.header(search_include(&include_paths, "libavutil/hwcontext_drm.h"))
.header(search_include(&include_paths, "libavutil/imgutils.h"))
.header(search_include(&include_paths, "libavutil/lfg.h"))
.header(search_include(&include_paths, "libavutil/log.h"))
Expand Down Expand Up @@ -1243,6 +1251,12 @@ fn main() {
builder = builder.header(search_include(&include_paths, "libswscale/swscale.h"));
}

if let Some(hwcontext_drm_header) =
maybe_search_include(&include_paths, "libavutil/hwcontext_drm.h")
{
builder = builder.header(hwcontext_drm_header);
}

// Finish the builder and generate the bindings.
let bindings = builder
.generate()
Expand Down

0 comments on commit a62e1e7

Please sign in to comment.