Skip to content

Commit

Permalink
Features & build cleanups (#189)
Browse files Browse the repository at this point in the history
* make bindgen optional
* test prebuilt bindings
* use correct htslib
* update prebuilt linux bindings
* add pre-built osx bindings
* fix optional bindgen branch
* better setup for optional features. build with cc rather than Make
* fixed up support for libdeflate
* use url of temp libdeflater
* add support for gcs and s3
* need direct dep on openssl
* run version.sh and write version.h
* use new -sys setup in libdeflate
* restore rerun directives for header files
* add test for http access
* don't use bindgen by default

Co-authored-by: Roman Valls Guimera <[email protected]>
  • Loading branch information
pmarks and brainstorm authored Jun 12, 2020
1 parent 2c46c26 commit 605eed7
Show file tree
Hide file tree
Showing 9 changed files with 27,969 additions and 107 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,26 @@ jobs:
- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
with:
args: '--out Lcov -- --test-threads 1'
args: '--out Lcov --exclude-files hts-sys/*_prebuilt_bindings.rs -- --test-threads 1'

- name: Upload coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./lcov.info

- name: Test standard build without default features
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features

- name: Test standard build with all features
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features

- name: Test musl build without default features
env:
CFLAGS: -I/usr/local/musl/include
Expand All @@ -92,5 +104,4 @@ jobs:
with:
use-cross: true
command: build
args: --target x86_64-unknown-linux-musl --all-features

args: --target x86_64-unknown-linux-musl --all-features
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ hts-sys = { version = "^1.10", path = "hts-sys", default-features = false }
default = ["bzip2", "lzma", "curl"]
bzip2 = ["hts-sys/bzip2"]
lzma = ["hts-sys/lzma"]
bindgen = ["hts-sys/bindgen"]
curl = ["hts-sys/curl"]
libdeflate = ["hts-sys/libdeflate-sys"]
s3 = ["hts-sys/s3"]
gcs = ["hts-sys/gcs"]
static = ["hts-sys/static"]
serde = ["serde_base", "serde_bytes"]
static = []

[dev-dependencies]
tempdir = "0.3"
Expand Down
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ If you only want to use the library, there is no need to clone the repository. G

## Requirements

To compile this crate you need docker and cross:
rust-htslib comes with pre-built bindings to htslib for Mac and Linux. You will need a C toolchain compatible with the `cc` crate. The build script for this crate will automatically build a link htslib.


### MUSL build
To compile this for MUSL crate you need docker and cross:

```shell
$ cargo install cross
Expand Down Expand Up @@ -62,7 +66,16 @@ with these compression methods, you can deactivate these features to reduce you
rust-htslib = { version = "*", default-features = false }
```

`rust-htslib` also has optional support for `serde`, to allow (de)serialization of `bam::Record` via any serde-supported format:
`rust-htslib` has optional support for `serde`, to allow (de)serialization of `bam::Record` via any serde-supported format.

Http access to files is available with the `curl` feature.

Beta-level S3 and Google Cloud Storge support is available with the `s3` and `gcs` features.

`rust-htslib` can optionally use `bindgen` to generate bindings to htslib. This can slow down the build substantially. Enabling the `bindgen` feature will
cause `hts-sys` to use a create a binding file for your architecture. Pre-built bindings are supplied for Mac and Linux. The `bindgen` feature on Windows is untested - please file a bug if you need help.



```toml
[dependencies]
Expand Down
19 changes: 12 additions & 7 deletions hts-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ tag-message = "Version {{version}} of Rust-HTSlib."

[dependencies]
libz-sys = { version = "1.0.25", features = ["static"] }
# https://github.com/alexcrichton/bzip2-rs/issues/56
bzip2-sys = { version = "0.1.8", optional = true }
lzma-sys = { version = "0.1.16", optional = true, features = ["static"] }
curl-sys = { version = "0.4.31", optional = true, features = ["static-curl", "static-ssl"] }
curl-sys = { version = "0.4.31", optional = true, features = ["static-curl", "static-ssl", "protocol-ftp"] }
libdeflate-sys = { version = "0.5", optional = true }

[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
openssl-sys = { version = "0.9", optional = true }

[features]
default = ["bzip2", "lzma"]
default = ["bzip2", "lzma", "curl"]
bzip2 = ["bzip2-sys"]
lzma = ["lzma-sys"]
curl = ["curl-sys"]
static = []
curl = ["curl-sys", "openssl-sys"]
gcs = ["curl"] # Google Cloud Storage support
s3 = ["curl"] # Amazon S3 support
static = [] # Don't dynamically link to other libraries

[build-dependencies]
fs-utils = "1.1"
bindgen = { version = "0.53.2", default-features = false, features = ["runtime"] }
cc = "1.0"
bindgen = { version = "0.53.2", default-features = false, features = ["runtime"], optional = true }
cc = { version = "1.0", features = ["parallel"] }
glob = "0.3.0"
Loading

0 comments on commit 605eed7

Please sign in to comment.