Skip to content

Commit

Permalink
Bump c-blosc2 -> v2.13.2 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger authored Mar 16, 2024
1 parent f0b3630 commit 282fdb3
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 58 deletions.
83 changes: 48 additions & 35 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,62 @@ on:
- prereleased

jobs:
macos:
runs-on: macos-latest
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-14
- windows-latest
- ubuntu-latest
flags:
- --features use-system-blosc2
- ''
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build
- name: Test
run: cargo test -- --test-threads 1

windows:
runs-on: windows-latest
# TODO: /~https://github.com/rust-lang/rust-bindgen/issues/2179
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v3
with:
submodules: recursive
python-version: 3.12
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
activate-environment: blosc2
environment-file: environment.yml
- shell: bash -el {0}
run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: "x86_64-pc-windows-gnu"
- name: Set up MinGW
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
- name: Build
run: cargo build --target x86_64-pc-windows-gnu
- name: Test
run: cargo test --target x86_64-pc-windows-gnu

linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install packages (macOS)
if: runner.os == 'macOS'
run: brew install ninja

- name: Install packages (Windows)
if: runner.os == 'Windows'
run: choco install ninja

- name: Install packages (Ubuntu)
if: runner.os == 'Linux'
shell: bash -el {0}
run: conda install clang -y

- name: Build
run: cargo build
shell: bash -el {0}
run: cargo build ${{ matrix.flags }}
- name: Test
# Running tests using shared library is ugly since conda doesn't
# update LD_LIBRARY_PATH type env vars, so would manually need to
# set the library to a currently discoverable place or update these
# env vars for each platform. Won't automatically locate the blosc2
# shared library within the conda environment.
if: ${{ matrix.flags == '' }}
shell: bash -el {0}
run: cargo test
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[package]
name = "blosc2-rs"
version = "0.1.0+2.8.0"
version = "0.2.0+2.13.2"
edition = "2021"

[lib]
name = "blosc2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
defaults = []
use-system-blosc2 = ["blosc2-sys/use-system-blosc2"]

[dependencies]
blosc2-sys = { path = "blosc2-sys" }
Expand Down
9 changes: 8 additions & 1 deletion blosc2-sys/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion blosc2-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
[package]
name = "blosc2-sys"
version = "0.1.0+2.8.0"
version = "0.2.0+2.13.2"
edition = "2021"
links = "blosc2"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[features]
defaults = []
use-system-blosc2 = []

[build-dependencies]
cmake = "^0.1"
bindgen = "^0.64"
pkg-config = "^0.3"
57 changes: 41 additions & 16 deletions blosc2-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
use std::path::PathBuf;

#[cfg(feature = "use-system-blosc2")]
const BLOSC2_VERSION: &'static str = "2.13.2";

fn main() {
let lib = cmake::Config::new("c-blosc2")
.define("CMAKE_POSITION_INDEPENDENT_CODE", "ON")
.define("CMAKE_C_FLAGS", "-Ofast")
.define("STATIC_LIB", "ON")
.define("SHARED_LIB", "ON")
.define("BLOSC_INSTALL", "ON")
.define("BUILD_TESTS", "OFF")
.define("BUILD_EXAMPLES", "OFF")
.define("BUILD_BENCHMARKS", "OFF")
.define("BUILD_FUZZERS", "OFF")
.always_configure(true)
.build();
let header = {
// build blosc2 from source
#[cfg(not(feature = "use-system-blosc2"))]
{
let lib = cmake::Config::new("c-blosc2")
.define("CMAKE_POSITION_INDEPENDENT_CODE", "ON")
.define("STATIC_LIB", "ON")
.define("SHARED_LIB", "OFF")
.define("BLOSC_INSTALL", "ON")
.define("BUILD_TESTS", "OFF")
.define("BUILD_EXAMPLES", "OFF")
.define("BUILD_SHARED_LIBS", "OFF")
.define("BUILD_BENCHMARKS", "OFF")
.define("BUILD_FUZZERS", "OFF")
.define("BUILD_PLUGINS", "OFF")
.always_configure(true)
.build();

println!("cargo:rustc-link-search={}/lib64", lib.display());
println!("cargo:rustc-link-search={}/lib", lib.display());
println!("cargo:rustc-link-lib=static=blosc2");
format!("{}/include/blosc2.h", lib.display())
}

println!("cargo:rustc-link-search={}/lib64", lib.display());
println!("cargo:rustc-link-search={}/lib", lib.display());
println!("cargo:rustc-link-lib=static=blosc2");
// Use system blosc2
#[cfg(feature = "use-system-blosc2")]
{
let lib = pkg_config::Config::new()
.exactly_version(BLOSC2_VERSION)
.probe("blosc2")
.unwrap();
for linkpath in lib.link_paths {
println!("cargo:rustc-link-search={}", linkpath.display());
}
println!("cargo:rustc-link-lib=blosc2");
format!("{}/blosc2.h", lib.include_paths[0].display())
}
};

let out = PathBuf::from(&(format!("{}/bindings.rs", std::env::var("OUT_DIR").unwrap())));
bindgen::Builder::default()
.header(&format!("{}/include/blosc2.h", lib.display()))
.header(header)
.layout_tests(false)
.no_default("tagMONITORINFOEXA") // Windows specific, no default [u8;40usize]
.opaque_type("_IMAGE_TLS_DIRECTORY64") // Windows specific, error[E0588]: packed type cannot transitively contain a #[repr(align)] type
Expand Down
2 changes: 1 addition & 1 deletion blosc2-sys/c-blosc2
Submodule c-blosc2 updated 370 files
6 changes: 6 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: blosc2
channels:
- conda-forge
dependencies:
- pkg-config
- c-blosc2 ==2.13.2
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ pub enum Codec {
}

impl Codec {
#[allow(dead_code)]
fn to_name(&self) -> Result<String> {
(*self).try_into()
}
Expand Down Expand Up @@ -272,7 +273,7 @@ impl TryFrom<i32> for Codec {
type Error = Error;

fn try_from(compcode: i32) -> Result<Self> {
match compcode as u32 {
match compcode as _ {
ffi::BLOSC_BLOSCLZ => Ok(Codec::BloscLz),
ffi::BLOSC_LZ4 => Ok(Codec::LZ4),
ffi::BLOSC_LZ4HC => Ok(Codec::LZ4HC),
Expand Down Expand Up @@ -1916,14 +1917,14 @@ mod tests {
#[test]
fn test_get_version_string() -> Result<()> {
let version = get_version_string()?;
assert_eq!(&version, "2.8.0");
assert_eq!(&version, "2.13.2");
Ok(())
}

#[test]
fn test_get_complib_version_string() -> Result<()> {
let info = get_complib_info(Codec::BloscLz)?;
assert_eq!(&info, "BloscLZ: 2.5.2");
assert_eq!(&info, "BloscLZ: 2.5.3");
Ok(())
}
}

0 comments on commit 282fdb3

Please sign in to comment.