Function libpng_src::compile_lib
source · pub fn compile_lib(
target_str: &str,
working_dir: &Path
) -> Result<PathBuf, Box<dyn Error>>Expand description
Statically compiles libpng library and returns the path to the compiled artifact.
Should be used when include headers are not needed.
Would create working directory if missing, would remove its previous content if not empty.
§Usage Example
ⓘ
/// 'build.rs' of a consumer crate
use std::{env::var, fs::copy, path::PathBuf};
use libpng_src;
fn main() {
let target = var("TARGET").unwrap();
let out_dir = var("OUT_DIR").map(PathBuf::from).unwrap();
let lib_path = libpng_src::compile_lib(&target, &out_dir).unwrap();
println!("cargo:rustc-link-search=native={}", lib_path.parent().unwrap().to_string_lossy());
#[cfg(not(target_os = "windows"))]
println!("cargo:rustc-link-lib=static=png16");
#[cfg(target_os = "windows")]
println!("cargo:rustc-link-lib=static=png16_static");
}