-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.rs
57 lines (53 loc) · 1.84 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
#[cfg(not(feature = "build-flac"))]
fn main() {
println!("cargo:rustc-link-lib=FLAC");
}
#[cfg(feature = "build-flac")]
fn main() {
let mut flac_config = cmake::Config::new("flac");
flac_config
.define("BUILD_CXXLIBS", "OFF")
.define("BUILD_PROGRAMS", "OFF")
.define("BUILD_EXAMPLES", "OFF")
.define("BUILD_TESTING", "OFF")
.define("BUILD_DOCS", "OFF")
.define("INSTALL_MANPAGES", "OFF")
.define("INSTALL_PKGCONFIG_MODULES", "OFF")
.define("INSTALL_CMAKE_CONFIG_MODULE", "OFF");
if cfg!(feature = "build-ogg") {
let ogg_path = cmake::Config::new("ogg")
.define("BUILD_SHARED_LIBS", "OFF")
.define("INSTALL_DOCS", "OFF")
.define("INSTALL_PKG_CONFIG_MODULE", "OFF")
.define("INSTALL_CMAKE_PACKAGE_MODULE", "OFF")
.build();
println!("cargo:rustc-link-search=native={}/lib", ogg_path.display());
// This path is used on 64 bit Fedora 33:
println!(
"cargo:rustc-link-search=native={}/lib64",
ogg_path.display()
);
println!("cargo:rustc-link-lib=static=ogg");
flac_config.define("CMAKE_PREFIX_PATH", ogg_path);
flac_config.define("WITH_OGG", "ON");
} else {
flac_config.define("WITH_OGG", "OFF");
};
let flac_path = flac_config.build_target("FLAC").build();
if std::env::var("TARGET")
.expect("TARGET is defined by rustc")
.contains("msvc")
{
println!(
"cargo:rustc-link-search=native={}/build/src/libFLAC/{}",
flac_path.display(),
flac_config.get_profile()
);
} else {
println!(
"cargo:rustc-link-search=native={}/build/src/libFLAC",
flac_path.display()
);
}
println!("cargo:rustc-link-lib=static=FLAC");
}