mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Reworked veloren_dynlib initialisation
This commit is contained in:
parent
9fd5c6e124
commit
1612b36753
@ -91,18 +91,12 @@ pub type Bone = Transform<f32, f32, f32>;
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
lazy_static! {
|
||||
static ref LIB: Arc<Mutex<Option<LoadedLib>>> = Arc::new(Mutex::new(None));
|
||||
static ref LIB: Arc<Mutex<Option<LoadedLib>>> =
|
||||
voxygen_dynlib::init("veloren-voxygen-anim", "veloren-voxygen-anim-dyn", "anim");
|
||||
}
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
pub fn init() {
|
||||
voxygen_dynlib::init(
|
||||
Arc::clone(&LIB),
|
||||
"veloren-voxygen-anim",
|
||||
"veloren-voxygen-anim-dyn",
|
||||
"anim",
|
||||
);
|
||||
}
|
||||
pub fn init() { lazy_static::initialize(&LIB); }
|
||||
|
||||
pub trait Skeleton: Send + Sync + 'static {
|
||||
type Attr;
|
||||
|
@ -120,12 +120,11 @@ impl LoadedLib {
|
||||
/// This will search for the directory named `package_source_dir` and watch the
|
||||
/// files within it for any changes.
|
||||
pub fn init(
|
||||
lib_storage: Arc<Mutex<Option<LoadedLib>>>,
|
||||
package: &'static str,
|
||||
dyn_package: &'static str,
|
||||
package_source_dir: &'static str,
|
||||
) {
|
||||
*lib_storage.lock().unwrap() = Some(LoadedLib::compile_load(dyn_package));
|
||||
) -> Arc<Mutex<Option<LoadedLib>>> {
|
||||
let lib_storage = Arc::new(Mutex::new(Some(LoadedLib::compile_load(dyn_package))));
|
||||
|
||||
// TODO: use crossbeam
|
||||
let (reload_send, reload_recv) = mpsc::channel();
|
||||
@ -148,6 +147,7 @@ pub fn init(
|
||||
// Start reloader that watcher signals
|
||||
// "Debounces" events since I can't find the option to do this in the latest
|
||||
// `notify`
|
||||
let lib_storage_clone = Arc::clone(&lib_storage);
|
||||
std::thread::Builder::new()
|
||||
.name(format!("{}_hotreload_watcher", package))
|
||||
.spawn(move || {
|
||||
@ -164,13 +164,15 @@ pub fn init(
|
||||
"Hot reloading {} because files in `{}` modified.", package, package_source_dir
|
||||
);
|
||||
|
||||
hotreload(dyn_package, &lib_storage);
|
||||
hotreload(dyn_package, &lib_storage_clone);
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// Let the watcher live forever
|
||||
std::mem::forget(watcher);
|
||||
|
||||
lib_storage
|
||||
}
|
||||
|
||||
fn compiled_file(dyn_package: &str) -> String { dyn_lib_file(dyn_package, false) }
|
||||
|
@ -35,7 +35,8 @@ use {
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
lazy_static! {
|
||||
static ref LIB: Arc<Mutex<Option<LoadedLib>>> = Arc::new(Mutex::new(None));
|
||||
static ref LIB: Arc<Mutex<Option<LoadedLib>>> =
|
||||
voxygen_dynlib::init("veloren-voxygen-egui", "veloren-voxygen-egui-dyn", "egui");
|
||||
}
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
@ -103,14 +104,7 @@ pub struct EguiActions {
|
||||
}
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
pub fn init() {
|
||||
voxygen_dynlib::init(
|
||||
Arc::clone(&LIB),
|
||||
"veloren-voxygen-egui",
|
||||
"veloren-voxygen-egui-dyn",
|
||||
"egui",
|
||||
);
|
||||
}
|
||||
pub fn init() { lazy_static::initialize(&LIB); }
|
||||
|
||||
pub fn maintain(
|
||||
platform: &mut Platform,
|
||||
|
@ -19,8 +19,6 @@ use common::{
|
||||
clock::Clock,
|
||||
};
|
||||
use std::panic;
|
||||
#[cfg(any(feature = "hot-anim", feature = "hot-egui"))]
|
||||
use std::sync::Arc;
|
||||
use tracing::{error, info, warn};
|
||||
#[cfg(feature = "egui-ui")]
|
||||
use veloren_voxygen::ui::egui::EguiState;
|
||||
|
Loading…
Reference in New Issue
Block a user