-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.rs
106 lines (97 loc) · 3.08 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
fn main() {
std::env::set_var("CC_LOG", "1");
std::env::set_current_dir("../..").unwrap();
build_lua_seri();
build_lpeglabel();
cfg!(windows).then(|| build_setfilemode());
cfg!(not(feature = "no_format")).then(|| build_emmyluacodestyle());
}
fn build_lua_seri() {
cc::Build::new()
.include("3rd/lua-seri")
.include("3rd/lua")
.files(
std::fs::read_dir("3rd/lua-seri")
.unwrap()
.filter_map(|entry| {
let entry = entry.unwrap();
let path = entry.path();
if path.extension()?.to_str()? == "c" {
Some(path)
} else {
None
}
}),
)
.compile("lua-seri");
}
fn build_lpeglabel() {
cc::Build::new()
.include("3rd/lpeglabel")
.include("3rd/lua")
.files(
std::fs::read_dir("3rd/lpeglabel")
.unwrap()
.filter_map(|entry| {
let entry = entry.unwrap();
let path = entry.path();
if path.extension()?.to_str()? == "c" {
Some(path)
} else {
None
}
}),
)
.compile("lpeglabel");
}
fn build_setfilemode() {
cc::Build::new()
.include("3rd/setfilemode")
.files(
std::fs::read_dir("3rd/setfilemode")
.unwrap()
.filter_map(|entry| {
let entry = entry.unwrap();
let path = entry.path();
if path.extension()?.to_str()? == "c" {
Some(path)
} else {
None
}
}),
)
.compile("setfilemode");
}
fn build_emmyluacodestyle() {
let mut builder = cc::Build::new();
builder.cpp(true);
builder
.include("3rd/EmmyLuaCodeStyle/Util/include")
.include("3rd/EmmyLuaCodeStyle/CodeFormatCore/include")
.include("3rd/EmmyLuaCodeStyle/LuaParser/include")
.include("3rd/EmmyLuaCodeStyle/3rd/wildcards/include")
.include("3rd/lua");
let file_patterns = vec![
"3rd/EmmyLuaCodeStyle/CodeFormatLib/src/*.cpp",
"3rd/EmmyLuaCodeStyle/LuaParser/src/**/*.cpp",
"3rd/EmmyLuaCodeStyle/Util/src/StringUtil.cpp",
"3rd/EmmyLuaCodeStyle/Util/src/Utf8.cpp",
"3rd/EmmyLuaCodeStyle/Util/src/SymSpell/*.cpp",
"3rd/EmmyLuaCodeStyle/Util/src/InfoTree/*.cpp",
"3rd/EmmyLuaCodeStyle/CodeFormatCore/src/**/*.cpp",
];
for pattern in file_patterns {
if pattern.contains("*") {
builder.files(glob::glob(pattern).unwrap().filter_map(|path| path.ok()));
} else {
builder.file(pattern);
}
}
if cfg!(windows) {
builder.flag("/utf-8");
builder.flag("/std:c++17");
} else {
builder.flag("-std=c++17");
}
builder.compile("EmmyLuaCodeStyle");
}