forked from servo/fontsan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
80 lines (69 loc) · 1.98 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#![deny(warnings)]
use std::path::{Path, PathBuf};
const BROTLI_INCLUDE_DIR: &str = "src/deps/brotli/c/include";
const LZ4_INCLUDE_DIR: &str = "src/deps/lz4/lib";
const OTS_INCLUDE_DIR: &str = "src/deps/ots/include";
const WOFF2_INCLUDE_DIR: &str = "src/deps/woff2/include";
const ZLIB_INCLUDE_DIR: &str = "src/fake-zlib";
fn build_lz4() {
cc::Build::new()
.file("src/deps/lz4/lib/lz4.c")
.compile("lz4");
}
fn build_ots() {
let ots_sources = glob::glob("src/deps/ots/src/*.cc")
.expect("Invalid glob pattern")
.collect::<Result<Vec<PathBuf>, _>>()
.expect("vendored ots sources not found");
cc::Build::new()
.cpp(true)
.files(ots_sources)
.include(OTS_INCLUDE_DIR)
.include(LZ4_INCLUDE_DIR)
.include(WOFF2_INCLUDE_DIR)
.include(ZLIB_INCLUDE_DIR)
.std("c++11")
.compile("ots");
}
fn build_brotli() {
let brotli_sources = glob::glob("src/deps/brotli/c/**/*.c")
.expect("Invalid glob pattern")
.collect::<Result<Vec<PathBuf>, _>>()
.expect("vendored brotli sources not found");
cc::Build::new()
.files(brotli_sources)
.include(BROTLI_INCLUDE_DIR)
.compile("brotli");
}
fn build_woff2() {
let woff2_dir = Path::new("src/deps/woff2/src");
let file_names = [
"table_tags.cc",
"variable_length.cc",
"woff2_common.cc",
"woff2_dec.cc",
"woff2_out.cc",
];
let woff2_sources = file_names.iter().map(|name| woff2_dir.join(name));
cc::Build::new()
.files(woff2_sources)
.include(WOFF2_INCLUDE_DIR)
.include(BROTLI_INCLUDE_DIR)
.std("c++11")
.warnings(false)
.compile("woff2");
}
fn build_ots_glue() {
cc::Build::new()
.file("src/ots_glue.cc")
.include(OTS_INCLUDE_DIR)
.std("c++11")
.compile("ots_glue");
}
fn main() {
build_lz4();
build_ots();
build_brotli();
build_woff2();
build_ots_glue();
}