Skip to content

Commit 3239868

Browse files
authored
Remove hot reloader (#18)
1 parent 928159e commit 3239868

File tree

11 files changed

+28
-694
lines changed

11 files changed

+28
-694
lines changed

Cargo.lock

Lines changed: 6 additions & 326 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ edition = "2021"
1111

1212
[workspace.dependencies]
1313
godot = { git = "https://github.com/titannano/gdext", rev = "a5d17342b7b47e8af652a6a733f497c468bbd59a" }
14-
hot-lib-reloader = "0.6.5"
1514
itertools = "0.10.3"
1615
abi_stable = { version = "0.11.2", default-features = false }
1716
rand = "0.8.5"
18-
cfg-if = "1.0.0"
1917
darling = { version = "0.20.3" }
2018
proc-macro2 = "1.0.68"
2119
quote = "1.0.33"
2220
syn = "2.0.38"
23-
process_path = "0.1"
2421

2522
godot-rust-script-derive = { path = "derive" }
2623
tests-scripts-lib = { path = "tests-scripts-lib" }

rust-script/Cargo.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@ edition.workspace = true
88
[dependencies]
99
godot.workspace = true
1010
abi_stable.workspace = true
11-
cfg-if.workspace = true
1211

13-
hot-lib-reloader = { workspace = true, optional = true }
1412
itertools = { workspace = true, optional = true }
1513
rand = { workspace = true, optional = true }
16-
process_path = { workspace = true, optional = true }
1714

1815
godot-rust-script-derive = { workspace = true, optional = true }
1916

2017
[dev-dependencies]
21-
tests-scripts-lib = { path = "../tests-scripts-lib", features = ["test-hot-reload"] }
18+
tests-scripts-lib = { path = "../tests-scripts-lib" }
2219
godot-rust-script = { path = "./", features = ["runtime"] }
2320

2421
[features]
25-
default = ["hot-reload"]
26-
hot-reload = ["dep:process_path", "dep:hot-lib-reloader"]
22+
default = []
2723
runtime = ["dep:itertools", "dep:rand"]
28-
scripts = ["dep:godot-rust-script-derive"]
24+
scripts = ["dep:godot-rust-script-derive"]

rust-script/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ pub use runtime::*;
1616
pub use godot_rust_script_derive::{godot_script_impl, GodotScript};
1717

1818
pub mod private_export {
19-
pub use super::{script_registry::RemoteVariantType, shared::BindingInit};
19+
pub use super::script_registry::RemoteVariantType;
2020
pub use abi_stable::std_types::{RStr, RString, RVec};
2121
pub use godot::sys::{plugin_add, plugin_registry};
22-
23-
#[cfg(all(feature = "hot-reload", debug_assertions))]
24-
pub use hot_lib_reloader::{self, hot_module};
2522
}
2623

2724
pub use godot;

rust-script/src/library.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,10 @@ macro_rules! setup_library {
5858
$crate::private_export::plugin_registry!(pub __SCRIPT_REGISTRY: $crate::RegistryItem);
5959

6060
#[no_mangle]
61-
pub fn __godot_rust_script_init(binding: Option<$crate::private_export::BindingInit>) -> $crate::private_export::RVec<$crate::RemoteScriptMetaData> {
61+
pub fn __godot_rust_script_init() -> $crate::private_export::RVec<$crate::RemoteScriptMetaData> {
6262
use $crate::private_export::*;
6363
use $crate::godot::obj::EngineEnum;
6464

65-
if let Some(init) = binding {
66-
let config = $crate::godot::sys::GdextConfig {
67-
tool_only_in_editor: false,
68-
is_editor: ::std::cell::OnceCell::new(),
69-
};
70-
71-
unsafe {
72-
$crate::godot::sys::init_with_existing_binding(init);
73-
}
74-
}
75-
7665
let lock = __godot_rust_plugin___SCRIPT_REGISTRY.lock().expect("unable to aquire mutex lock");
7766

7867
$crate::assemble_metadata(lock.iter())

rust-script/src/runtime/hot_reloader.rs

Lines changed: 0 additions & 141 deletions
This file was deleted.

rust-script/src/runtime/mod.rs

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#[cfg(all(feature = "hot-reload", debug_assertions))]
2-
mod hot_reloader;
31
mod metadata;
42
mod resource_loader;
53
mod resource_saver;
@@ -9,7 +7,6 @@ mod rust_script_language;
97

108
use std::{collections::HashMap, rc::Rc, sync::RwLock};
119

12-
use cfg_if::cfg_if;
1310
use godot::{
1411
engine::{Engine, ResourceLoader, ResourceSaver},
1512
prelude::{godot_print, Gd},
@@ -25,35 +22,6 @@ use crate::{
2522

2623
use self::rust_script_language::RustScriptLanguage;
2724

28-
#[cfg(all(feature = "hot-reload", debug_assertions))]
29-
use hot_reloader::{HotReloadEntry, HotReloader};
30-
31-
#[cfg(all(feature = "hot-reload", debug_assertions))]
32-
#[macro_export]
33-
macro_rules! setup {
34-
($lib_crate:tt) => {
35-
#[$crate::private_export::hot_module(dylib = stringify!($lib_crate), lib_dir=process_path::get_dylib_path().and_then(|path| path.parent().map(std::path::Path::to_path_buf)).unwrap_or_default())]
36-
mod scripts_lib {
37-
use $crate::private_export::RVec;
38-
39-
// manually expose functions.
40-
#[hot_functions]
41-
extern "Rust" {
42-
pub fn __godot_rust_script_init(
43-
binding: Option<$crate::private_export::BindingInit>,
44-
) -> RVec<$crate::RemoteScriptMetaData>;
45-
}
46-
47-
// expose a type to subscribe to lib load events
48-
#[lib_change_subscription]
49-
pub fn subscribe() -> hot_lib_reloader::LibReloadObserver {}
50-
51-
pub use ::$lib_crate::__GODOT_RUST_SCRIPT_SRC_ROOT;
52-
}
53-
};
54-
}
55-
56-
#[cfg(not(all(feature = "hot-reload", debug_assertions)))]
5725
#[macro_export]
5826
macro_rules! setup {
5927
($lib_crate:tt) => {
@@ -63,7 +31,6 @@ macro_rules! setup {
6331
};
6432
}
6533

66-
#[cfg(not(all(feature = "hot-reload", debug_assertions)))]
6734
#[macro_export]
6835
macro_rules! init {
6936
() => {
@@ -74,28 +41,8 @@ macro_rules! init {
7441
};
7542
}
7643

77-
#[cfg(all(feature = "hot-reload", debug_assertions))]
78-
#[macro_export]
79-
macro_rules! init {
80-
() => {
81-
$crate::RustScriptExtensionLayer::new(
82-
scripts_lib::__godot_rust_script_init,
83-
scripts_lib::__GODOT_RUST_SCRIPT_SRC_ROOT,
84-
scripts_lib::subscribe,
85-
)
86-
};
87-
}
88-
8944
thread_local! {
9045
static SCRIPT_REGISTRY: RwLock<HashMap<String, ScriptMetaData>> = RwLock::default();
91-
#[cfg(all(feature = "hot-reload", debug_assertions))]
92-
static HOT_RELOAD_BRIDGE: std::cell::RefCell<HashMap<rust_script_instance::RustScriptInstanceId, std::cell::RefCell<HotReloadEntry>>> = std::cell::RefCell::default();
93-
}
94-
95-
cfg_if! {
96-
if #[cfg(all(feature = "hot-reload", debug_assertions))] {
97-
type HotReloadSubscribe = fn() -> hot_lib_reloader::LibReloadObserver;
98-
}
9946
}
10047

10148
pub struct RustScriptExtensionLayer {
@@ -104,33 +51,19 @@ pub struct RustScriptExtensionLayer {
10451
res_saver: Option<Gd<RustScriptResourceSaver>>,
10552
res_loader: Option<Gd<RustScriptResourceLoader>>,
10653
scripts_src_dir: Option<&'static str>,
107-
108-
#[cfg(all(feature = "hot-reload", debug_assertions))]
109-
hot_reload_subscribe: HotReloadSubscribe,
110-
111-
#[cfg(all(feature = "hot-reload", debug_assertions))]
112-
hot_reloader: Option<Gd<HotReloader>>,
11354
}
11455

11556
impl RustScriptExtensionLayer {
11657
pub fn new<F: RustScriptLibInit + 'static + Clone>(
11758
lib_init_fn: F,
11859
scripts_src_dir: &'static str,
119-
#[cfg(all(feature = "hot-reload", debug_assertions))]
120-
hot_reload_subscribe: HotReloadSubscribe,
12160
) -> Self {
12261
Self {
12362
lib_init_fn: Rc::new(lib_init_fn),
12463
lang: None,
12564
res_saver: None,
12665
res_loader: None,
12766
scripts_src_dir: Some(scripts_src_dir),
128-
129-
#[cfg(all(feature = "hot-reload", debug_assertions))]
130-
hot_reload_subscribe,
131-
132-
#[cfg(all(feature = "hot-reload", debug_assertions))]
133-
hot_reloader: None,
13467
}
13568
}
13669

@@ -141,18 +74,6 @@ impl RustScriptExtensionLayer {
14174
let res_loader = RustScriptResourceLoader::new(lang.clone());
14275
let res_saver = Gd::from_object(RustScriptResourceSaver);
14376

144-
cfg_if! {
145-
if #[cfg(all(feature = "hot-reload", debug_assertions))] {
146-
use godot::prelude::StringName;
147-
148-
let mut hot_reloader = Gd::from_init_fn(|base| HotReloader::new((self.hot_reload_subscribe)(), self.lib_init_fn.clone(), base));
149-
150-
hot_reloader.call_deferred(StringName::from("register"), &[]);
151-
152-
self.hot_reloader = Some(hot_reloader);
153-
}
154-
}
155-
15677
self.lang = Some(lang.clone());
15778
self.res_saver = Some(res_saver.clone());
15879
self.res_loader = Some(res_loader.clone());
@@ -186,15 +107,7 @@ impl RustScriptExtensionLayer {
186107
}
187108

188109
fn load_rust_scripts(lib_init_fn: Rc<dyn RustScriptLibInit>) {
189-
cfg_if! {
190-
if #[cfg(all(feature = "hot-reload", debug_assertions))] {
191-
let ffi_init = Some(unsafe { godot::sys::get_binding() });
192-
} else {
193-
let ffi_init = None;
194-
}
195-
}
196-
197-
let result = lib_init_fn(ffi_init);
110+
let result = lib_init_fn();
198111

199112
let registry: HashMap<String, ScriptMetaData> = result
200113
.into_iter()

0 commit comments

Comments
 (0)