-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
108 lines (95 loc) · 3.39 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
106
107
108
#![deny(warnings, clippy::all)]
use std::{env, fs};
fn main() {
// Setup pkg-config if cross-compiling
let host_triple = env::var("HOST").unwrap();
let target_triple = env::var("TARGET").unwrap();
if host_triple != target_triple {
// NOTE: only setup for aarch64-unknown-linux-gnu atm
if target_triple.as_str() == "aarch64-unknown-linux-gnu" {
env::set_var(
"PKG_CONFIG_PATH_aarch64-unknown-linux-gnu",
"/usr/lib/aarch64-linux-gnu/pkgconfig",
)
}
}
let mut config = autotools::Config::new("vendor/babeltrace");
config.reconf("-vif");
config.enable("built-in-plugins", None);
config.enable("silent-rules", None);
config.disable("debug-info", None);
config.disable("man-pages", None);
config.disable("glibtest", None);
config.disable("doxygen-doc", None);
config.disable("doxygen-html", None);
config.disable("maintainer-mode", None);
config.disable("dependency-tracking", None);
config.disable_shared();
config.enable_static();
config.fast_build(true);
if cfg!(debug_assertions) {
config.enable("asan", None);
config.env("BABELTRACE_DEV_MODE", "1");
config.env("BABELTRACE_DEBUG_MODE", "1");
config.env("BABELTRACE_MINIMAL_LOG_LEVEL", "INFO");
} else {
config.disable("asan", None);
}
let babeltrace_path = config.build();
let glib2 = pkg_config::Config::new()
.atleast_version("2.0.0")
.statik(true)
.probe("glib-2.0")
.expect("Failed to find glib-2.0 pkg-config");
let gmod2 = pkg_config::Config::new()
.atleast_version("2.0.0")
.statik(true)
.probe("gmodule-2.0")
.expect("Failed to find gmodule-2.0 pkg-config");
let pcre = pkg_config::Config::new()
.statik(true)
.probe("libpcre")
.expect("Failed to find libpcre pkg-config");
if cfg!(feature = "test") {
println!("cargo:rustc-link-arg=-Wl,--allow-multiple-definition");
}
println!(
"cargo:rustc-link-search=native={}/lib",
babeltrace_path.display()
);
println!("cargo:rustc-link-lib=static=babeltrace2");
println!("cargo:rustc-link-lib=static=babeltrace2-ctf-writer");
let plugin_path = babeltrace_path.join("lib/babeltrace2/plugins");
fs::copy(
plugin_path.join("babeltrace-plugin-utils.a"),
plugin_path.join("libbabeltrace-plugin-utils.a"),
)
.unwrap();
fs::copy(
plugin_path.join("babeltrace-plugin-ctf.a"),
plugin_path.join("libbabeltrace-plugin-ctf.a"),
)
.unwrap();
println!(
"cargo:rustc-link-search=native={}/lib/babeltrace2/plugins/",
babeltrace_path.display()
);
println!("cargo:rustc-link-lib=static=babeltrace-plugin-utils");
println!("cargo:rustc-link-lib=static=babeltrace-plugin-ctf");
println!(
"cargo:rustc-link-search=native={}",
gmod2.link_paths[0].display()
);
println!("cargo:rustc-link-lib=static={}", gmod2.libs[0]);
println!(
"cargo:rustc-link-search=native={}",
glib2.link_paths[0].display()
);
println!("cargo:rustc-link-lib=static={}", glib2.libs[0]);
println!(
"cargo:rustc-link-search=native={}",
pcre.link_paths[0].display()
);
println!("cargo:rustc-link-lib=static={}", pcre.libs[0]);
println!("cargo:rustc-link-lib=dylib=c");
}