Skip to content

Remove linking unless explicitly enabling testing #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
- |
Expand All @@ -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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ libc = "0.2.0"
[features]
default = []
unstable = []
test = []
36 changes: 3 additions & 33 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}