##// END OF EJS Templates
rust: add option of static linking a local Re2 install...
Raphaël Gomès -
r45207:97c10b15 default
parent child Browse files
Show More
@@ -8,15 +8,51 b''
8 #[cfg(feature = "with-re2")]
8 #[cfg(feature = "with-re2")]
9 use cc;
9 use cc;
10
10
11 /// Uses either the system Re2 install as a dynamic library or the provided
12 /// build as a static library
11 #[cfg(feature = "with-re2")]
13 #[cfg(feature = "with-re2")]
12 fn compile_re2() {
14 fn compile_re2() {
13 cc::Build::new()
15 use cc;
16 use std::path::Path;
17 use std::process::exit;
18
19 let msg = r"HG_RE2_PATH must be one of `system|<path to build source clone of Re2>`";
20 let re2 = match std::env::var_os("HG_RE2_PATH") {
21 None => {
22 eprintln!("{}", msg);
23 exit(1)
24 }
25 Some(v) => {
26 if v == "system" {
27 None
28 } else {
29 Some(v)
30 }
31 }
32 };
33
34 let mut options = cc::Build::new();
35 options
14 .cpp(true)
36 .cpp(true)
15 .flag("-std=c++11")
37 .flag("-std=c++11")
16 .file("src/re2/rust_re2.cpp")
38 .file("src/re2/rust_re2.cpp");
17 .compile("librustre.a");
39
40 if let Some(ref source) = re2 {
41 options.include(Path::new(source));
42 };
43
44 options.compile("librustre.a");
18
45
19 println!("cargo:rustc-link-lib=re2");
46 if let Some(ref source) = &re2 {
47 // Link the local source statically
48 println!(
49 "cargo:rustc-link-search=native={}",
50 Path::new(source).join(Path::new("obj")).display()
51 );
52 println!("cargo:rustc-link-lib=static=re2");
53 } else {
54 println!("cargo:rustc-link-lib=re2");
55 }
20 }
56 }
21
57
22 fn main() {
58 fn main() {
General Comments 0
You need to be logged in to leave comments. Login now