| 1 |
use std::path::PathBuf; |
| 2 |
use std::fs; |
| 3 |
|
| 4 |
fn main() { |
| 5 |
// Directory for the fontconfig build |
| 6 |
|
| 7 |
let cargo_manifest_dir = |
| 8 |
std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"); |
| 9 |
|
| 10 |
let mut build_dir = PathBuf::from(cargo_manifest_dir); |
| 11 |
build_dir = build_dir.join("../../build"); |
| 12 |
build_dir = fs::canonicalize(build_dir).expect("Failed to canonicalize path."); |
| 13 |
|
| 14 |
let fontconfig_lib = build_dir.join("libfontconfig.a"); |
| 15 |
|
| 16 |
if !fontconfig_lib.exists() { |
| 17 |
panic!("{:?} not found, build FontConfig with -Dfontations=enabled into dir build/ first.", fontconfig_lib); |
| 18 |
} |
| 19 |
|
| 20 |
// Tell cargo to look for fontconfig in the build directory |
| 21 |
println!("cargo:rustc-link-search=native={}", build_dir.display()); |
| 22 |
println!("cargo:rustc-link-lib=static=fontconfig"); |
| 23 |
|
| 24 |
// FreeType and Expat from the system. |
| 25 |
println!("cargo:rustc-link-lib=dylib=freetype"); |
| 26 |
println!("cargo:rustc-link-lib=dylib=expat"); |
| 27 |
|
| 28 |
// Rerun this build script if the fontconfig source code changes |
| 29 |
println!("cargo:rerun-if-changed=src"); |
| 30 |
} |