-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
69 lines (56 loc) · 2.23 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
use std::{env, path::Path};
fn main() {
if env::var("DOCS_RS").is_ok() {
return;
}
let _ = cxx_build::bridge("src/lib.rs");
let mut cmake = cmake::Config::new("bridge");
cmake.build_target("cxx-juce");
let out_dir = env::var("OUT_DIR").unwrap();
cmake.define("CXX_JUCE_BINDINGS_DIR", format!("{out_dir}/cxxbridge"));
if cfg!(feature = "asio") {
cmake.define("CXX_JUCE_USE_ASIO", "ON");
if let Ok(path) = env::var("CXX_JUCE_ASIO_SDK_DIR") {
if Path::new(&path).join("common").join("iasiodrv.h").exists() {
cmake.define("CXX_JUCE_ASIO_SDK_DIR", path);
} else {
panic!("CXX_JUCE_ASIO_SDK_DIR is set to '{path}' which is not a valid path to the ASIO SDK");
}
} else {
panic!("CXX_JUCE_ASIO_SDK_DIR is not set");
}
} else {
cmake.define("CXX_JUCE_USE_ASIO", "OFF");
}
if cfg!(target_os = "windows") && cmake.get_profile() == "Debug" {
cmake.profile("RelWithDebInfo");
}
let destination = cmake.build();
println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rerun-if-changed=bridge");
println!("cargo:rerun-if-env-changed=CXX_JUCE_ASIO_SDK_DIR");
println!(
"cargo:rustc-link-search=native={}/build/cxx-juce_artefacts/{}",
destination.display(),
cmake.get_profile(),
);
println!("cargo:rustc-link-lib=static=cxx-juce");
if cfg!(target_os = "macos") {
println!("cargo:rustc-link-lib=c++");
println!("cargo:rustc-link-lib=framework=Accelerate");
println!("cargo:rustc-link-lib=framework=AudioToolbox");
println!("cargo:rustc-link-lib=framework=Cocoa");
println!("cargo:rustc-link-lib=framework=CoreAudio");
println!("cargo:rustc-link-lib=framework=CoreFoundation");
println!("cargo:rustc-link-lib=framework=CoreMIDI");
println!("cargo:rustc-link-lib=framework=IOKit");
}
if cfg!(target_os = "windows") {
println!("cargo:rustc-link-lib=dylib=shell32");
println!("cargo:rustc-link-lib=dylib=ole32");
}
if cfg!(target_os = "linux") {
println!("cargo:rustc-link-lib=asound");
println!("cargo:rustc-link-lib=jack");
}
}