Skip to content

Commit e204f81

Browse files
committed
Check for metal and/or CUDA support through build.rs and activate Kalosm features when available
1 parent 259c724 commit e204f81

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

Diff for: Cargo.lock

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: rust-executor/Cargo.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ include = [
2323
name = "rust_executor"
2424
path = "src/lib.rs"
2525

26+
[features]
27+
# Pass metal and cuda features (set through build.rs) through to kalosm
28+
default = []
29+
metal = ["kalosm/metal"]
30+
cuda = ["kalosm/cuda"]
31+
32+
2633
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2734

2835
[dependencies]
@@ -99,7 +106,7 @@ rustls = "0.23"
99106
tokio-rustls = "0.26"
100107
rustls-pemfile = "2"
101108

102-
kalosm = { version = "0.3.2", git = "https://github.com/coasys/floneum.git", rev = "44e05c5fe6fc72eaeaf6ccefbf8269cda54aca75", features = ["language", "metal"] }
109+
kalosm = { version = "0.3.2", git = "https://github.com/coasys/floneum.git", rev = "44e05c5fe6fc72eaeaf6ccefbf8269cda54aca75", features = ["language"] }
103110
deflate = "1.0.0"
104111

105112
[dev-dependencies]

Diff for: rust-executor/build.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use std::process::Command;
2+
3+
fn main() {
4+
// Try to detect if CUDA is installed by checking if `nvcc` is available
5+
let cuda_available = Command::new("nvcc").arg("--version").output().is_ok();
6+
7+
// If CUDA is available, enable the `cuda` feature
8+
if cuda_available {
9+
println!("cargo:rustc-cfg=feature=\"cuda\"");
10+
}
11+
12+
// If building on macOS, enable `metal` feature by default
13+
if cfg!(target_os = "macos") {
14+
println!("cargo:rustc-cfg=feature=\"metal\"");
15+
}
16+
}

0 commit comments

Comments
 (0)