-
Notifications
You must be signed in to change notification settings - Fork 1
Build libpressio for libpressio-sys #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
juntyr
wants to merge
12
commits into
robertu94:master
Choose a base branch
from
juntyr:build
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
54e2263
Start work on building libpressio for libpressio-sys
juntyr ddceba6
very basic libpressio compiling locally
robertu94 dc97033
Add CI
juntyr 82afbea
Fix usize usage sites
juntyr 63f1e1e
Add an openmp feature
juntyr 85342cf
Try linking libpressio from general path
juntyr d5cdbe5
Try using an explicit static lib name for libpressio
juntyr a26ebb2
Try passing the libpressio lib name verbatim
juntyr 0c888fb
Fix verbatim modifier
juntyr 6d25c06
Conservatively add more library search paths
juntyr 34adf91
Various fixes to the libpressio rust build
robertu94 94607be
Merge branch 'build' of github.com:juntyr/libpressio-rs into build
robertu94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [submodule "libpressio-sys/libpressio"] | ||
| path = libpressio-sys/libpressio | ||
| url = https://github.com/robertu94/libpressio.git | ||
| [submodule "libpressio-sys/std_compat"] | ||
| path = libpressio-sys/std_compat | ||
| url = https://github.com/robertu94/std_compat |
This file contains hidden or 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,15 +1,38 @@ | ||
| [workspace] | ||
| resolver = "2" | ||
| members = ["libpressio-sys"] | ||
|
|
||
| [workspace.package] | ||
| edition = "2024" | ||
| authors = ["Robert Underwood <[email protected]>"] | ||
| repository = "https://github.com/robertu94/libpressio-rs" | ||
| rust-version = "1.85" | ||
|
|
||
| [workspace.dependencies] | ||
| # workspace-internal crates | ||
| libpressio = { version = "0.1", path = ".", default-features = false } | ||
| libpressio-sys = { version = "0.1", path = "libpressio-sys", default-features = false } | ||
|
|
||
| # crates.io third-party dependencies | ||
| bindgen = { version = "0.71", default-features = false } | ||
| cc = { version = "1.2", default-features = false } | ||
| cmake = { version = "0.1.26", default-features = false } | ||
| libc = { version = "0.2", default-features = false } | ||
| ndarray = { version = "0.16.1", default-features = false } | ||
|
|
||
| [package] | ||
| name = "libpressio-rs" | ||
| name = "libpressio" | ||
| version = "0.1.0" | ||
| authors = ["Robert Underwood <[email protected]>"] | ||
| edition = "2018" | ||
| edition = { workspace = true } | ||
| authors = { workspace = true } | ||
| repository = { workspace = true } | ||
| rust-version = { workspace = true } | ||
|
|
||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
| description = "High-level Rust bindings to the libpressio compression framework" | ||
| categories = ["api-bindings", "compression", "encoding"] | ||
| keywords = ["libpressio", "compression", "encoding"] | ||
|
|
||
| [dependencies] | ||
| ndarray = "0.14.0" | ||
| libc = "0.2.86" | ||
|
|
||
| [build-dependencies] | ||
| bindgen = "0.53.1" | ||
| pkg-config = "0.3.19" | ||
| ndarray = { workspace = true } | ||
| libc = { workspace = true } | ||
| libpressio-sys = { workspace = true } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [package] | ||
| name = "libpressio-sys" | ||
| version = "0.1.0" | ||
| edition = { workspace = true } | ||
| authors = { workspace = true } | ||
| repository = { workspace = true } | ||
| rust-version = { workspace = true } | ||
|
|
||
| description = "Low-level Rust bindings to the libpressio compression framework" | ||
| readme = "README.md" | ||
| categories = ["api-bindings", "compression", "encoding"] | ||
| keywords = ["libpressio", "bindgen", "compression", "encoding"] | ||
|
|
||
| [build-dependencies] | ||
| bindgen = { workspace = true, features = ["runtime"] } | ||
| cc = { workspace = true } | ||
| cmake = { workspace = true } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| use std::{ | ||
| env, | ||
| path::{Path, PathBuf}, | ||
| }; | ||
|
|
||
| fn main() { | ||
| println!("cargo::rerun-if-changed=build.rs"); | ||
| println!("cargo::rerun-if-changed=wrapper.h"); | ||
| println!("cargo::rerun-if-changed=libpressio"); | ||
| println!("cargo::rerun-if-changed=std_compat"); | ||
|
|
||
| // --------------------------------------------------------- | ||
| // Configure std_compat, the compiler portability layer | ||
| // --------------------------------------------------------- | ||
| let mut stdcompat_config = cmake::Config::new("std_compat"); | ||
| //prefer static libraries for RUST | ||
| stdcompat_config.define("BUILD_SHARED_LIBS", "OFF"); | ||
| //disable testing to avoid google-test dependency | ||
| stdcompat_config.define("BUILD_TESTING", "OFF"); | ||
| // require a C++17 compiler (e.g. gcc 12 or later) for now | ||
| // this includes Ubuntu 24.04 and later, Fedora, Nyx, et al | ||
| // https://robertu94.github.io/guides/dependencies | ||
| stdcompat_config.define("STDCOMPAT_CXX_VERSION", "17"); | ||
| stdcompat_config.define("STDCOMPAT_CXX_UNSTABLE", "ON"); | ||
| stdcompat_config.define("STD_COMPAT_BOOST_REQUIRED", "OFF"); | ||
| let stdcompat_out = stdcompat_config.build(); | ||
| println!("cargo:rustc-link-search=native={}", stdcompat_out.display()); | ||
|
|
||
| // --------------------------------------------------------- | ||
| // Configure libpressio | ||
| // --------------------------------------------------------- | ||
| let mut config = cmake::Config::new("libpressio"); | ||
| config.define("BUILD_SHARED_LIBS", "OFF"); | ||
| config.define("BUILD_TESTING", "OFF"); | ||
| config.define("LIBPRESSIO_HAS_OPENMP", "ON"); | ||
| config.define("CMAKE_PREFIX_PATH", stdcompat_out); | ||
| let libpressio_out = config.build(); | ||
|
|
||
| println!("cargo:rustc-link-search=native={}", libpressio_out.join("lib64").display()); | ||
| println!("cargo:rustc-link-lib=static=libpressio"); | ||
| eprintln!("include dir {}", libpressio_out.join("include").display()); | ||
|
|
||
| let cargo_callbacks = bindgen::CargoCallbacks::new(); | ||
| let bindings = bindgen::Builder::default() | ||
| .clang_arg("-x") | ||
| .clang_arg("c++") | ||
| .clang_arg("-std=c++11") | ||
| .clang_arg(format!( | ||
| "-I{}", | ||
| libpressio_out.join("include").join("libpressio").display() | ||
| )) | ||
| .header("wrapper.h") | ||
| .parse_callbacks(Box::new(cargo_callbacks)) | ||
| .allowlist_function("pressio_.*") | ||
| .allowlist_var("pressio_.*") | ||
| .allowlist_type("pressio_.*") | ||
| // MSRV 1.85 | ||
| .rust_target(match bindgen::RustTarget::stable(85, 0) { | ||
| Ok(target) => target, | ||
| #[expect(clippy::panic)] | ||
| Err(err) => panic!("{err}"), | ||
| }) | ||
| .generate() | ||
| .expect("Unable to generate bindings"); | ||
|
|
||
| let out_path = | ||
| PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR should be set in a build script")); | ||
| bindings | ||
| .write_to_file(out_path.join("bindings.rs")) | ||
| .expect("Couldn't write bindings!"); | ||
| } | ||
Submodule libpressio
added at
11a1ed
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include!(concat!(env!("OUT_DIR"), "/bindings.rs")); |
Submodule std_compat
added at
76b61a
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "libpressio/include/libpressio.h" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.