Skip to content
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
File renamed without changes.
17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ keywords = ["htslib", "bam", "bioinformatics", "pileup", "sequencing"]
license = "MIT"
repository = "https://github.com/samtools/htslib.git"
documentation = "https://docs.rs/rust-htslib"
edition = "2018"
edition = "2021"
rust-version = "1.56"

[package.metadata.release]
pre-release-commit-message = "release version {{version}}"
Expand All @@ -28,16 +29,16 @@ openssl-sys = { version = "0.9.56", optional = true }

[features]
default = ["bzip2", "lzma", "curl"]
bzip2 = ["bzip2-sys"]
lzma = ["lzma-sys"]
curl = ["curl-sys", "openssl-sys"]
libdeflate = ["libdeflate-sys"]
bzip2 = ["bzip2-sys"] # Bzip2 support
lzma = ["lzma-sys"] # LZMA support
curl = ["curl-sys", "openssl-sys"] # HTTP/FTP support (requires OpenSSL on non-macOS Unix)
libdeflate = ["libdeflate-sys"] # libdeflate support (faster compression/decompression)
gcs = ["curl"] # Google Cloud Storage support
s3 = ["curl"] # Amazon S3 support
static = [] # Don't dynamically link to other libraries
static = [] # Deprecated, always on

[build-dependencies]
fs-utils = "1.1"
bindgen = { version = "0.72.1", default-features = false, features = ["runtime"], optional = true }
cc = { version = "1.0", features = ["parallel"] }
glob = "0.3.0"
cc = { version = "1.2.67", features = ["parallel"] }
glob = "0.3.3"
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,37 @@

This sub-crate provides the raw HTSlib bindings, which are used for the high level Rust API for reading and writing BAM files provided by rust-htslib.

See rust-htslib for details.
See [rust-htslib](https://github.com/rust-bio/rust-htslib) for details.

## Cloning
When cloning this repo and updating the binaries, the `htslib` submodule needs to be cloned recursively:

```
git clone --recurse-submodules ...
```

## Updating prebuilt bindings

When updating the htslib submodule or modifying `wrapper.h`, the prebuilt binding files need to be regenerated.

### macOS

```sh
cargo build --features bindgen
cp target/debug/build/hts-sys-*/out/bindings.rs osx_prebuilt_bindings.rs
```

### Linux

```sh
docker run --rm --platform linux/amd64 \
-v "$(pwd)":/workspace -w /workspace rust:latest bash -c '
rustup component add rustfmt &&
apt-get update -qq &&
apt-get install -y -qq cmake zlib1g-dev libbz2-dev clang libc6-dev libssl-dev libcurl4-openssl-dev &&
cargo build --features bindgen &&
BINDINGS=$(find target/debug/build/hts-sys-*/out -name bindings.rs | head -1) &&
rustfmt "$BINDINGS" &&
cp "$BINDINGS" linux_prebuilt_bindings.rs
'
```
19 changes: 10 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This file may not be copied, modified, or distributed
// except according to those terms.

#[cfg(feature = "serde")]
#[cfg(feature = "bindgen")]
use bindgen;
use fs_utils::copy::copy_directory;
use glob::glob;
Expand Down Expand Up @@ -34,6 +34,7 @@ const FILES: &[&str] = &[
"region.c",
"sam.c",
"sam_mods.c",
"simd.c",
"synced_bcf_reader.c",
"vcf_sweep.c",
"tbx.c",
Expand Down Expand Up @@ -95,12 +96,11 @@ fn main() {

cfg.include(out.join("htslib"));

let want_static = cfg!(feature = "static") || env::var("HTS_STATIC").is_ok();

if want_static {
cfg.warnings(false).static_flag(true).pic(true);
} else {
cfg.warnings(false).static_flag(false).pic(true);
if cfg!(feature = "static") {
// this is the default as of 2.3.0, we just keep the feature for backwards compatibility
println!(
"cargo:warning=The `static` feature is deprecated and is now the default behavior."
);
}

if let Ok(z_inc) = env::var("DEP_Z_INCLUDE") {
Expand Down Expand Up @@ -183,8 +183,6 @@ fn main() {
config_lines.push("#define ENABLE_S3 1");
cfg.file("htslib/hfile_s3.c");
println!("cargo:rerun-if-changed=htslib/hfile_s3.c");
cfg.file("htslib/hfile_s3_write.c");
println!("cargo:rerun-if-changed=htslib/hfile_s3_write.c");
}

// pass through target-feature flags to enable special instruction
Expand Down Expand Up @@ -261,6 +259,7 @@ fn main() {
}

cfg.file("wrapper.c");
cfg.cargo_warnings(false);
cfg.compile("hts");

// If bindgen is enabled, use it
Expand All @@ -269,6 +268,8 @@ fn main() {
bindgen::Builder::default()
.header("wrapper.h")
.layout_tests(false)
.rust_target(bindgen::RustTarget::stable(56, 0).unwrap())
.rust_edition(bindgen::RustEdition::Edition2021)
.generate_comments(false)
.blocklist_function("strtold")
.blocklist_type("max_align_t")
Expand Down
2 changes: 1 addition & 1 deletion htslib
Submodule htslib updated 290 files
Loading
Loading