1
0

Compare commits

2 Commits

Author SHA1 Message Date
8bc0792f1e feat: add rust binding framework 2026-02-05 17:18:48 +08:00
6d41e593bc doc: update devnote 2026-02-05 16:40:05 +08:00
10 changed files with 132 additions and 0 deletions

View File

@@ -0,0 +1 @@
/target

View File

@@ -0,0 +1,70 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bmap"
version = "0.4.0"
dependencies = [
"bmap-sys",
"thiserror",
]
[[package]]
name = "bmap-sys"
version = "0.4.0"
[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "2.0.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "unicode-ident"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"

View File

@@ -0,0 +1,6 @@
[workspace]
resolver = "3"
members = ["bmap","bmap-sys"]
[workspace.dependencies]
thiserror = "2.0.12"

View File

@@ -0,0 +1,9 @@
[package]
name = "bmap-sys"
version = "0.4.0"
authors = ["yyc12345"]
edition = "2024"
description = "The Rust binding to BMap."
license = "SPDX:MIT"
[dependencies]

View File

@@ -0,0 +1,13 @@
use std::env;
use std::path::PathBuf;
fn main() {
// Fetch user specified install directory of built BMap.
let install_dir = env::var("LibCmo_ROOT").expect("You must set LibCmo_ROOT to the install directory of LibCmo built by CMake before building this Rust crate.");
let install_path = PathBuf::from(install_dir);
// Tell Rust compiler where to find linkd dynamic library.
println!("cargo:rustc-link-search=native={}", install_path.join("lib").display());
// Tell Rust compiler the name of linked dynamic library.
println!("cargo:rustc-link-lib=dylib=BMap");
}

View File

@@ -0,0 +1,9 @@
use std::ffi::{CStr, CString};
use std::os::raw::{c_float, c_void};
//use std::ptr;
#[link(name = "BMap", kind = "dylib")]
unsafe extern "C" {
pub unsafe fn BMInit() -> bool;
pub unsafe fn BMDispose() -> bool;
}

View File

@@ -0,0 +1,7 @@
use bmap_sys;
#[test]
fn test_init_and_dispose() {
assert!(unsafe { bmap_sys::BMInit() });
assert!(unsafe { bmap_sys::BMDispose() });
}

View File

@@ -0,0 +1,11 @@
[package]
name = "bmap"
version = "0.4.0"
authors = ["yyc12345"]
edition = "2024"
description = "The wrapper for Rust binding to BMap."
license = "SPDX:MIT"
[dependencies]
thiserror = { workspace = true }
bmap-sys = { path="../bmap-sys" }

View File

@@ -0,0 +1 @@
use bmap_sys;

View File

@@ -39,6 +39,11 @@ Some Java code use Google Gson as its dependency.
The Gson versio I used is Gson 2.10.1. The Gson versio I used is Gson 2.10.1.
It would be okey for you to use any Antlr you like. It would be okey for you to use any Antlr you like.
### Passing Dependencies
When executing Java code relying on these dependencies,
you can use `-cp` option of Java runtime to pass the directory where you can find those dependency's JAR files.
## Python ## Python
For most Python code written in this project, we use Astral UV to manage them. For most Python code written in this project, we use Astral UV to manage them.