Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce the new Rust port #529

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions source/ports/rs_port2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
77 changes: 77 additions & 0 deletions source/ports/rs_port2/Cargo.lock

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

12 changes: 12 additions & 0 deletions source/ports/rs_port2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
workspace = { members = ["crates/metacall-bindings"] }
[package]
name = "metacall-rs"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.93"
metacall-bindings = { path = "crates/metacall-bindings" }
thiserror = "2.0.3"
4 changes: 4 additions & 0 deletions source/ports/rs_port2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
> Under development. Don't use it in production!

# Metacall Rust Port
Improved version for [Metacall Rust Port](https://github.com/metacall/core/tree/develop/source/ports/rs_port).
2 changes: 2 additions & 0 deletions source/ports/rs_port2/crates/metacall-bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
!build.rs
8 changes: 8 additions & 0 deletions source/ports/rs_port2/crates/metacall-bindings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "metacall-bindings"
version = "0.1.0"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
29 changes: 29 additions & 0 deletions source/ports/rs_port2/crates/metacall-bindings/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::env;

fn main() {
// When running tests from CMake
if let Ok(val) = env::var("PROJECT_OUTPUT_DIR") {
// Link search path to build folder
println!("cargo:rustc-link-search=native={val}");

// Link against correct version of metacall
match env::var("CMAKE_BUILD_TYPE") {
Ok(val) => {
if val == "Debug" {
// Try to link the debug version when running tests
println!("cargo:rustc-link-lib=dylib=metacalld");
} else {
println!("cargo:rustc-link-lib=dylib=metacall");
}
}
Err(_) => {
println!("cargo:rustc-link-lib=dylib=metacall");
}
}
} else {
// When building from Cargo
println!("cargo:rustc-link-lib=dylib=metacall")
}
}


Loading
Loading