-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mulimoen/feature/cc
Switch build system from cmake to cc
- Loading branch information
Showing
6 changed files
with
103 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,28 @@ | |
name = "blosc-src" | ||
version = "0.1.1" | ||
authors = ["Magnus Ulimoen <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
build = "build.rs" | ||
links = "blosc" | ||
license-file = "c-blosc/LICENSES/BLOSC.txt" | ||
exclude = [ | ||
"c-blosc/compat/**", | ||
"c-blosc/tests/**", | ||
"c-blosc/bench/**", | ||
"c-blosc/internal-complibs/zlib-1.2.11/contrib/**", | ||
"c-blosc/internal-complibs/zlib-1.2.11/examples/**", | ||
"c-blosc/internal-complibs/zlib-1.2.11/doc/**", | ||
"c-blosc/internal-complibs/zstd-1.5.2/legacy/**", | ||
] | ||
repository = "https://github.com/mulimoen/rust-blosc-src" | ||
keywords = ["compression"] | ||
categories = ["external-ffi-bindings", "compression"] | ||
description = "FFI bindings for blosc-c" | ||
|
||
[dependencies] | ||
[features] | ||
lz4 = [] | ||
zstd = [] | ||
zlib = [] | ||
|
||
[build-dependencies] | ||
cmake = "0.1.46" | ||
cc = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
#! /bin/sh | ||
bindgen --no-rustfmt-bindings \ | ||
--blacklist-type __uint64_t \ | ||
--blacklist-type __size_t \ | ||
--whitelist-type '.*BLOSC.*' \ | ||
--whitelist-function '.*blosc.*' \ | ||
--whitelist-var '.*BLOSC.*' \ | ||
--blocklist-type __uint64_t \ | ||
--blocklist-type __size_t \ | ||
--allowlist-type '.*BLOSC.*' \ | ||
--allowlist-function '.*blosc.*' \ | ||
--allowlist-var '.*BLOSC.*' \ | ||
--size_t-is-usize \ | ||
c-blosc/blosc/blosc.h > src/bindgen.rs | ||
rustfmt src/bindgen.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,55 @@ | ||
use std::fs; | ||
|
||
use cc::Build; | ||
|
||
fn main() { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
let mut cfg = cmake::Config::new("c-blosc"); | ||
|
||
for option in &[ | ||
"BUILD_SHARED", | ||
"BUILD_TESTS", | ||
"BUILD_FUZZERS", | ||
"BUILD_BENCHMARKS", | ||
"DEACTIVATE_ZSTD", | ||
] { | ||
cfg.define(option, "OFF"); | ||
} | ||
let mut build = cc::Build::new(); | ||
|
||
let target_mscv = cfg!(target_env = "msvc"); | ||
let add_file = |builder: &mut Build, folder: &str| { | ||
for entry in fs::read_dir(folder).unwrap() { | ||
let path = entry.unwrap().path(); | ||
if let Some(extension) = path.extension() { | ||
if extension == "c" || extension == "cpp" || (!target_mscv && extension == "S") { | ||
builder.file(path); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
add_file(&mut build, "c-blosc/blosc"); | ||
|
||
if !cfg!(target_feature = "sse2") { | ||
cfg.define("DEACTIVATE_SSE2", "OFF"); | ||
if cfg!(feature = "lz4") { | ||
add_file(&mut build, "c-blosc/internal-complibs/lz4-1.9.3"); | ||
build.include("c-blosc/internal-complibs/lz4-1.9.3"); | ||
build.define("HAVE_LZ4", None); | ||
} | ||
if !cfg!(target_feature = "avx") { | ||
cfg.define("DEACTIVATE_AVX", "OFF"); | ||
if cfg!(feature = "zlib") { | ||
add_file(&mut build, "c-blosc/internal-complibs/zlib-1.2.11"); | ||
build.include("c-blosc/internal-complibs/zlib-1.2.11"); | ||
build.define("HAVE_ZLIB", None); | ||
} | ||
if cfg!(feature = "zstd") { | ||
add_file(&mut build, "c-blosc/internal-complibs/zstd-1.5.2/common"); | ||
add_file(&mut build, "c-blosc/internal-complibs/zstd-1.5.2/compress"); | ||
add_file( | ||
&mut build, | ||
"c-blosc/internal-complibs/zstd-1.5.2/decompress", | ||
); | ||
add_file( | ||
&mut build, | ||
"c-blosc/internal-complibs/zstd-1.5.2/dictBuilder", | ||
); | ||
build.include("c-blosc/internal-complibs/zstd-1.5.2"); | ||
build.define("HAVE_ZSTD", None); | ||
} | ||
|
||
let dst = cfg.build(); | ||
println!("cargo:root={}", dst.display()); | ||
let incdir = format!("{}/include", dst.display()); | ||
println!("cargo:include={}", incdir); | ||
let linklib = if cfg!(target_env = "msvc") { | ||
"libblosc" | ||
} else { | ||
"blosc" | ||
}; | ||
println!("cargo:library={}", linklib); | ||
|
||
println!("cargo:rustc-link-search=native={}/lib", dst.display()); | ||
println!("cargo:rustc-link-lib=static={}", linklib); | ||
build.compile(linklib); | ||
} |
Oops, something went wrong.