Add macOS package manager search paths for pkg-config (#8)
This commit is contained in:
parent
0d11595259
commit
fa2b8d13ad
@ -16,7 +16,7 @@ fn main() {
|
||||
println!("\tend: {}", chapter.end());
|
||||
|
||||
for (k, v) in chapter.metadata().iter() {
|
||||
println!("\t{}: {}", k, v);
|
||||
println!("\t{k}: {v}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,11 +49,11 @@ fn main() {
|
||||
println!("\tstart: {}", chapter.start());
|
||||
println!("\tend: {}", chapter.end());
|
||||
for (k, v) in chapter.metadata().iter() {
|
||||
println!("\t{}: {}", k, v);
|
||||
println!("\t{k}: {v}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Err(error) => println!("error: {}", error),
|
||||
Err(error) => println!("error: {error}"),
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ fn main() -> Result<(), ffmpeg::Error> {
|
||||
}
|
||||
|
||||
fn save_file(frame: &Video, index: usize) -> std::result::Result<(), std::io::Error> {
|
||||
let mut file = File::create(format!("frame{}.ppm", index))?;
|
||||
let mut file = File::create(format!("frame{index}.ppm"))?;
|
||||
file.write_all(format!("P6\n{} {}\n255\n", frame.width(), frame.height()).as_bytes())?;
|
||||
file.write_all(frame.data(0))?;
|
||||
Ok(())
|
||||
|
@ -8,7 +8,7 @@ fn main() -> Result<(), ffmpeg::Error> {
|
||||
match ffmpeg::format::input(&env::args().nth(1).expect("missing file")) {
|
||||
Ok(context) => {
|
||||
for (k, v) in context.metadata().iter() {
|
||||
println!("{}: {}", k, v);
|
||||
println!("{k}: {v}");
|
||||
}
|
||||
|
||||
if let Some(stream) = context.streams().best(ffmpeg::media::Type::Video) {
|
||||
@ -83,7 +83,7 @@ fn main() -> Result<(), ffmpeg::Error> {
|
||||
}
|
||||
}
|
||||
|
||||
Err(error) => println!("error: {}", error),
|
||||
Err(error) => println!("error: {error}"),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ fn main() {
|
||||
)
|
||||
.expect("invalid x264 options string");
|
||||
|
||||
eprintln!("x264 options: {:?}", x264_opts);
|
||||
eprintln!("x264 options: {x264_opts:?}");
|
||||
|
||||
ffmpeg::init().unwrap();
|
||||
log::set_level(log::Level::Info);
|
||||
|
@ -399,6 +399,27 @@ fn try_vcpkg(statik: bool) -> Option<Vec<PathBuf>> {
|
||||
.ok()
|
||||
}
|
||||
|
||||
// add well known package manager lib paths us as homebrew (or macports)
|
||||
#[cfg(target_os = "macos")]
|
||||
fn add_pkg_config_path() {
|
||||
use std::path::Path;
|
||||
|
||||
let pc_path = pkg_config::get_variable("pkg-config", "pc_path").unwrap();
|
||||
// append M1 homebrew pkgconfig path
|
||||
let brew_pkgconfig = cfg!(target_arch = "aarch64")
|
||||
.then_some("/opt/homebrew/lib/pkgconfig/")
|
||||
.unwrap_or("/usr/local/homebrew/lib/pkgconfig/"); // x86 as fallback
|
||||
if !pc_path.to_lowercase().contains(brew_pkgconfig) && Path::new(brew_pkgconfig).is_dir() {
|
||||
let new_pc_path = env::var("PKG_CONFIG_PATH")
|
||||
// PKG_CONFIG_PATH="/our/path:$PKG_CONFIG_PATH"
|
||||
.map(|p| format!("{brew_pkgconfig}:{p}"))
|
||||
.unwrap_or_else(|_| brew_pkgconfig.to_string());
|
||||
env::set_var("PKG_CONFIG_PATH", new_pc_path);
|
||||
}
|
||||
}
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn add_pkg_config_path() {}
|
||||
|
||||
fn check_features(
|
||||
include_paths: Vec<PathBuf>,
|
||||
infos: &[(&'static str, Option<&'static str>, &'static str)],
|
||||
@ -708,6 +729,7 @@ fn main() {
|
||||
}
|
||||
// Fallback to pkg-config
|
||||
else {
|
||||
add_pkg_config_path();
|
||||
pkg_config::Config::new()
|
||||
.statik(statik)
|
||||
.probe("libavutil")
|
||||
|
Loading…
x
Reference in New Issue
Block a user