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

Update to snappy 1.1.7 and use cmake to build snappy-sys #4

Merged
merged 10 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
os: Visual Studio 2015

environment:
matrix:
- channel: stable
target: x86_64-pc-windows-msvc
- channel: stable
target: i686-pc-windows-msvc
- channel: beta
target: x86_64-pc-windows-msvc
- channel: beta
target: i686-pc-windows-msvc
- channel: nightly
target: x86_64-pc-windows-msvc
- channel: nightly
target: i686-pc-windows-msvc

matrix:
allow_failures:
- channel: nightly

install:
- appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init -yv --default-toolchain %channel% --default-host %target%
- set PATH=%PATH%;%USERPROFILE%\.cargo\bin
- rustc -vV
- cargo -vV

build: false

test_script:
- cargo test -vv %cargoflags%
- cargo test -vv --release %cargoflags%

cache:
- target
- C:\Users\appveyor\.cargo\registry
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true
[*]
indent_style=tab
indent_size=tab
tab_width=4
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
max_line_length=120
insert_final_newline=true

[*.{yml,sh}]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/Cargo.lock
**/target/
58 changes: 58 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
language: rust

matrix:
include:
- os: linux
env: TARGET=x86_64-unknown-linux-gnu
rust: stable
- os: linux
env: TARGET=i686-unknown-linux-gnu
rust: stable
- os: osx
env: TARGET=x86_64-apple-darwin
rust: stable

- os: linux
env: TARGET=x86_64-unknown-linux-gnu
rust: beta
- os: linux
env: TARGET=i686-unknown-linux-gnu
rust: beta
- os: osx
env: TARGET=x86_64-apple-darwin
rust: beta

- os: linux
env: TARGET=x86_64-unknown-linux-gnu
rust: nightly
- os: linux
env: TARGET=i686-unknown-linux-gnu
rust: nightly
- os: osx
env: TARGET=x86_64-apple-darwin
rust: nightly
exclude:
- rust: stable
allow_failures:
- rust: nightly
fast_finish: true

env:
global:
- HOST=x86_64-unknown-linux-gnu

install:
# prevent target re-add error from rustup
- if [[ $TRAVIS_OS_NAME == "linux" && $HOST != $TARGET ]]; then rustup target add $TARGET; fi

script:
- cargo test -vv --target=$TARGET
- cargo test -vv --release --target=$TARGET

addons:
apt:
packages:
- gcc-multilib
- g++-multilib

cache: cargo
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
libc = "0.2.7"
libc = "0.2"
snappy-sys = { path = "snappy-sys" }

[dev-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# snappy

Rust bindings for the snappy compression library.

[![Build Status](https://travis-ci.org/paritytech/rust-snappy.svg?branch=master)](https://travis-ci.org/paritytech/rust-snappy)
[![Build status](https://ci.appveyor.com/api/projects/status/rr3ipesm4qqwv7y1?svg=true)](https://ci.appveyor.com/project/andresilva/rust-snappy)
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"
50 changes: 35 additions & 15 deletions snappy-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
extern crate cc;
extern crate cmake;

use std::env;
use std::fs;

use cmake::Config;

fn main() {
let mut snappy_config = cc::Build::new();
snappy_config.include("snappy/");
snappy_config.include(".");
let src = env::current_dir().unwrap().join("snappy");

let out = Config::new("snappy")
.define("CMAKE_VERBOSE_MAKEFILE", "ON")
.build_target("snappy")
.build();

let mut build = out.join("build");

if cfg!(target_os = "windows") {
let stub = build.join("snappy-stubs-public.h");

snappy_config.define("NDEBUG", Some("1"));
let profile = match &*env::var("PROFILE").unwrap_or("debug".to_owned()) {
"bench" | "release" => "Release",
_ => "Debug",
};
build = build.join(profile);

if !cfg!(target_env = "msvc") {
snappy_config.flag("-std=c++11");
} else {
snappy_config.flag("-EHsc");
fs::copy(stub, build.join("snappy-stubs-public.h")).unwrap();
}

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");
}
fs::copy(src.join("snappy.h"), build.join("snappy.h")).unwrap();

println!("cargo:rustc-link-search=native={}", build.display());
println!("cargo:rustc-link-lib=static=snappy");
println!("cargo:include={}", build.display());

// 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 if cfg!(not(target_env = "msvc")) {
println!("cargo:rustc-link-lib=stdc++");
}
}
97 changes: 0 additions & 97 deletions snappy-sys/snappy-stubs-public.h

This file was deleted.

41 changes: 41 additions & 0 deletions snappy-sys/snappy/.appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Build matrix / environment variables are explained on:
# https://www.appveyor.com/docs/appveyor-yml/
# This file can be validated on: https://ci.appveyor.com/tools/validate-yaml

version: "{build}"

environment:
matrix:
# AppVeyor currently has no custom job name feature.
# http://help.appveyor.com/discussions/questions/1623-can-i-provide-a-friendly-name-for-jobs
- JOB: Visual Studio 2017
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_GENERATOR: Visual Studio 15 2017
- JOB: Visual Studio 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE_GENERATOR: Visual Studio 14 2015

platform:
- x86
- x64

configuration:
- RelWithDebInfo
- Debug

build:
verbosity: minimal

build_script:
- git submodule update --init --recursive
- mkdir out
- cd out
- if "%platform%"=="x64" set CMAKE_GENERATOR=%CMAKE_GENERATOR% Win64
- cmake --version
- cmake .. -G "%CMAKE_GENERATOR%"
-DCMAKE_CONFIGURATION_TYPES="%CONFIGURATION%"
- cmake --build . --config %CONFIGURATION%
- cd ..

test_script:
- out\%CONFIGURATION%\snappy_unittest
Loading