Skip to content

Commit 605eed7

Browse files
pmarksbrainstorm
andauthored
Features & build cleanups (#189)
* 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 <brainstorm@users.noreply.github.com>
1 parent 2c46c26 commit 605eed7

File tree

9 files changed

+27969
-107
lines changed

9 files changed

+27969
-107
lines changed

.github/workflows/rust.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,26 @@ jobs:
6868
- name: Run cargo-tarpaulin
6969
uses: actions-rs/tarpaulin@v0.1
7070
with:
71-
args: '--out Lcov -- --test-threads 1'
71+
args: '--out Lcov --exclude-files hts-sys/*_prebuilt_bindings.rs -- --test-threads 1'
7272

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

79+
- name: Test standard build without default features
80+
uses: actions-rs/cargo@v1
81+
with:
82+
command: test
83+
args: --no-default-features
84+
85+
- name: Test standard build with all features
86+
uses: actions-rs/cargo@v1
87+
with:
88+
command: test
89+
args: --all-features
90+
7991
- name: Test musl build without default features
8092
env:
8193
CFLAGS: -I/usr/local/musl/include
@@ -92,5 +104,4 @@ jobs:
92104
with:
93105
use-cross: true
94106
command: build
95-
args: --target x86_64-unknown-linux-musl --all-features
96-
107+
args: --target x86_64-unknown-linux-musl --all-features

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ hts-sys = { version = "^1.10", path = "hts-sys", default-features = false }
3535
default = ["bzip2", "lzma", "curl"]
3636
bzip2 = ["hts-sys/bzip2"]
3737
lzma = ["hts-sys/lzma"]
38+
bindgen = ["hts-sys/bindgen"]
3839
curl = ["hts-sys/curl"]
40+
libdeflate = ["hts-sys/libdeflate-sys"]
41+
s3 = ["hts-sys/s3"]
42+
gcs = ["hts-sys/gcs"]
43+
static = ["hts-sys/static"]
3944
serde = ["serde_base", "serde_bytes"]
40-
static = []
4145

4246
[dev-dependencies]
4347
tempdir = "0.3"

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ If you only want to use the library, there is no need to clone the repository. G
1919

2020
## Requirements
2121

22-
To compile this crate you need docker and cross:
22+
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.
23+
24+
25+
### MUSL build
26+
To compile this for MUSL crate you need docker and cross:
2327

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

65-
`rust-htslib` also has optional support for `serde`, to allow (de)serialization of `bam::Record` via any serde-supported format:
69+
`rust-htslib` has optional support for `serde`, to allow (de)serialization of `bam::Record` via any serde-supported format.
70+
71+
Http access to files is available with the `curl` feature.
72+
73+
Beta-level S3 and Google Cloud Storge support is available with the `s3` and `gcs` features.
74+
75+
`rust-htslib` can optionally use `bindgen` to generate bindings to htslib. This can slow down the build substantially. Enabling the `bindgen` feature will
76+
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.
77+
78+
6679

6780
```toml
6881
[dependencies]

hts-sys/Cargo.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,25 @@ tag-message = "Version {{version}} of Rust-HTSlib."
1818

1919
[dependencies]
2020
libz-sys = { version = "1.0.25", features = ["static"] }
21-
# https://github.com/alexcrichton/bzip2-rs/issues/56
2221
bzip2-sys = { version = "0.1.8", optional = true }
2322
lzma-sys = { version = "0.1.16", optional = true, features = ["static"] }
24-
curl-sys = { version = "0.4.31", optional = true, features = ["static-curl", "static-ssl"] }
23+
curl-sys = { version = "0.4.31", optional = true, features = ["static-curl", "static-ssl", "protocol-ftp"] }
24+
libdeflate-sys = { version = "0.5", optional = true }
25+
26+
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
27+
openssl-sys = { version = "0.9", optional = true }
2528

2629
[features]
27-
default = ["bzip2", "lzma"]
30+
default = ["bzip2", "lzma", "curl"]
2831
bzip2 = ["bzip2-sys"]
2932
lzma = ["lzma-sys"]
30-
curl = ["curl-sys"]
31-
static = []
33+
curl = ["curl-sys", "openssl-sys"]
34+
gcs = ["curl"] # Google Cloud Storage support
35+
s3 = ["curl"] # Amazon S3 support
36+
static = [] # Don't dynamically link to other libraries
3237

3338
[build-dependencies]
3439
fs-utils = "1.1"
35-
bindgen = { version = "0.53.2", default-features = false, features = ["runtime"] }
36-
cc = "1.0"
40+
bindgen = { version = "0.53.2", default-features = false, features = ["runtime"], optional = true }
41+
cc = { version = "1.0", features = ["parallel"] }
3742
glob = "0.3.0"

0 commit comments

Comments
 (0)