Skip to content

Commit

Permalink
Fix crates build (#12)
Browse files Browse the repository at this point in the history
* Copy c-blosc2 into out dir for building

Fixes publishing as c-blosc2 configure modifies outside of out dir

* Only set link flags in sys crate
  • Loading branch information
milesgranger authored Apr 29, 2024
1 parent f35df97 commit e8133f6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blosc2-rs"
version = "0.2.3+2.14.3"
version = "0.2.4+2.14.3"
description = "Blosc2"
license = "MIT"
edition = "2021"
Expand Down
3 changes: 2 additions & 1 deletion blosc2-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blosc2-sys"
version = "0.2.3+2.14.3"
version = "0.2.4+2.14.3"
edition = "2021"
description = "Bindings to C Blosc2"
license = "MIT"
Expand Down Expand Up @@ -33,3 +33,4 @@ regenerate-bindings = ["bindgen"]
cmake = "^0.1"
bindgen = { version = "^0.64", optional = true }
pkg-config = { version = "^0.3", optional = true }
copy_dir = "0.1.3"
9 changes: 8 additions & 1 deletion blosc2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ fn main() {
#[cfg(not(feature = "use-system-blosc2"))]
{
let out_dir_str = std::env::var("OUT_DIR").unwrap();
let out_dir = Path::new(&out_dir_str);

// The configure step modifies the config.h.in file into c-blosc2/config.h
// which violates the cargo publishing/build as it modifies things outside
// of the crate's out dir; so we'll copy everything into out/c-blosc2
let src_dir = out_dir.join("c-blosc2");
copy_dir::copy_dir("c-blosc2", &src_dir).unwrap();

let install_path_str =
std::env::var("BLOSC2_INSTALL_PREFIX").unwrap_or(out_dir_str.to_owned());
let install_path = Path::new(&install_path_str);

let cmake_c_flags = std::env::var("CFLAGS").unwrap_or("".to_string());
let mut cmake_conf = cmake::Config::new("c-blosc2");
let mut cmake_conf = cmake::Config::new(src_dir);
cmake_conf
.define("CMAKE_POSITION_INDEPENDENT_CODE", "ON")
.define("BUILD_SHARED_LIBS", "ON")
Expand Down
7 changes: 0 additions & 7 deletions build.rs

This file was deleted.

0 comments on commit e8133f6

Please sign in to comment.