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
30 changes: 26 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,32 @@ jobs:
- nightly
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config libsuitesparse-dev
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose
- run: cargo test --verbose
sudo apt-get install -y cmake libclang-dev clang

- name: Build and install SuiteSparse:GraphBLAS
run: |
git clone --depth 1 https://github.com/DrTimothyAldenDavis/GraphBLAS.git
cd GraphBLAS
make compact
sudo make install

- name: Build and install LAGraph
run: |
cd deps/LAGraph
make
sudo make install

- name: Install Rust toolchain
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}

- name: Build (with regenerated bindings)
run: cargo build --features regenerate-bindings --verbose

- name: Test
run: LD_LIBRARY_PATH=/usr/local/lib cargo test --verbose
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/LAGraph"]
path = deps/LAGraph
url = https://github.com/SparseLinearAlgebra/LAGraph.git
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,14 @@ version = "0.1.0"
edition = "2024"

[dependencies]
csv = "1.4.0"
libc = "0.2"
oxrdf = "0.3.3"
oxttl = "0.2.3"
thiserror = "1.0"

[features]
regenerate-bindings = ["bindgen"]

[build-dependencies]
bindgen = { version = "0.71", optional = true }
99 changes: 99 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#[cfg(feature = "regenerate-bindings")]
use std::path::PathBuf;

fn main() {
println!("cargo:rustc-link-lib=dylib=graphblas");
println!("cargo:rustc-link-search=native=/usr/local/lib");
println!("cargo:rustc-link-lib=dylib=lagraph");
println!("cargo:rustc-link-search=native=deps/LAGraph/build/src");
println!("cargo:rustc-link-lib=dylib=lagraphx");
println!("cargo:rustc-link-search=native=deps/LAGraph/build/experimental");

// ---- Bindgen (only with `regenerate-bindings` feature) ----
#[cfg(feature = "regenerate-bindings")]
regenerate_bindings();

println!("cargo:rerun-if-changed=build.rs");
}

#[cfg(feature = "regenerate-bindings")]
fn regenerate_bindings() {
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));

let lagraph_include = manifest_dir.join("deps/LAGraph/include");
assert!(
lagraph_include.join("LAGraph.h").exists(),
"LAGraph.h not found at {}.\n\
Fetch the submodule:\n git submodule update --init --recursive",
lagraph_include.display()
);

let graphblas_include = [
PathBuf::from("/usr/local/include/suitesparse"),
PathBuf::from("/usr/include/suitesparse"),
]
.into_iter()
.find(|p| p.join("GraphBLAS.h").exists())
.unwrap_or_else(|| {
panic!(
"GraphBLAS.h not found.\n\
Install SuiteSparse:GraphBLAS so headers are in /usr/local/include/suitesparse."
)
});

let bindings = bindgen::Builder::default()
.header(
lagraph_include
.join("LAGraph.h")
.to_str()
.expect("non-utf8 header path"),
)
.header(
lagraph_include
.join("LAGraphX.h")
.to_str()
.expect("non-utf8 header path"),
)
.clang_arg(format!("-I{}", graphblas_include.display()))
.clang_arg(format!("-I{}", lagraph_include.display()))
.allowlist_type("GrB_Index")
.allowlist_type("GrB_Matrix")
.allowlist_type("GrB_Vector")
.allowlist_item("GrB_BOOL")
.allowlist_item("GrB_LOR")
.allowlist_item("GrB_LOR_LAND_SEMIRING_BOOL")
.allowlist_item("GrB_Info")
.allowlist_function("GrB_Matrix_new")
.allowlist_function("GrB_Matrix_nvals")
.allowlist_function("GrB_Matrix_free")
.allowlist_function("GrB_Matrix_build_BOOL")
.allowlist_function("GrB_Vector_new")
.allowlist_function("GrB_Vector_free")
.allowlist_function("GrB_Vector_setElement_BOOL")
.allowlist_function("GrB_Vector_nvals")
.allowlist_function("GrB_Vector_extractTuples_BOOL")
.allowlist_function("GrB_vxm")
.allowlist_type("LAGraph_Graph")
.allowlist_type("LAGraph_Kind")
.allowlist_function("LAGraph_Init")
.allowlist_function("LAGraph_Finalize")
.allowlist_function("LAGraph_New")
.allowlist_function("LAGraph_Delete")
.allowlist_function("LAGraph_Cached_AT")
.allowlist_function("LAGraph_MMRead")
.default_enum_style(bindgen::EnumVariation::Rust {
non_exhaustive: false,
})
.derive_debug(true)
.derive_copy(true)
.layout_tests(false)
// Suppress C-language doc comments so rustdoc does not attempt to
// compile them as Rust doctests.
.generate_comments(false)
.generate()
.expect("bindgen failed to generate bindings");

bindings
.write_to_file(manifest_dir.join("src/lagraph_sys_generated.rs"))
.expect("failed to write bindgen output to src/lagraph_sys_generated.rs");
}
1 change: 1 addition & 0 deletions deps/LAGraph
Submodule LAGraph added at bc0049
Loading
Loading