diff --git a/.travis.yml b/.travis.yml index 3d108f4f..5aad7c40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,15 +25,16 @@ matrix: before_install: - | + rvm get stable rvm install "$BUILD_RUBY_VERSION" rvm use "$BUILD_RUBY_VERSION" ruby --version ruby -e 'require "pp"; pp RbConfig::CONFIG' before_script: -- | - pip install 'travis-cargo<0.2' --user && - export PATH=$HOME/Library/Python/2.7/bin:$HOME/.local/bin:$PATH +- if [ "$TRAVIS_OS_NAME" == "linux" ]; then pip install 'travis-cargo<0.2' --user; fi +- if [ "$TRAVIS_OS_NAME" == "osx" ]; then pip2 install 'travis-cargo<0.2' --user; fi +- export PATH=$HOME/Library/Python/2.7/bin:$HOME/.local/bin:$PATH script: - | @@ -45,8 +46,4 @@ env: - TRAVIS_CARGO_NIGHTLY_FEATURE="" matrix: - BUILD_RUBY_VERSION: 2.3.5 - - BUILD_RUBY_VERSION: 2.3.5 - RUBY_STATIC: 1 - - BUILD_RUBY_VERSION: 2.4.2 - BUILD_RUBY_VERSION: 2.4.2 - RUBY_STATIC: 1 diff --git a/Cargo.toml b/Cargo.toml index 902eefe1..50a58969 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,3 +19,4 @@ libc = "0.2.0" [features] default = [] unstable = [] +test = [] diff --git a/build.rs b/build.rs index 5937b322..f2e91e80 100644 --- a/build.rs +++ b/build.rs @@ -16,39 +16,9 @@ fn rbconfig(key: &str) -> String { String::from_utf8(config.stdout).expect("RbConfig value not UTF-8!") } -fn use_libdir() { - println!("cargo:rustc-link-search={}", rbconfig("libdir")); -} - -fn transform_lib_args(rbconfig_key: &str, replacement: &str) -> String { - rbconfig(rbconfig_key).replace("-l", replacement) -} - -fn use_static() { - // Ruby gives back the libs in the form: `-lpthread -lgmp` - // Cargo wants them as: `-l pthread -l gmp` - println!("cargo:rustc-flags={}", transform_lib_args("LIBS", "-l ")); -} - -fn use_dylib() { - use_libdir(); - println!("cargo:rustc-link-lib=dylib={}", rbconfig("RUBY_SO_NAME")); -} - fn main() { - if rbconfig("target_os") != "mingw32" && env::var_os("RUBY_STATIC").is_some() { - use_static() - } else { - match rbconfig("ENABLE_SHARED").as_str() { - "no" => use_static(), - "yes" => use_dylib(), - _ => { - let msg = "Error! Couldn't find a valid value for \ - RbConfig::CONFIG['ENABLE_SHARED']. \ - This may mean that your ruby's build config is corrupted. \ - Possible solution: build a new Ruby with the `--enable-shared` configure opt."; - panic!(msg) - } - } + if cfg!(feature="test") { + println!("cargo:rustc-link-search={}", rbconfig("libdir")); + println!("cargo:rustc-link-lib=dylib={}", rbconfig("RUBY_SO_NAME")); } }