Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow manual unloading/reloading of GDNative/GDExtention lib files (DLL, etc) #5324

Closed
Tracked by #66231
greenfox1505 opened this issue Sep 4, 2022 · 1 comment
Closed
Tracked by #66231

Comments

@greenfox1505
Copy link

greenfox1505 commented Sep 4, 2022

Describe the project you are working on

I am currently working on a plugin for managing my Rust project within the editor.

Describe the problem or limitation you are having in your project

My plugin is a EditorPlugin with a build() function. That build() function calls my compile script for my DLL(s). However, when the compile completes and it tries to overwrite the old DLL, Godot still has them loaded and it can't write to them. Unfocusing the Godot Editor window and running the compile script outside of Godot allows it to complete correctly.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add the ablity for a GDNative/GDExtention to be manually disabled/unloaded with GDScript. Perhaps adding a property likeGDNativeLibrary.loaded:bool that can be set to false. Or add unload() and reload() functions.

I haven't used Godot4+GDExtention yet. I don't know if this problem occurs with the new architecture.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

tool
extends EditorPlugin

var buildableLib:GDNativeLibrary = load("res://myLib.gdnlib")

func build():
	buildableLib.unload() #new function
	var array = []
	var i = OS.execute("bash",["compileScript.sh"],true,array,true)
	print(array)
	buildableLib.reload() #new function
	return i == 0:

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

At present, it is not possible to update any code that compiles down to a DLL while Godot Editor has window focus.
For other languages to ever be editable within Godot Editor, like what I'm building, core functionality of manually unloading before they can be compiled is needed.

@Bromeon
Copy link

Bromeon commented Sep 7, 2024

Add the ablity for a GDNative/GDExtention to be manually disabled/unloaded with GDScript. Perhaps adding a property likeGDNativeLibrary.loaded:bool that can be set to false. Or add unload() and reload() functions.

In GDExtension, this can be achieved with the GDExtensionManager API, which has methods to load/reload/unload individual extensions. In addition, hot-reloading has been implemented in godotengine/godot#80284, so that the Godot editor automatically picks up new DLL versions.

As such, I think what you want is now possible.

@Bromeon Bromeon closed this as completed Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants