mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Reorganised plugin crates
This commit is contained in:
parent
05aee7df18
commit
780f54ac90
41
Cargo.lock
generated
41
Cargo.lock
generated
@ -727,13 +727,6 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "common-api"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "conrod_core"
|
name = "conrod_core"
|
||||||
version = "0.63.0"
|
version = "0.63.0"
|
||||||
@ -3753,15 +3746,6 @@ dependencies = [
|
|||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "plugin-api-derive"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.24",
|
|
||||||
"quote 1.0.7",
|
|
||||||
"syn 1.0.54",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "png"
|
name = "png"
|
||||||
version = "0.16.7"
|
version = "0.16.7"
|
||||||
@ -5558,7 +5542,6 @@ dependencies = [
|
|||||||
"arraygen",
|
"arraygen",
|
||||||
"authc",
|
"authc",
|
||||||
"bincode",
|
"bincode",
|
||||||
"common-api",
|
|
||||||
"criterion",
|
"criterion",
|
||||||
"crossbeam",
|
"crossbeam",
|
||||||
"csv",
|
"csv",
|
||||||
@ -5593,6 +5576,7 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
"tracy-client",
|
"tracy-client",
|
||||||
"vek 0.12.0",
|
"vek 0.12.0",
|
||||||
|
"veloren-plugin-api",
|
||||||
"wasmer-runtime",
|
"wasmer-runtime",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -5600,12 +5584,28 @@ dependencies = [
|
|||||||
name = "veloren-plugin-api"
|
name = "veloren-plugin-api"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
|
||||||
"common-api",
|
|
||||||
"plugin-api-derive",
|
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "veloren-plugin-derive"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 1.0.24",
|
||||||
|
"quote 1.0.7",
|
||||||
|
"syn 1.0.54",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "veloren-plugin-rt"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bincode",
|
||||||
|
"serde",
|
||||||
|
"veloren-plugin-api",
|
||||||
|
"veloren-plugin-derive",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "veloren-server"
|
name = "veloren-server"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
@ -5787,6 +5787,7 @@ dependencies = [
|
|||||||
"tracy-client",
|
"tracy-client",
|
||||||
"vek 0.12.0",
|
"vek 0.12.0",
|
||||||
"veloren-common",
|
"veloren-common",
|
||||||
|
"veloren-plugin-api",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -4,7 +4,9 @@ cargo-features = ["named-profiles","profile-overrides"]
|
|||||||
members = [
|
members = [
|
||||||
"common",
|
"common",
|
||||||
"common/sys",
|
"common/sys",
|
||||||
"common/common-api",
|
"plugin/rt",
|
||||||
|
"plugin/api",
|
||||||
|
"plugin/derive",
|
||||||
"client",
|
"client",
|
||||||
"plugin-api",
|
"plugin-api",
|
||||||
"server",
|
"server",
|
||||||
|
@ -66,7 +66,7 @@ tracy-client = { version = "0.9.0", optional = true }
|
|||||||
# Plugins
|
# Plugins
|
||||||
wasmer-runtime = "0.17.1"
|
wasmer-runtime = "0.17.1"
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
common-api = {path = "./common-api"}
|
plugin-api = { package = "veloren-plugin-api", path = "../plugin/api"}
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
#bench
|
#bench
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
option_zip
|
option_zip
|
||||||
)]
|
)]
|
||||||
|
|
||||||
pub extern crate common_api;
|
|
||||||
|
|
||||||
pub mod assets;
|
pub mod assets;
|
||||||
pub mod astar;
|
pub mod astar;
|
||||||
pub mod character;
|
pub mod character;
|
||||||
|
@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::{collections::{HashMap, HashSet}, fs, io::Read, path::{Path, PathBuf}};
|
use std::{collections::{HashMap, HashSet}, fs, io::Read, path::{Path, PathBuf}};
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
use common_api::Event;
|
use plugin_api::Event;
|
||||||
|
|
||||||
use self::{ errors::PluginError, module::{PluginModule, PreparedEventQuery}};
|
use self::{ errors::PluginError, module::{PluginModule, PreparedEventQuery}};
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use parking_lot::Mutex;
|
|||||||
use wasmer_runtime::*;
|
use wasmer_runtime::*;
|
||||||
|
|
||||||
use super::errors::{PluginError, PluginModuleError};
|
use super::errors::{PluginError, PluginModuleError};
|
||||||
use common_api::{Action, Event};
|
use plugin_api::{Action, Event};
|
||||||
|
|
||||||
// This represent a WASM function interface
|
// This represent a WASM function interface
|
||||||
pub type Function<'a> = Func<'a, (i32, u32), i32>;
|
pub type Function<'a> = Func<'a, (i32, u32), i32>;
|
||||||
|
@ -34,3 +34,6 @@ serde = { version = "1.0.110", features = ["derive"] }
|
|||||||
|
|
||||||
# Tracy
|
# Tracy
|
||||||
tracy-client = { version = "0.9.0", optional = true }
|
tracy-client = { version = "0.9.0", optional = true }
|
||||||
|
|
||||||
|
# Plugins
|
||||||
|
plugin-api = { package = "veloren-plugin-api", path = "../../plugin/api"}
|
||||||
|
@ -181,7 +181,7 @@ impl State {
|
|||||||
// Load plugins from asset directory
|
// Load plugins from asset directory
|
||||||
ecs.insert(match PluginMgr::from_assets() {
|
ecs.insert(match PluginMgr::from_assets() {
|
||||||
Ok(plugin_mgr) => {
|
Ok(plugin_mgr) => {
|
||||||
if let Err(e) = plugin_mgr.execute_event("on_load", &common::common_api::events::PluginLoadEvent {}) {
|
if let Err(e) = plugin_mgr.execute_event("on_load", &plugin_api::events::PluginLoadEvent {}) {
|
||||||
tracing::error!(?e, "Failed to run plugin init");
|
tracing::error!(?e, "Failed to run plugin init");
|
||||||
info!("Error occurred when loading plugins. Running without plugins instead.");
|
info!("Error occurred when loading plugins. Running without plugins instead.");
|
||||||
PluginMgr::default()
|
PluginMgr::default()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "common-api"
|
name = "veloren-plugin-api"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["ccgauche <gaucheron.laurent@gmail.com>"]
|
authors = ["ccgauche <gaucheron.laurent@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
@ -1,6 +1,5 @@
|
|||||||
use serde::{Serialize, de::DeserializeOwned, Deserialize};
|
use serde::{Serialize, de::DeserializeOwned, Deserialize};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Deserialize,Serialize,Debug)]
|
#[derive(Deserialize,Serialize,Debug)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
ServerClose,
|
ServerClose,
|
||||||
@ -14,9 +13,9 @@ pub trait Event: Serialize + DeserializeOwned{
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod events {
|
pub mod events {
|
||||||
|
|
||||||
use super::Event;
|
use super::Event;
|
||||||
use serde::{Serialize,Deserialize};
|
use serde::{Serialize,Deserialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct PlayerJoinEvent {
|
pub struct PlayerJoinEvent {
|
||||||
pub player_name: String,
|
pub player_name: String,
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "plugin-api-derive"
|
name = "veloren-plugin-derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["ccgauche <gaucheron.laurent@gmail.com>"]
|
authors = ["ccgauche <gaucheron.laurent@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
@ -16,11 +16,11 @@ pub fn export_function(_args: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
let out: proc_macro2::TokenStream = quote! {
|
let out: proc_macro2::TokenStream = quote! {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub fn #fn_name(intern__ptr: i32, intern__len: u32) -> i32 {
|
pub fn #fn_name(intern__ptr: i32, intern__len: u32) -> i32 {
|
||||||
let input = plugin_api::read_input(intern__ptr,intern__len).unwrap();
|
let input = plugin_rt::read_input(intern__ptr,intern__len).unwrap();
|
||||||
fn inner(#fn_args) #fn_return {
|
fn inner(#fn_args) #fn_return {
|
||||||
#fn_body
|
#fn_body
|
||||||
}
|
}
|
||||||
plugin_api::write_output(&inner(input))
|
plugin_rt::write_output(&inner(input))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
out.into()
|
out.into()
|
@ -16,27 +16,12 @@ version = "1.3.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "common-api"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hello"
|
name = "hello"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"veloren-plugin-api",
|
"veloren-plugin-api",
|
||||||
]
|
"veloren-plugin-rt",
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "plugin_proc"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -98,8 +83,24 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
|||||||
name = "veloren-plugin-api"
|
name = "veloren-plugin-api"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
|
||||||
"common-api",
|
|
||||||
"plugin_proc",
|
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "veloren-plugin-derive"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "veloren-plugin-rt"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bincode",
|
||||||
|
"serde",
|
||||||
|
"veloren-plugin-api",
|
||||||
|
"veloren-plugin-derive",
|
||||||
|
]
|
@ -8,6 +8,7 @@ edition = "2018"
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
plugin-api = { package = "veloren-plugin-api", path = ".." }
|
plugin-rt = { package = "veloren-plugin-rt", path = "../rt" }
|
||||||
|
plugin-api = { package = "veloren-plugin-api", path = "../api" }
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
@ -1,10 +1,12 @@
|
|||||||
use plugin_api::{*,events::*};
|
pub extern crate plugin_rt;
|
||||||
|
|
||||||
|
use plugin_rt::*;
|
||||||
|
use plugin_api::{Action, events::*};
|
||||||
|
|
||||||
#[export_function]
|
#[export_function]
|
||||||
pub fn on_load(load: PluginLoadEvent) -> () {
|
pub fn on_load(load: PluginLoadEvent) -> () {
|
||||||
send_actions(vec![Action::Print("This is a test".to_owned())]);
|
send_actions(vec![Action::Print("This is a test".to_owned())]);
|
||||||
println!("Hello world");
|
println!("Hello world");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[export_function]
|
#[export_function]
|
@ -1,13 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "veloren-plugin-api"
|
name = "veloren-plugin-rt"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Joshua Barretto <joshua.s.barretto@gmail.com>"]
|
authors = ["Joshua Barretto <joshua.s.barretto@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
common-api = { path = "../common/common-api" }
|
plugin-api = { package = "veloren-plugin-api", path = "../api" }
|
||||||
plugin-api-derive = { path = "./plugin-api-derive"}
|
plugin-derive = { package = "veloren-plugin-derive", path = "../derive"}
|
||||||
serde = {version = "1.0.118", features = ["derive"]}
|
serde = {version = "1.0.118", features = ["derive"]}
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
|
|
||||||
# spin = "0.7"
|
|
@ -1,12 +1,7 @@
|
|||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
|
|
||||||
|
pub use plugin_api as api;
|
||||||
pub extern crate plugin_api_derive;
|
pub use plugin_derive::*;
|
||||||
pub extern crate common_api;
|
|
||||||
|
|
||||||
pub use common_api::*;
|
|
||||||
|
|
||||||
pub use plugin_api_derive::*;
|
|
||||||
|
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
@ -15,7 +10,7 @@ extern "C" {
|
|||||||
fn send_action(ptr: *const u8, len: usize);
|
fn send_action(ptr: *const u8, len: usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_actions(action: Vec<Action>) {
|
pub fn send_actions(action: Vec<api::Action>) {
|
||||||
let ret = bincode::serialize(&action).unwrap();
|
let ret = bincode::serialize(&action).unwrap();
|
||||||
unsafe {
|
unsafe {
|
||||||
send_action(ret.as_ptr(), ret.len());
|
send_action(ret.as_ptr(), ret.len());
|
Loading…
Reference in New Issue
Block a user