npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sometimes_youwin/gdnative-runtime-loader

v1.0.0

Published

Load dynamic libs at runtime for Godot 3

Downloads

2

Readme

GDNative Runtime Loader

Chat on Discord

Allows for runtime loading of GDNative libraries for Godot 3.4.x.

Useful for making parts of your game/application optional to users. An example of where this would be useful would be making a lip-sync library optional or using a mock library if it's not available.

Note

This script is really only useful for exported projects that wish to make some features optional. If possible, you should instead rely on CICD to package your game/app appropriately.

Limitations

  • The library must be exposed to Godot using GDNative
  • If a library is unloaded at runtime, your game/app will probably crash
  • The runtime loader must be used to interact with your library

Example

GDScript

runtime_loader = RuntimeLoader.new("res://example/plugins/" if OS.is_debug_build() else "")
	
runtime_loader.scan()

pinger = runtime_loader.create_class("pinger", "Pinger")
if pinger != null:
    print(pinger.ping())

config.ini

# Library metadata that's technically optional
# If omitted, defaults will be used, however it's generally better to be explicit
[General]
# These all map back to GDNativeLibrary resource properties
symbol_prefix="godot_"
reloadable=true
load_once=true
singleton=false
# Only use the following option if you are sure you need it
init_func_name="my_init_func"

# A section must exist for each target platform
# Target platform names map back to the names in a GDNativeLibrary resource
[Windows.64]
# The name of the library in the current folder
# In theory, this will also work in a nested folder as long as you provide a relative path
lib="rust.dll"

# All other sections are used to define classes in the library
[Pinger]
# This is the only field needed in order to generate a NativeScript resource
extends="Reference"

A full example is provided as a release. The ponger library is deliberately misconfigured in order to showcase error handling. It is trivial to fix. If you cannot figure out how to fix ponger's configuration, this addon is too advanced for you.

Quickstart

  1. Copy the addons/gdnative-runtime-library directory into your addons folder
  2. Create a plugins folder at your project root (next to your executable for exported projects)
  3. Create a new folder for each of your plugins
  4. Add a config.ini file for each plugin (e.g. plugins/my_gdnative_lib/config.ini)
  5. Fill out the config.ini (see the example project for an example. Note that the dlls are not checked into this repository, but you can download the exported release for a runnable example)
  6. Create a new gdnative_runtime_loader.gd file with an optional path arg (By default this searches for a plugins folder at your project root, but this can be customized)
  7. Call scan() in order to parse the libraries
  8. If your library has a custom init hook, you will need to pass those args now to the library (e.g. runtime_loader.libraries["my_lib"].add_init_arg(1)) to add an init arg 1 to a library called my_lib)
  9. Create classes defined in your library and use them in your game/app (e.g. runtime_loader.create_class("my_lib", "foo") to create a class called Foo from the my_lib library)