forked from GitHub/bdwgc-rust
add optional cmake builds
This commit is contained in:
@@ -8,8 +8,12 @@ edition = "2018"
|
||||
license = "MIT"
|
||||
build = "build.rs"
|
||||
|
||||
[features]
|
||||
default = ["autotools"]
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
[build-dependencies]
|
||||
autotools = "0.2"
|
||||
autotools = {version = "0.2", optional = true}
|
||||
cmake = {version = "0.1", optional = true}
|
||||
|
||||
@@ -12,6 +12,13 @@ This crate is for use cases in which developers need to integrate [`bdwgc`][bdwg
|
||||
|
||||
See [`examples`](examples) directory.
|
||||
|
||||
By default [`bdwgc`][bdwgc] is built with autotools. To build with cmake enable the `cmake` feature in `Cargo.toml`:
|
||||
|
||||
[dependencies.bdwgc-alloc]
|
||||
version = "0.4"
|
||||
default-features = false
|
||||
features = ["cmake"]
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
27
build.rs
27
build.rs
@@ -1,6 +1,7 @@
|
||||
const LIB_ATOMIC_OPS_DIR: &str = "vendor/libatomic_ops";
|
||||
const LIB_GC_DIR: &str = "vendor/bdwgc";
|
||||
|
||||
#[cfg(feature = "autotools")]
|
||||
fn main() {
|
||||
for dir in &[LIB_ATOMIC_OPS_DIR, LIB_GC_DIR] {
|
||||
std::process::Command::new("sh")
|
||||
@@ -41,3 +42,29 @@ fn main() {
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "cmake")]
|
||||
fn main() {
|
||||
use cmake::Config;
|
||||
use std::path::Path;
|
||||
|
||||
let libatomic_include_path = Path::new(LIB_ATOMIC_OPS_DIR)
|
||||
.join("src")
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.display()
|
||||
.to_string()
|
||||
.replace(r"\\?\", "");
|
||||
|
||||
let dst = Config::new(LIB_GC_DIR)
|
||||
.profile("Release")
|
||||
.define("BUILD_SHARED_LIBS", "FALSE")
|
||||
.cflag(format!("-I{}", libatomic_include_path))
|
||||
.build();
|
||||
|
||||
println!(
|
||||
"cargo:rustc-link-search=native={}",
|
||||
dst.join("lib").display()
|
||||
);
|
||||
println!("cargo:rustc-link-lib=static=gc");
|
||||
}
|
||||
|
||||
2
vendor/bdwgc
vendored
2
vendor/bdwgc
vendored
Submodule vendor/bdwgc updated: 2b7003769e...a20818be9e
2
vendor/libatomic_ops
vendored
2
vendor/libatomic_ops
vendored
Submodule vendor/libatomic_ops updated: 6287479564...ae996e93f0
Reference in New Issue
Block a user