@@ -22,32 +22,37 @@ struct Library {
22
22
optional : bool ,
23
23
features : & ' static [ AVFeature ] ,
24
24
headers : & ' static [ AVHeader ] ,
25
+ min_major_version : u64 ,
25
26
}
26
27
27
28
impl Library {
28
29
const fn required (
29
30
name : & ' static str ,
30
31
features : & ' static [ AVFeature ] ,
31
32
headers : & ' static [ AVHeader ] ,
33
+ min_version : u64 ,
32
34
) -> Self {
33
35
Self {
34
36
name,
35
37
optional : false ,
36
38
features,
37
39
headers,
40
+ min_major_version : min_version,
38
41
}
39
42
}
40
43
41
44
const fn optional (
42
45
name : & ' static str ,
43
46
features : & ' static [ AVFeature ] ,
44
47
headers : & ' static [ AVHeader ] ,
48
+ min_version : u64 ,
45
49
) -> Self {
46
50
Self {
47
51
name,
48
52
optional : true ,
49
53
features,
50
54
headers,
55
+ min_major_version : min_version,
51
56
}
52
57
}
53
58
@@ -61,14 +66,14 @@ impl Library {
61
66
}
62
67
63
68
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 ) ,
72
77
] ;
73
78
74
79
#[ derive( Debug ) ]
@@ -769,22 +774,22 @@ fn check_features(include_paths: &[PathBuf]) {
769
774
}
770
775
}
771
776
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) {
783
786
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,
785
789
) ;
786
790
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,
788
793
) ;
789
794
}
790
795
}
0 commit comments