Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jan 27, 2025
1 parent 9f4fde1 commit 5a7de6f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion platform/rust-autocxx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "rustlib"
name = "maplibre-native-autocxx"
version = "0.1.0"
authors = ["Yuri Astrakhan <[email protected]>", "MapLibre contributors"]
description = "MapLibre Native Rust library"
Expand Down
2 changes: 1 addition & 1 deletion platform/rust-cmake/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "maplibre-native"
name = "maplibre-native-cmake"
version = "0.1.0"
edition = "2021"

Expand Down
10 changes: 10 additions & 0 deletions platform/rust-cxx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "maplibre-native-cxx"
version = "0.1.0"
edition = "2021"

[dependencies]
cxx = "1.0"

[build-dependencies]
cxx-build = "1.0"
10 changes: 10 additions & 0 deletions platform/rust-cxx/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fn main() {
cxx_build::bridge("src/main.rs")
.file("src/blobstore.cc")
.std("c++20")
.compile("cxxbridge-demo");

println!("cargo:rerun-if-changed=src/main.rs");
println!("cargo:rerun-if-changed=src/blobstore.cc");
println!("cargo:rerun-if-changed=include/blobstore.h");
}
12 changes: 12 additions & 0 deletions platform/rust-cxx/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// cxx wrapper for maplibre-native
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
include!("maplibre-native/include/maplibre-native.h");

type MaplibreNative;

fn new_maplibre_native() -> UniquePtr<MaplibreNative>;
fn render(&self, style: &str, width: u32, height: u32) -> Vec<u8>;
}
}

0 comments on commit 5a7de6f

Please sign in to comment.