This repository has been archived by the owner on May 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.rs
42 lines (35 loc) · 1.41 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
use std::env;
#[cfg(target_os = "linux")]
fn find_default_java_home() -> String {
// TODO: How is this with non-Debian distributions?
String::from("/usr/lib/jvm/default-java")
}
#[cfg(target_os = "macos")]
fn find_default_java_home() -> String {
// TODO: Find paths dynamically, e.g. via `/usr/libexec/java_home -v 1.8`
String::from("/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home")
}
#[cfg(target_os = "windows")]
fn find_default_java_home() -> String {
// TODO: Find paths dynamically, especially regarding 32-bit/64-bit paths / `Program Files (x86)` / `Program Files`.
String::from("C:\\Program Files\\Java\\jre8")
}
fn main() {
// Try to determine the Java home directory so that we can link to `libjvm`.
let java_home = env::var("JAVA_HOME")
.ok()
.unwrap_or(find_default_java_home());
// TODO: Why is this necessary?
print!("cargo:rustc-link-search=native=");
println!("{}/jre/lib/server", java_home);
if cfg!(target_arch = "x86_64") {
print!("cargo:rustc-link-search=native=");
println!("{}/jre/lib/amd64/server", java_home);
} else if cfg!(target_arch = "x86") {
print!("cargo:rustc-link-search=native=");
println!("{}/jre/lib/i386/server", java_home);
} else {
panic!("rucaja is not currently supported on your architecture")
}
// TODO: handle something like `LD_LIBRARY_PATH` at runtime?
}