2019-03-23 19:28:40 +03:00
|
|
|
use std::env;
|
2019-10-29 18:43:19 +03:00
|
|
|
use std::path::{Path, PathBuf};
|
2019-03-23 19:28:40 +03:00
|
|
|
|
|
|
|
fn harfbuzz() {
|
2019-10-29 18:43:19 +03:00
|
|
|
use std::fs;
|
|
|
|
|
2019-10-29 18:17:10 +03:00
|
|
|
if !Path::new("harfbuzz/.git").exists() {
|
|
|
|
git_submodule_update();
|
|
|
|
}
|
|
|
|
|
2019-10-29 18:43:19 +03:00
|
|
|
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
|
|
|
|
|
|
let mut cfg = cc::Build::new();
|
|
|
|
cfg.warnings(false);
|
2020-11-24 01:33:47 +03:00
|
|
|
cfg.cpp(true);
|
2019-10-29 18:43:19 +03:00
|
|
|
cfg.flag_if_supported("-fno-rtti");
|
|
|
|
cfg.flag_if_supported("-fno-exceptions");
|
|
|
|
cfg.flag_if_supported("-fno-threadsafe-statics");
|
|
|
|
cfg.flag_if_supported("-std=c++11");
|
2020-01-27 03:14:00 +03:00
|
|
|
cfg.flag_if_supported("-fno-stack-check");
|
2019-10-29 18:43:19 +03:00
|
|
|
|
|
|
|
let build_dir = out_dir.join("harfbuzz-build");
|
|
|
|
fs::create_dir_all(&build_dir).unwrap();
|
|
|
|
cfg.out_dir(&build_dir);
|
|
|
|
|
|
|
|
let target = env::var("TARGET").unwrap();
|
|
|
|
|
|
|
|
for f in [
|
|
|
|
"hb-aat-layout.cc",
|
|
|
|
"hb-aat-map.cc",
|
|
|
|
"hb-blob.cc",
|
|
|
|
"hb-buffer-serialize.cc",
|
|
|
|
"hb-buffer.cc",
|
|
|
|
"hb-common.cc",
|
|
|
|
"hb-face.cc",
|
|
|
|
"hb-fallback-shape.cc",
|
|
|
|
"hb-font.cc",
|
|
|
|
"hb-ft.cc",
|
|
|
|
"hb-map.cc",
|
2020-11-21 19:50:24 +03:00
|
|
|
"hb-number.cc",
|
2019-10-29 18:43:19 +03:00
|
|
|
"hb-ot-cff1-table.cc",
|
|
|
|
"hb-ot-cff2-table.cc",
|
|
|
|
"hb-ot-color.cc",
|
|
|
|
"hb-ot-face.cc",
|
|
|
|
"hb-ot-font.cc",
|
|
|
|
"hb-ot-layout.cc",
|
|
|
|
"hb-ot-map.cc",
|
|
|
|
"hb-ot-math.cc",
|
2020-11-21 19:50:24 +03:00
|
|
|
"hb-ot-metrics.cc",
|
2019-10-29 18:43:19 +03:00
|
|
|
"hb-ot-name.cc",
|
|
|
|
"hb-ot-shape-complex-arabic.cc",
|
|
|
|
"hb-ot-shape-complex-default.cc",
|
|
|
|
"hb-ot-shape-complex-hangul.cc",
|
|
|
|
"hb-ot-shape-complex-hebrew.cc",
|
|
|
|
"hb-ot-shape-complex-indic-table.cc",
|
|
|
|
"hb-ot-shape-complex-indic.cc",
|
|
|
|
"hb-ot-shape-complex-khmer.cc",
|
|
|
|
"hb-ot-shape-complex-myanmar.cc",
|
|
|
|
"hb-ot-shape-complex-thai.cc",
|
|
|
|
"hb-ot-shape-complex-use-table.cc",
|
|
|
|
"hb-ot-shape-complex-use.cc",
|
|
|
|
"hb-ot-shape-complex-vowel-constraints.cc",
|
|
|
|
"hb-ot-shape-fallback.cc",
|
|
|
|
"hb-ot-shape-normalize.cc",
|
|
|
|
"hb-ot-shape.cc",
|
|
|
|
"hb-ot-tag.cc",
|
|
|
|
"hb-ot-var.cc",
|
|
|
|
"hb-set.cc",
|
|
|
|
"hb-shape-plan.cc",
|
|
|
|
"hb-shape.cc",
|
|
|
|
"hb-shaper.cc",
|
|
|
|
"hb-static.cc",
|
2020-11-21 19:50:24 +03:00
|
|
|
"hb-ucd.cc",
|
2019-10-29 18:43:19 +03:00
|
|
|
"hb-unicode.cc",
|
|
|
|
]
|
|
|
|
.iter()
|
|
|
|
{
|
|
|
|
cfg.file(format!("harfbuzz/src/{}", f));
|
2019-03-23 19:28:40 +03:00
|
|
|
}
|
|
|
|
|
2020-11-21 19:50:24 +03:00
|
|
|
cfg.define("HB_NO_MT", None);
|
2019-10-29 18:43:19 +03:00
|
|
|
cfg.define("HAVE_FALLBACK", None);
|
|
|
|
cfg.define("HAVE_UCDN", None);
|
|
|
|
cfg.include("harfbuzz/src/hb-ucdn");
|
|
|
|
|
|
|
|
if !target.contains("windows") {
|
|
|
|
cfg.define("HAVE_UNISTD_H", None);
|
|
|
|
cfg.define("HAVE_SYS_MMAN_H", None);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We know that these are present in our vendored freetype
|
|
|
|
cfg.define("HAVE_FREETYPE", Some("1"));
|
2020-08-29 20:03:07 +03:00
|
|
|
|
2019-10-29 18:43:19 +03:00
|
|
|
cfg.define("HAVE_FT_Get_Var_Blend_Coordinates", Some("1"));
|
|
|
|
cfg.define("HAVE_FT_Set_Var_Blend_Coordinates", Some("1"));
|
|
|
|
cfg.define("HAVE_FT_Done_MM_Var", Some("1"));
|
|
|
|
|
|
|
|
// Import the include dirs exported from deps/freetype/build.rs
|
2021-03-25 20:05:34 +03:00
|
|
|
for inc in std::env::var("DEP_FREETYPE_INCLUDE").unwrap().split(';') {
|
2019-10-29 18:43:19 +03:00
|
|
|
cfg.include(inc);
|
|
|
|
}
|
|
|
|
|
2020-08-29 20:03:07 +03:00
|
|
|
println!(
|
|
|
|
"cargo:rustc-link-search={}",
|
|
|
|
std::env::var("DEP_FREETYPE_LIB").unwrap()
|
|
|
|
);
|
|
|
|
println!("cargo:rustc-link-lib=freetype");
|
|
|
|
println!("cargo:rustc-link-lib=png");
|
|
|
|
println!("cargo:rustc-link-lib=z");
|
|
|
|
|
2019-10-29 18:43:19 +03:00
|
|
|
cfg.compile("harfbuzz");
|
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);
|
2020-01-27 03:14:00 +03:00
|
|
|
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.9");
|
2019-03-23 19:28:40 +03:00
|
|
|
}
|