Skip to content

Commit

Permalink
fix msvc building
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu committed Jan 24, 2020
1 parent 9c86efd commit 1139725
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions snmalloc-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cmake::Config;

fn main() {
let mut cfg = &mut Config::new("snmalloc");

Expand All @@ -8,15 +9,8 @@ fn main() {
"Release"
};

if cfg!(all(windows, target_env = "msvc")) {
cfg = cfg.generator("Visual Studio 15 2017 Win64")
.define("SNMALLOC_RUST_SUPPORT", "ON")
.build_arg("--config")
.build_arg(build_type)
} else {
cfg = cfg.define("SNMALLOC_RUST_SUPPORT", "ON")
.define("CMAKE_BUILD_TYPE", build_type)
}
cfg = cfg.define("SNMALLOC_RUST_SUPPORT", "ON")
.profile(build_type);

let target = if cfg!(feature = "1mib") {
"snmallocshim-1mib-rust"
Expand All @@ -29,12 +23,16 @@ fn main() {
} else {
cfg.build_target(target).build()
};

dst.push("./build");
println!("cargo:rustc-link-search=native={}", dst.display());

println!("cargo:rustc-link-lib={}", target);
if cfg!(unix) {
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=dylib=stdc++");
println!("cargo:rustc-link-lib=dylib=atomic");
} else {
println!("cargo:rustc-link-search=native={}/{}", dst.display(), build_type);
println!("cargo:rustc-link-lib=dylib=mincore");
}
}
}

0 comments on commit 1139725

Please sign in to comment.