Add build.rs to rebuild plugins, and a test plugin

This commit is contained in:
Isaac Clayton 2022-06-10 18:41:43 +02:00
parent 5b40734f80
commit 8aef8ab259
8 changed files with 163 additions and 11 deletions

7
plugins/Cargo.lock generated
View file

@ -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"

View file

@ -1,2 +1,2 @@
[workspace]
members = ["./json_language"]
members = ["./json_language", "./test_plugin"]

View file

@ -0,0 +1,10 @@
[package]
name = "test_plugin"
version = "0.1.0"
edition = "2021"
[dependencies]
plugin = { path = "../../crates/plugin" }
[lib]
crate-type = ["cdylib"]

View 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)
// }