Add build.rs to rebuild plugins, and a test plugin
This commit is contained in:
parent
5b40734f80
commit
8aef8ab259
8 changed files with 163 additions and 11 deletions
7
plugins/Cargo.lock
generated
7
plugins/Cargo.lock
generated
|
@ -112,6 +112,13 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "test_plugin"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"plugin",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.0"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
[workspace]
|
||||
members = ["./json_language"]
|
||||
members = ["./json_language", "./test_plugin"]
|
||||
|
|
10
plugins/test_plugin/Cargo.toml
Normal file
10
plugins/test_plugin/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "test_plugin"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
plugin = { path = "../../crates/plugin" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
44
plugins/test_plugin/src/lib.rs
Normal file
44
plugins/test_plugin/src/lib.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
use plugin::prelude::*;
|
||||
|
||||
#[export]
|
||||
pub fn noop() {}
|
||||
|
||||
#[export]
|
||||
pub fn constant() -> u32 {
|
||||
27
|
||||
}
|
||||
|
||||
#[export]
|
||||
pub fn identity(i: u32) -> u32 {
|
||||
i
|
||||
}
|
||||
|
||||
#[export]
|
||||
pub fn add(a: u32, b: u32) -> u32 {
|
||||
a + b
|
||||
}
|
||||
|
||||
#[export]
|
||||
pub fn swap(a: u32, b: u32) -> (u32, u32) {
|
||||
(b, a)
|
||||
}
|
||||
|
||||
#[export]
|
||||
pub fn sort(mut list: Vec<u32>) -> Vec<u32> {
|
||||
list.sort();
|
||||
list
|
||||
}
|
||||
|
||||
#[export]
|
||||
pub fn print(string: String) {
|
||||
println!("to stdout: {}", string);
|
||||
eprintln!("to stderr: {}", string);
|
||||
}
|
||||
|
||||
// #[import]
|
||||
// fn mystery_number(input: u32) -> u32;
|
||||
|
||||
// #[export]
|
||||
// pub fn and_back(secret: u32) -> u32 {
|
||||
// mystery_number(secret)
|
||||
// }
|
Loading…
Add table
Add a link
Reference in a new issue