Skip to content

Commit ea361ff

Browse files
committed
Export more user-friendly version flags ffmpeg_x_y
avcodec_version_greater_than_* are cumbersome for downstream software, after all.
1 parent c5d1a5f commit ea361ff

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

build.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,35 @@ fn check_features(
498498
}
499499
}
500500
}
501+
502+
let ffmpeg_lavc_versions = [
503+
("ffmpeg_3_0", 57, 24),
504+
("ffmpeg_3_1", 57, 48),
505+
("ffmpeg_3_2", 57, 64),
506+
("ffmpeg_3_3", 57, 89),
507+
("ffmpeg_3_1", 57, 107),
508+
("ffmpeg_4_0", 58, 18),
509+
("ffmpeg_4_1", 58, 35),
510+
("ffmpeg_4_2", 58, 54),
511+
("ffmpeg_4_3", 58, 91),
512+
];
513+
for &(ffmpeg_version_flag, lavc_version_major, lavc_version_minor) in
514+
ffmpeg_lavc_versions.iter()
515+
{
516+
let search_str = format!(
517+
"[avcodec_version_greater_than_{lavc_version_major}_{lavc_version_minor}]",
518+
lavc_version_major = lavc_version_major,
519+
lavc_version_minor = lavc_version_minor - 1
520+
);
521+
let pos = stdout
522+
.find(&search_str)
523+
.expect("Variable not found in output")
524+
+ search_str.len();
525+
if &stdout[pos..pos + 1] == "1" {
526+
println!(r#"cargo:rustc-cfg=feature="{}""#, ffmpeg_version_flag);
527+
println!(r#"cargo:{}=true"#, ffmpeg_version_flag);
528+
}
529+
}
501530
}
502531

503532
fn search_include(include_paths: &Vec<PathBuf>, header: &str) -> String {

0 commit comments

Comments
 (0)