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

[GDExtension] Add config option to specify custom library lookup paths. #88049

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Feb 7, 2024

Fixes #87761

Add an optional lookup_paths GDExtension config file parameter to specify a list of custom library lookup paths. Paths can be relative res:// path, absolute path, or relative to the other special project locations (bundle_dir://, pck_dir://, exe_dir://).

In case of #87761, the issue can be resolved by adding this line to the config:

 compatibility_minimum = "4.1"
+lookup_paths = [ ""pck_dir://" ]

 [libraries]

@bruvzg bruvzg added this to the 4.x milestone Feb 7, 2024
@bruvzg bruvzg force-pushed the gde_custom_load_path branch 2 times, most recently from e6711f8 to c0c81e1 Compare February 7, 2024 09:38
@bruvzg bruvzg force-pushed the gde_custom_load_path branch from c0c81e1 to ba6959f Compare February 7, 2024 10:16
@bruvzg bruvzg marked this pull request as ready for review February 7, 2024 11:11
@bruvzg bruvzg requested review from a team as code owners February 7, 2024 11:11
@@ -35,6 +35,7 @@
#include "core/object/method_bind.h"
#include "core/os/os.h"
#include "core/version.h"
#include "gdextension.compat.inc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To follow current include conventions, this should be:

#include "gdextension.h"
#include "gdextension.compat.inc"

#include "core/config/project_settings.h"
#include "core/extension/gdextension_manager.h"
#include "core/io/dir_access.h"
#include "core/object/class_db.h"
#include "core/object/method_bind.h"
#include "core/os/os.h"
#include "core/version.h"

@@ -43,6 +43,7 @@
<return type="int" enum="Error" />
<param index="0" name="path" type="String" />
<param index="1" name="entry_symbol" type="String" />
<param index="2" name="lookup_paths" type="PackedStringArray" default="PackedStringArray()" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to document it.

@akien-mga
Copy link
Member

CC @godotengine/gdextension


#ifndef DISABLE_DEPRECATED

#include "gdextension.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary

Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This makes sense to me at a high-level. My main concern is just being sure that we want to expose these particular paths and their names.

For example: Will developers understand what bundle_dir:// is (I'm not totally sure I understand what it is :-))? Will they understand how pck_dir:// is different than exe_dir://?

Comment on lines +39 to +41
void GDExtension::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("open_library", "path", "entry_symbol"), &GDExtension::_open_library_bind_compat_88049);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer necessary. After PR #88418, GDExtension::open_library() isn't exposed anymore.

Comment on lines +724 to +726
lookup_dir = lookup_dir.begins_with("pck_dir://") ? lookup_dir.replace_first("pck_dir:/", ProjectSettings::get_singleton()->get_main_pack_path()) : lookup_dir;
lookup_dir = lookup_dir.begins_with("bundle_dir://") ? lookup_dir.replace_first("bundle_dir:/", OS::get_singleton()->get_bundle_resource_dir()) : lookup_dir;
lookup_dir = lookup_dir.begins_with("exe_dir://") ? lookup_dir.replace_first("exe_dir:/", OS::get_singleton()->get_executable_path().get_base_dir()) : lookup_dir;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to replace this with the custom path mapping from PR #87586 after that is merged, so that these paths aren't exclusive to GDExtension loading. Perhaps a TODO should be added here?

Also, are we sure we want to commit to these specific prefix names? Not that I want to spend lots of time bike-shedding the names :-) but we will be committing to them as part of our external API, so they probably should go through a little bit wider discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GDExtension library files won't load in a folder separate from the Godot executable
4 participants