summaryrefslogtreecommitdiff
path: root/impls
diff options
context:
space:
mode:
Diffstat (limited to 'impls')
-rw-r--r--impls/monero_rust/Cargo.lock7
-rw-r--r--impls/monero_rust/Cargo.toml14
-rw-r--r--impls/monero_rust/LICENSE22
-rw-r--r--impls/monero_rust/README.md16
-rw-r--r--impls/monero_rust/build.rs15
-rw-r--r--impls/monero_rust/src/main.rs10
6 files changed, 80 insertions, 4 deletions
diff --git a/impls/monero_rust/Cargo.lock b/impls/monero_rust/Cargo.lock
new file mode 100644
index 0000000..bb713b5
--- /dev/null
+++ b/impls/monero_rust/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "monero_rust"
+version = "0.0.1"
diff --git a/impls/monero_rust/Cargo.toml b/impls/monero_rust/Cargo.toml
new file mode 100644
index 0000000..0815b9e
--- /dev/null
+++ b/impls/monero_rust/Cargo.toml
@@ -0,0 +1,14 @@
+[package]
+name = "monero_rust"
+version = "0.0.1"
+edition = "2021"
+description = "monero_c Rust bindings."
+repository = "https://github.com/ManyMath/monero_rust"
+license = "MIT"
+build = "build.rs"
+
+[[bin]]
+name = "monero_rust"
+path = "src/main.rs"
+
+[dependencies]
diff --git a/impls/monero_rust/LICENSE b/impls/monero_rust/LICENSE
new file mode 100644
index 0000000..45a85f9
--- /dev/null
+++ b/impls/monero_rust/LICENSE
@@ -0,0 +1,22 @@
+MIT License
+
+Copyright (c) 2024 Joshua Babb
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/impls/monero_rust/README.md b/impls/monero_rust/README.md
index eeb3524..fa851fa 100644
--- a/impls/monero_rust/README.md
+++ b/impls/monero_rust/README.md
@@ -2,8 +2,15 @@
`monero_c` bindings for Rust.
## Getting started
+<!--
+### Prerequisites
+You may need
+```
+sudo apt-get install libhidapi-dev
+```
+-->
1. Build `monero_c`
-2. Copy the `monero_c` static library to `monero_rust`.
+2. Copy the `monero_c` library to `monero_rust`.
3. Run `monero_rust` example
### Build `monero_c`
@@ -26,12 +33,13 @@ git submodule update --init --recursive --force
```
<!-- TODO add unxz etc -->
-### Copy the `monero_c` static library to `monero_rust`.
-Copy your `libwallet` static library to `monero_c/impls/monero_rust/lib`.
+### Copy the `monero_c` library to `monero_rust`.
+Copy your `libwallet` library to `monero_c/impls/monero_rust/lib`.
```
cp build/release/monero/x86_64-linux-gnu_libwallet2_api_c.so ../lib
+mv ../lib/x86_64-linux-gnu_libwallet2_api_c.so ../lib/libx86_64-linux-gnu_libwallet2_api_c.so
```
-<!-- TODO automatically copy using arch provided as param IAW TODO above -->
+<!-- TODO automatically copy and rename using arch param IAW TODO above -->
### Run `monero_rust` example
From `monero_c/impls/monero_rust`:
diff --git a/impls/monero_rust/build.rs b/impls/monero_rust/build.rs
new file mode 100644
index 0000000..47c41a6
--- /dev/null
+++ b/impls/monero_rust/build.rs
@@ -0,0 +1,15 @@
+use std::env;
+use std::path::PathBuf;
+
+fn main() {
+ println!("cargo:rerun-if-changed=build.rs");
+
+ let lib_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("lib");
+
+ println!("cargo:rustc-link-search=native={}", lib_dir.display());
+ println!("cargo:rustc-link-lib=dylib=wallet2_api_c");
+ println!("cargo:rustc-link-lib=dylib=stdc++");
+ println!("cargo:rustc-link-lib=dylib=hidapi-hidraw");
+
+ println!("cargo:rustc-link-arg-bin=monero_rust=-Wl,-rpath,$ORIGIN/../../lib");
+}
diff --git a/impls/monero_rust/src/main.rs b/impls/monero_rust/src/main.rs
new file mode 100644
index 0000000..0e76a13
--- /dev/null
+++ b/impls/monero_rust/src/main.rs
@@ -0,0 +1,10 @@
+fn main() {
+ unsafe {
+ MONERO_DEBUG_test0();
+ }
+ println!("Called MONERO_DEBUG_test0 successfully.");
+}
+
+extern "C" {
+ fn MONERO_DEBUG_test0();
+}