2019-03-23 19:28:40 +03:00
|
|
|
use cmake::Config;
|
|
|
|
use std::env;
|
2019-05-29 21:12:32 +03:00
|
|
|
use std::path::Path;
|
2019-03-23 19:28:40 +03:00
|
|
|
|
|
|
|
fn harfbuzz() {
|
2019-10-29 18:17:10 +03:00
|
|
|
if !Path::new("harfbuzz/.git").exists() {
|
|
|
|
git_submodule_update();
|
|
|
|
}
|
|
|
|
|
2019-03-23 19:28:40 +03:00
|
|
|
let mut config = Config::new("harfbuzz");
|
|
|
|
for (key, value) in std::env::vars() {
|
|
|
|
println!("{}: {}", key, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
let ft_outdir = std::env::var("DEP_FREETYPE_OUTDIR").unwrap();
|
|
|
|
|
|
|
|
let dst = config
|
|
|
|
.env("CMAKE_PREFIX_PATH", &ft_outdir)
|
|
|
|
.cxxflag("-DHB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR")
|
|
|
|
.define("HB_HAVE_FREETYPE", "ON")
|
|
|
|
.define("HB_BUILD_TESTS", "OFF")
|
|
|
|
.define(
|
|
|
|
"FREETYPE_LIBRARY",
|
|
|
|
std::env::var("DEP_FREETYPE_LIB").unwrap(),
|
|
|
|
)
|
|
|
|
.define(
|
2019-03-23 20:51:09 +03:00
|
|
|
"FREETYPE_INCLUDE_DIR_ft2build",
|
|
|
|
std::env::var("DEP_FREETYPE_INCLUDE").unwrap(),
|
|
|
|
)
|
|
|
|
.define(
|
|
|
|
"FREETYPE_INCLUDE_DIR_freetype2",
|
2019-03-23 19:28:40 +03:00
|
|
|
std::env::var("DEP_FREETYPE_INCLUDE").unwrap(),
|
|
|
|
)
|
|
|
|
.profile("Release")
|
|
|
|
.build();
|
2019-05-29 21:12:32 +03:00
|
|
|
emit_libdirs(Path::new(&ft_outdir));
|
|
|
|
emit_libdirs(&dst);
|
|
|
|
emit_libdirs(Path::new("/usr"));
|
2019-03-23 19:28:40 +03:00
|
|
|
println!("cargo:rustc-link-lib=static=harfbuzz");
|
2019-05-29 21:12:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fn emit_libdirs(p: &Path) {
|
|
|
|
for d in &["lib64", "lib"] {
|
|
|
|
let libdir = p.join(d);
|
|
|
|
if libdir.is_dir() {
|
|
|
|
println!("cargo:rustc-link-search=native={}", libdir.display());
|
|
|
|
}
|
|
|
|
}
|
2019-03-23 19:28:40 +03:00
|
|
|
}
|
|
|
|
|
2019-10-29 18:17:10 +03:00
|
|
|
fn git_submodule_update() {
|
|
|
|
let _ = std::process::Command::new("git")
|
|
|
|
.args(&["submodule", "update", "--init"])
|
|
|
|
.status();
|
|
|
|
}
|
|
|
|
|
2019-03-23 19:28:40 +03:00
|
|
|
fn main() {
|
|
|
|
harfbuzz();
|
|
|
|
let out_dir = env::var("OUT_DIR").unwrap();
|
|
|
|
println!("cargo:outdir={}", out_dir);
|
|
|
|
}
|