Add rustc-check-cfg
for ffmpeg_x_y
features (#70)
* sys: Add check-cfg statements * Add rustc-check-cfg in main crate The sys build script sets an environment variable for every feature that needs to be added to rustc-check-cfg.
This commit is contained in:
parent
820afa79bb
commit
3239649dbb
9
build.rs
9
build.rs
@ -2,7 +2,14 @@ use std::env;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
for (name, _value) in env::vars() {
|
for (name, _value) in env::vars() {
|
||||||
if name.starts_with("DEP_FFMPEG_") {
|
println!("{name}");
|
||||||
|
|
||||||
|
if name.starts_with("DEP_FFMPEG_CHECK_") {
|
||||||
|
println!(
|
||||||
|
r#"cargo:rustc-check-cfg=cfg(feature, values("{}"))"#,
|
||||||
|
name["DEP_FFMPEG_CHECK_".len()..name.len()].to_lowercase()
|
||||||
|
);
|
||||||
|
} else if name.starts_with("DEP_FFMPEG_") {
|
||||||
println!(
|
println!(
|
||||||
r#"cargo:rustc-cfg=feature="{}""#,
|
r#"cargo:rustc-cfg=feature="{}""#,
|
||||||
name["DEP_FFMPEG_".len()..name.len()].to_lowercase()
|
name["DEP_FFMPEG_".len()..name.len()].to_lowercase()
|
||||||
|
@ -851,6 +851,10 @@ fn check_features(include_paths: &[PathBuf]) {
|
|||||||
.expect("Unable to find the version for lib{lib}");
|
.expect("Unable to find the version for lib{lib}");
|
||||||
|
|
||||||
for &(ffmpeg_version_flag, lavc_version_major, lavc_version_minor) in &ffmpeg_lavc_versions {
|
for &(ffmpeg_version_flag, lavc_version_major, lavc_version_minor) in &ffmpeg_lavc_versions {
|
||||||
|
// Every possible feature needs an unconditional check-cfg to prevent warnings
|
||||||
|
println!(r#"cargo:rustc-check-cfg=cfg(feature, values("{}"))"#, ffmpeg_version_flag);
|
||||||
|
println!(r#"cargo:check_{}=true"#, ffmpeg_version_flag);
|
||||||
|
|
||||||
if lavc_version >= (lavc_version_major, lavc_version_minor) {
|
if lavc_version >= (lavc_version_major, lavc_version_minor) {
|
||||||
println!(r#"cargo:rustc-cfg=feature="{}""#, ffmpeg_version_flag);
|
println!(r#"cargo:rustc-cfg=feature="{}""#, ffmpeg_version_flag);
|
||||||
println!(r#"cargo:{}=true"#, ffmpeg_version_flag);
|
println!(r#"cargo:{}=true"#, ffmpeg_version_flag);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user