build: use gcc to detect compiler

This commit is contained in:
Tae-il Lim
2023-05-24 21:49:22 +02:00
committed by Till Höppner
parent ae12cdec7c
commit 7ba8f47d16
2 changed files with 4 additions and 8 deletions
+1
View File
@@ -16,6 +16,7 @@ libc = "0.2"
[build-dependencies]
num_cpus = "0.2.11"
gcc = "0.3"
[features]
default = ["avcodec", "avdevice", "avfilter", "avformat", "avresample", "swresample", "swscale"]
+3 -8
View File
@@ -1,4 +1,5 @@
extern crate num_cpus;
extern crate gcc;
use std::env;
use std::fs::{self, File};
@@ -256,15 +257,9 @@ fn check_features(infos: &Vec<(&'static str, Option<&'static str>, &'static str)
"#, includes_code=includes_code, main_code=main_code).expect("Write failed");
let executable = out_dir.join(if cfg!(windows) { "check.exe" } else { "check" });
let compiler =
if cfg!(windows) || env::var("MSYSTEM").unwrap_or("".to_string()).starts_with("MINGW32") {
"gcc"
}
else {
"cc"
};
let mut compiler = gcc::Config::new().get_compiler().to_command();
if !Command::new(compiler).current_dir(&out_dir)
if !compiler.current_dir(&out_dir)
.arg("-I").arg(search().join("include").to_string_lossy().into_owned())
.arg("-o").arg(&executable)
.arg("check.c")