feat: add rust binding framework
This commit is contained in:
9
Assets/BMapBindings/rusty-bmap/bmap-sys/Cargo.toml
Normal file
9
Assets/BMapBindings/rusty-bmap/bmap-sys/Cargo.toml
Normal 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]
|
||||
13
Assets/BMapBindings/rusty-bmap/bmap-sys/build.rs
Normal file
13
Assets/BMapBindings/rusty-bmap/bmap-sys/build.rs
Normal 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");
|
||||
}
|
||||
9
Assets/BMapBindings/rusty-bmap/bmap-sys/src/lib.rs
Normal file
9
Assets/BMapBindings/rusty-bmap/bmap-sys/src/lib.rs
Normal 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;
|
||||
}
|
||||
7
Assets/BMapBindings/rusty-bmap/bmap-sys/tests/basic.rs
Normal file
7
Assets/BMapBindings/rusty-bmap/bmap-sys/tests/basic.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use bmap_sys;
|
||||
|
||||
#[test]
|
||||
fn test_init_and_dispose() {
|
||||
assert!(unsafe { bmap_sys::BMInit() });
|
||||
assert!(unsafe { bmap_sys::BMDispose() });
|
||||
}
|
||||
Reference in New Issue
Block a user