Skip to content

Commit 62d1ee7

Browse files
Merge pull request #6 from SparseLinearAlgebra/dev
feat: add graph representation, csv reader
2 parents 34b4a80 + 7a76030 commit 62d1ee7

13 files changed

Lines changed: 1321 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,32 @@ jobs:
1919
- nightly
2020
steps:
2121
- uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
2225
- name: Install system dependencies
2326
run: |
2427
sudo apt-get update
25-
sudo apt-get install -y libssl-dev pkg-config libsuitesparse-dev
26-
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
27-
- run: cargo build --verbose
28-
- run: cargo test --verbose
28+
sudo apt-get install -y cmake libclang-dev clang
29+
30+
- name: Build and install SuiteSparse:GraphBLAS
31+
run: |
32+
git clone --depth 1 https://github.com/DrTimothyAldenDavis/GraphBLAS.git
33+
cd GraphBLAS
34+
make compact
35+
sudo make install
36+
37+
- name: Build and install LAGraph
38+
run: |
39+
cd deps/LAGraph
40+
make
41+
sudo make install
42+
43+
- name: Install Rust toolchain
44+
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
45+
46+
- name: Build (with regenerated bindings)
47+
run: cargo build --features regenerate-bindings --verbose
48+
49+
- name: Test
50+
run: LD_LIBRARY_PATH=/usr/local/lib cargo test --verbose

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "deps/LAGraph"]
2+
path = deps/LAGraph
3+
url = https://github.com/SparseLinearAlgebra/LAGraph.git

Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,14 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7+
csv = "1.4.0"
8+
libc = "0.2"
9+
oxrdf = "0.3.3"
10+
oxttl = "0.2.3"
11+
thiserror = "1.0"
12+
13+
[features]
14+
regenerate-bindings = ["bindgen"]
15+
16+
[build-dependencies]
17+
bindgen = { version = "0.71", optional = true }

build.rs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#[cfg(feature = "regenerate-bindings")]
2+
use std::path::PathBuf;
3+
4+
fn main() {
5+
println!("cargo:rustc-link-lib=dylib=graphblas");
6+
println!("cargo:rustc-link-search=native=/usr/local/lib");
7+
println!("cargo:rustc-link-lib=dylib=lagraph");
8+
println!("cargo:rustc-link-search=native=deps/LAGraph/build/src");
9+
println!("cargo:rustc-link-lib=dylib=lagraphx");
10+
println!("cargo:rustc-link-search=native=deps/LAGraph/build/experimental");
11+
12+
// ---- Bindgen (only with `regenerate-bindings` feature) ----
13+
#[cfg(feature = "regenerate-bindings")]
14+
regenerate_bindings();
15+
16+
println!("cargo:rerun-if-changed=build.rs");
17+
}
18+
19+
#[cfg(feature = "regenerate-bindings")]
20+
fn regenerate_bindings() {
21+
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
22+
23+
let lagraph_include = manifest_dir.join("deps/LAGraph/include");
24+
assert!(
25+
lagraph_include.join("LAGraph.h").exists(),
26+
"LAGraph.h not found at {}.\n\
27+
Fetch the submodule:\n git submodule update --init --recursive",
28+
lagraph_include.display()
29+
);
30+
31+
let graphblas_include = [
32+
PathBuf::from("/usr/local/include/suitesparse"),
33+
PathBuf::from("/usr/include/suitesparse"),
34+
]
35+
.into_iter()
36+
.find(|p| p.join("GraphBLAS.h").exists())
37+
.unwrap_or_else(|| {
38+
panic!(
39+
"GraphBLAS.h not found.\n\
40+
Install SuiteSparse:GraphBLAS so headers are in /usr/local/include/suitesparse."
41+
)
42+
});
43+
44+
let bindings = bindgen::Builder::default()
45+
.header(
46+
lagraph_include
47+
.join("LAGraph.h")
48+
.to_str()
49+
.expect("non-utf8 header path"),
50+
)
51+
.header(
52+
lagraph_include
53+
.join("LAGraphX.h")
54+
.to_str()
55+
.expect("non-utf8 header path"),
56+
)
57+
.clang_arg(format!("-I{}", graphblas_include.display()))
58+
.clang_arg(format!("-I{}", lagraph_include.display()))
59+
.allowlist_type("GrB_Index")
60+
.allowlist_type("GrB_Matrix")
61+
.allowlist_type("GrB_Vector")
62+
.allowlist_item("GrB_BOOL")
63+
.allowlist_item("GrB_LOR")
64+
.allowlist_item("GrB_LOR_LAND_SEMIRING_BOOL")
65+
.allowlist_item("GrB_Info")
66+
.allowlist_function("GrB_Matrix_new")
67+
.allowlist_function("GrB_Matrix_nvals")
68+
.allowlist_function("GrB_Matrix_free")
69+
.allowlist_function("GrB_Matrix_build_BOOL")
70+
.allowlist_function("GrB_Vector_new")
71+
.allowlist_function("GrB_Vector_free")
72+
.allowlist_function("GrB_Vector_setElement_BOOL")
73+
.allowlist_function("GrB_Vector_nvals")
74+
.allowlist_function("GrB_Vector_extractTuples_BOOL")
75+
.allowlist_function("GrB_vxm")
76+
.allowlist_type("LAGraph_Graph")
77+
.allowlist_type("LAGraph_Kind")
78+
.allowlist_function("LAGraph_Init")
79+
.allowlist_function("LAGraph_Finalize")
80+
.allowlist_function("LAGraph_New")
81+
.allowlist_function("LAGraph_Delete")
82+
.allowlist_function("LAGraph_Cached_AT")
83+
.allowlist_function("LAGraph_MMRead")
84+
.default_enum_style(bindgen::EnumVariation::Rust {
85+
non_exhaustive: false,
86+
})
87+
.derive_debug(true)
88+
.derive_copy(true)
89+
.layout_tests(false)
90+
// Suppress C-language doc comments so rustdoc does not attempt to
91+
// compile them as Rust doctests.
92+
.generate_comments(false)
93+
.generate()
94+
.expect("bindgen failed to generate bindings");
95+
96+
bindings
97+
.write_to_file(manifest_dir.join("src/lagraph_sys_generated.rs"))
98+
.expect("failed to write bindgen output to src/lagraph_sys_generated.rs");
99+
}

deps/LAGraph

Submodule LAGraph added at bc00497

0 commit comments

Comments
 (0)