Skip to content

Commit 5362c9e

Browse files
authored
Export all lib features (shssoichiro#87)
* export all lib features * fix versions for sws/swr/avfi
1 parent 6a541ca commit 5362c9e

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

ffmpeg-sys-the-third/build.rs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,37 @@ struct Library {
2222
optional: bool,
2323
features: &'static [AVFeature],
2424
headers: &'static [AVHeader],
25+
min_major_version: u64,
2526
}
2627

2728
impl Library {
2829
const fn required(
2930
name: &'static str,
3031
features: &'static [AVFeature],
3132
headers: &'static [AVHeader],
33+
min_version: u64,
3234
) -> Self {
3335
Self {
3436
name,
3537
optional: false,
3638
features,
3739
headers,
40+
min_major_version: min_version,
3841
}
3942
}
4043

4144
const fn optional(
4245
name: &'static str,
4346
features: &'static [AVFeature],
4447
headers: &'static [AVHeader],
48+
min_version: u64,
4549
) -> Self {
4650
Self {
4751
name,
4852
optional: true,
4953
features,
5054
headers,
55+
min_major_version: min_version,
5156
}
5257
}
5358

@@ -61,14 +66,14 @@ impl Library {
6166
}
6267

6368
static LIBRARIES: &[Library] = &[
64-
Library::required("avutil", AVUTIL_FEATURES, AVUTIL_HEADERS),
65-
Library::optional("avcodec", AVCODEC_FEATURES, AVCODEC_HEADERS),
66-
Library::optional("avformat", AVFORMAT_FEATURES, AVFORMAT_HEADERS),
67-
Library::optional("avdevice", AVDEVICE_FEATURES, AVDEVICE_HEADERS),
68-
Library::optional("avfilter", AVFILTER_FEATURES, AVFILTER_HEADERS),
69-
Library::optional("swscale", SWSCALE_FEATURES, SWSCALE_HEADERS),
70-
Library::optional("swresample", SWRESAMPLE_FEATURES, SWRESAMPLE_HEADERS),
71-
Library::optional("postproc", POSTPROC_FEATURES, POSTPROC_HEADERS),
69+
Library::required("avutil", AVUTIL_FEATURES, AVUTIL_HEADERS, 50),
70+
Library::optional("avcodec", AVCODEC_FEATURES, AVCODEC_HEADERS, 50),
71+
Library::optional("avformat", AVFORMAT_FEATURES, AVFORMAT_HEADERS, 50),
72+
Library::optional("avdevice", AVDEVICE_FEATURES, AVDEVICE_HEADERS, 50),
73+
Library::optional("avfilter", AVFILTER_FEATURES, AVFILTER_HEADERS, 0),
74+
Library::optional("swscale", SWSCALE_FEATURES, SWSCALE_HEADERS, 0),
75+
Library::optional("swresample", SWRESAMPLE_FEATURES, SWRESAMPLE_HEADERS, 0),
76+
Library::optional("postproc", POSTPROC_FEATURES, POSTPROC_HEADERS, 50),
7277
];
7378

7479
#[derive(Debug)]
@@ -769,22 +774,22 @@ fn check_features(include_paths: &[PathBuf]) {
769774
}
770775
}
771776

772-
let version_check_info = [("avcodec", 57, 62, 0, 101)];
773-
for &(lib, begin_version_major, end_version_major, begin_version_minor, end_version_minor) in
774-
&version_check_info
775-
{
776-
let libversion = *versions
777-
.get(lib)
778-
.expect("Unable to find the version for lib{lib}");
779-
780-
for version_major in begin_version_major..end_version_major {
781-
for version_minor in begin_version_minor..end_version_minor {
782-
if libversion >= (version_major, version_minor) {
777+
for lib in enabled_libraries() {
778+
let ver = if let Some(v) = versions.get(&lib.name) {
779+
v
780+
} else {
781+
continue;
782+
};
783+
for major in lib.min_major_version..=(*ver).0 {
784+
for minor in 0..=135 {
785+
if *ver >= (major, minor) {
783786
println!(
784-
r#"cargo:rustc-cfg=feature="{lib}_version_greater_than_{version_major}_{version_minor}""#
787+
r#"cargo:rustc-cfg=feature="{}_version_greater_than_{major}_{minor}""#,
788+
lib.name,
785789
);
786790
println!(
787-
r#"cargo:{lib}_version_greater_than_{version_major}_{version_minor}=true"#
791+
r#"cargo:{}_version_greater_than_{major}_{minor}=true"#,
792+
lib.name,
788793
);
789794
}
790795
}

0 commit comments

Comments
 (0)