Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
use cmake to build snappy-sys
Browse files Browse the repository at this point in the history
  • Loading branch information
andresilva committed Jun 29, 2018
1 parent 87b9fc3 commit 5342af8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 119 deletions.
7 changes: 3 additions & 4 deletions snappy-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ authors = ["Arkadiy Paronyan arkadiy@ethcore.io>"]
license = "MIT/Apache-2.0/BSD"
description = "Native bindings to libsnappy"
readme = "README.md"
keywords = [ "ffi", "snappy" ]
keywords = ["ffi", "snappy"]

build = "build.rs"
links = "snappy"

[features]
default = [ "static" ]
static = []
default = []

[dependencies]
libc = "0.2"

[build-dependencies]
cc = { version = "1.0", features = ["parallel"] }
cmake = "0.1"
31 changes: 13 additions & 18 deletions snappy-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
extern crate cc;
extern crate cmake;

fn main() {
let mut snappy_config = cc::Build::new();
snappy_config.include("snappy/");
snappy_config.include(".");

snappy_config.define("NDEBUG", Some("1"));
use cmake::Config;

if !cfg!(target_env = "msvc") {
snappy_config.flag("-std=c++11");
} else {
snappy_config.flag("-EHsc");
}
fn main() {
let dst = Config::new("snappy").build_target("snappy").build();
let build = dst.join("build");
println!("cargo:rustc-link-lib=static=snappy");
println!("cargo:rustc-link-search=native={}", build.display());

snappy_config.file("snappy/snappy.cc");
snappy_config.file("snappy/snappy-sinksource.cc");
snappy_config.file("snappy/snappy-c.cc");
snappy_config.cpp(true);
snappy_config.compile("libsnappy.a");
// https://github.com/alexcrichton/cc-rs/blob/ca70fd32c10f8cea805700e944f3a8d1f97d96d4/src/lib.rs#L891
if cfg!(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")) {
println!("cargo:rustc-link-lib=c++");
} else {
println!("cargo:rustc-link-lib=stdc++");
}
}

97 changes: 0 additions & 97 deletions snappy-sys/snappy-stubs-public.h

This file was deleted.

0 comments on commit 5342af8

Please sign in to comment.