1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-28 07:55:03 +03:00
wezterm/deps/freetype/build.rs

62 lines
2.0 KiB
Rust
Raw Normal View History

use cmake::Config;
2019-03-23 23:18:55 +03:00
use fs_extra;
use std::env;
2019-03-23 23:18:55 +03:00
use std::path::PathBuf;
2019-03-23 21:14:53 +03:00
fn zlib() {
2019-03-23 23:18:55 +03:00
// The out-of-source build for zlib unfortunately modifies some of
// the sources, leaving the repo with a dirty status. Let's take
// a copy of the sources so that we don't trigger this.
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let src_dir = out_dir.join("zlib-src");
if src_dir.exists() {
fs_extra::remove_items(&vec![&src_dir]).expect("failed to remove zlib-src");
}
std::fs::create_dir(&src_dir).expect("failed to create zlib-src");
fs_extra::copy_items(&vec!["zlib"], &src_dir, &fs_extra::dir::CopyOptions::new())
.expect("failed to copy zlib to zlib-src");
let mut config = Config::new(src_dir.join("zlib"));
2019-03-23 21:14:53 +03:00
let dst = config.profile("Release").build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
2019-03-23 21:53:45 +03:00
if cfg!(unix) {
println!("cargo:rustc-link-lib=static=z");
} else {
println!("cargo:rustc-link-lib=static=zlibstatic");
}
2019-03-23 21:14:53 +03:00
}
fn libpng() {
let mut config = Config::new("libpng");
let dst = config.profile("Release").build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
2019-03-23 21:53:45 +03:00
if cfg!(unix) {
println!("cargo:rustc-link-lib=static=png");
} else {
println!("cargo:rustc-link-lib=static=libpng16_static");
}
}
fn freetype() {
let mut config = Config::new("freetype2");
let dst = config
.define("FT_WITH_PNG", "ON")
2019-03-23 20:51:09 +03:00
.define("CMAKE_DISABLE_FIND_PACKAGE_BZip2", "TRUE")
.profile("Release")
.build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
println!("cargo:rustc-link-lib=static=freetype");
println!("cargo:rustc-link-search=native=/usr/lib");
println!("cargo:include={}/include/freetype2", dst.display());
println!("cargo:lib={}/lib/libfreetype.a", dst.display());
}
fn main() {
2019-03-23 21:14:53 +03:00
zlib();
libpng();
freetype();
let out_dir = env::var("OUT_DIR").unwrap();
println!("cargo:outdir={}", out_dir);
}