annotate rust/hg-core/build.rs @ 44348:d8d4fa9a7f18

rust-re2: add wrapper for calling Re2 from Rust This assumes that Re2 is installed following Google's guide. I am not sure how we want to integrate it in the project, but I think a follow-up patch would be more appropriate for such work. As it stands, *not* having Re2 installed results in a compilation error, which is a problem as it breaks install compatibility. Hence, this is gated behind a non-default `with-re2` compilation feature. Differential Revision: https://phab.mercurial-scm.org/D7910
author Rapha?l Gom?s <rgomes@octobus.net>
date Thu, 16 Jan 2020 13:34:04 +0100
parents
children 97c10b157665
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44348
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
1 // build.rs
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
2 //
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
3 // Copyright 2020 Raphaël Gomès <rgomes@octobus.net>
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
4 //
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
5 // This software may be used and distributed according to the terms of the
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
6 // GNU General Public License version 2 or any later version.
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
7
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
8 #[cfg(feature = "with-re2")]
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
9 use cc;
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
10
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
11 #[cfg(feature = "with-re2")]
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
12 fn compile_re2() {
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
13 cc::Build::new()
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
14 .cpp(true)
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
15 .flag("-std=c++11")
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
16 .file("src/re2/rust_re2.cpp")
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
17 .compile("librustre.a");
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
18
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
19 println!("cargo:rustc-link-lib=re2");
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
20 }
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
21
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
22 fn main() {
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
23 #[cfg(feature = "with-re2")]
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
24 compile_re2();
d8d4fa9a7f18 rust-re2: add wrapper for calling Re2 from Rust
Rapha?l Gom?s <rgomes@octobus.net>
parents:
diff changeset
25 }