Skip to content

Commit

Permalink
Add Rust support
Browse files Browse the repository at this point in the history
Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
  • Loading branch information
shymega committed May 12, 2024
1 parent 7186bca commit bca82ba
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/rust/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
find_program(CXXBRIDGE cxxbridge PATHS "$ENV{HOME}/.cargo/bin/")
if (CXXBRIDGE STREQUAL "CXXBRIDGE-NOTFOUND")
find_program(CARGO cargo PATHS "$ENV{HOME}/.cargo/bin/")
if (CARGO STREQUAL "CARGO-NOTFOUND")
message(FATAL_ERROR "Requires cargo available in path, install via rustup https://rustup.rs/")
endif()
message("Could not find cxxbridge, trying to install with `cargo install cxxbridge-cmd'")
execute_process(COMMAND ${CARGO} install cxxbridge-cmd)
find_program(CXXBRIDGE cxxbridge PATHS "$ENV{HOME}/.cargo/bin/")
endif()

corrosion_import_crate(MANIFEST_PATH Cargo.toml)
corrosion_add_cxxbridge(rustlib CRATE openpinebuds_rs FILES lib.rs)
173 changes: 173 additions & 0 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "openpinebuds-rs"
version = "0.1.0"
edition = "2021"

[lib]
name = "openpinebuds_rs"
crate-type = ["staticlib"]

[dependencies]
cxx = "1.0"

[build-dependencies]
cxx-build = "1.0"
21 changes: 21 additions & 0 deletions src/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! Rust library for OpenPineBuds
#![deny(
warnings,
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
clippy::all,
clippy::cargo,
trivial_casts,
trivial_numeric_casts,
unused_import_braces,
unused_qualifications,
unused_extern_crates,
variant_size_differences
)]

#[cxx::bridge]
mod ffi {
//! Rust FFI module for OpenPineBuds

}

0 comments on commit bca82ba

Please sign in to comment.