Skip to content

Commit 47233df

Browse files
kisgRepiteoAThousandShips
committed
Apply suggestions from code review
Co-authored-by: Thaddeus Crews <[email protected]> Co-authored-by: A Thousand Ships <[email protected]>
1 parent 8dd8d9a commit 47233df

18 files changed

+49
-59
lines changed

SConstruct

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,6 @@ if not env["platform"]:
356356
if env["platform"]:
357357
print(f"Automatically detected platform: {env['platform']}")
358358

359-
# Library Support
360-
if env["library_type"] != "executable":
361-
if env["platform"] not in ["linuxbsd", "macos", "windows"]:
362-
print_error(f"Library builds not yet supported for {env['platform']}")
363-
Exit(255)
364-
env.Append(CPPDEFINES=["LIBGODOT_ENABLED"])
365-
366359
# Deprecated aliases kept for compatibility.
367360
if env["platform"] in compatibility_platform_aliases:
368361
alias = env["platform"]
@@ -571,6 +564,13 @@ if not env["deprecated"]:
571564
if env["precision"] == "double":
572565
env.Append(CPPDEFINES=["REAL_T_IS_DOUBLE"])
573566

567+
# Library Support
568+
if env["library_type"] != "executable":
569+
if "library" not in env.get("supported", []):
570+
print_error(f"Library builds unsupported for {env['platform']}")
571+
Exit(255)
572+
env.Append(CPPDEFINES=["LIBGODOT_ENABLED"])
573+
574574
# Default num_jobs to local cpu count if not user specified.
575575
# SCons has a peculiarity where user-specified options won't be overridden
576576
# by SetOption, so we can rely on this to know if we should use our default.

core/extension/gdextension_function_loader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
/**************************************************************************/
3030

3131
#include "gdextension_function_loader.h"
32+
3233
#include "gdextension.h"
3334

3435
Error GDExtensionFunctionLoader::open_library(const String &p_path) {
@@ -47,8 +48,7 @@ Error GDExtensionFunctionLoader::initialize(GDExtensionInterfaceGetProcAddress p
4748
if (ret) {
4849
return OK;
4950
} else {
50-
ERR_PRINT("GDExtension initialization function for '" + library_path + "' returned an error.");
51-
return FAILED;
51+
ERR_FAIL_V_MSG(FAILED, "GDExtension initialization function for '" + library_path + "' returned an error.");
5252
}
5353
}
5454

core/extension/gdextension_function_loader.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,16 @@ class GDExtensionFunctionLoader : public GDExtensionLoader {
3939
friend class GDExtensionManager;
4040
friend class GDExtension;
4141

42-
private:
4342
String library_path;
4443
GDExtensionInitializationFunction initialization_function = nullptr;
4544

4645
public:
47-
Error open_library(const String &p_path) override;
46+
virtual Error open_library(const String &p_path) override;
4847
Error initialize(GDExtensionInterfaceGetProcAddress p_get_proc_address, const Ref<GDExtension> &p_extension, GDExtensionInitialization *r_initialization) override;
4948
void close_library() override;
5049
bool is_library_open() const override;
5150
bool has_library_changed() const override;
5251
bool library_exists() const override;
5352

54-
void set_initialization_function(GDExtensionInitializationFunction initialization_function);
53+
void set_initialization_function(GDExtensionInitializationFunction p_initialization_function);
5554
};

core/extension/gdextension_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ GDExtensionManager::LoadStatus GDExtensionManager::load_extension(const String &
121121
GDExtensionManager::LoadStatus GDExtensionManager::load_extension_from_function(const String &p_path, GDExtensionConstPtr<const GDExtensionInitializationFunction> p_init_func) {
122122
Ref<GDExtensionFunctionLoader> func_loader;
123123
func_loader.instantiate();
124-
func_loader->set_initialization_function((GDExtensionInitializationFunction) * (p_init_func.data));
124+
func_loader->set_initialization_function((GDExtensionInitializationFunction)*p_init_func.data);
125125
return load_extension_with_loader(p_path, func_loader);
126126
}
127127

core/extension/godot_instance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
/**************************************************************************/
3030

3131
#include "godot_instance.h"
32+
3233
#include "core/extension/gdextension_manager.h"
3334
#include "main/main.h"
3435
#include "servers/display_server.h"

core/extension/godot_instance.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232

3333
#include "core/extension/gdextension_interface.h"
3434
#include "core/object/class_db.h"
35-
#include "core/object/object.h"
3635

3736
class GodotInstance : public Object {
3837
GDCLASS(GodotInstance, Object);
3938

40-
static void _bind_methods();
41-
4239
bool started = false;
4340

41+
protected:
42+
static void _bind_methods();
43+
4444
public:
4545
GodotInstance();
4646
~GodotInstance();

doc/classes/GDExtensionManager.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<param index="0" name="path" type="String" />
4545
<param index="1" name="init_func" type="const GDExtensionInitializationFunction*" />
4646
<description>
47-
Loads an already-in-address-space extension by unique name and initialization function. The [param path] needs to be unique and start with libgodot://. Returns [constant LOAD_STATUS_OK] if successful.
47+
Loads an extension already in address space by unique name and initialization function. The [param path] needs to be unique and start with libgodot://. Returns [constant LOAD_STATUS_OK] if successful.
4848
</description>
4949
</method>
5050
<method name="reload_extension">

doc/classes/GodotInstance.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Provides access to an embedded Godot instance.
55
</brief_description>
66
<description>
7-
GodotInstance represents a running Godot instance that is controlled from an outside codebase, without a perpetual main loop. It is created by the C API libgodot_create_godot_instance. Only one may be created per process.
7+
GodotInstance represents a running Godot instance that is controlled from an outside codebase, without a perpetual main loop. It is created by the C API [code]libgodot_create_godot_instance[/code]. Only one may be created per process.
88
</description>
99
<tutorials>
1010
</tutorials>
@@ -24,13 +24,13 @@
2424
<method name="is_started">
2525
<return type="bool" />
2626
<description>
27-
Returns true if this instance has been fully started.
27+
Returns [code]true[/code] if this instance has been fully started.
2828
</description>
2929
</method>
3030
<method name="iteration">
3131
<return type="bool" />
3232
<description>
33-
Runs a single iteration of the main loop. Returns true if the engine is attempting to quit.
33+
Runs a single iteration of the main loop. Returns [code]true[/code] if the engine is attempting to quit.
3434
</description>
3535
</method>
3636
<method name="pause">
@@ -48,7 +48,7 @@
4848
<method name="start">
4949
<return type="bool" />
5050
<description>
51-
Finishes this instance's startup sequence. Returns true on success.
51+
Finishes this instance's startup sequence. Returns [code]true[/code] on success.
5252
</description>
5353
</method>
5454
</methods>

methods.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def redirect_emitter(target, source, env):
8888
Emitter to automatically redirect object/library build files to the `bin/obj` directory,
8989
retaining subfolder structure. External build files will attempt to retain subfolder
9090
structure relative to their environment's parent directory, sorted under `bin/obj/external`.
91-
If `redirect_build_objects` is `False`, or an external build file isn't relative to the
92-
passed environment, or a file is being written directly into `bin`, this emitter does nothing.
91+
If `redirect_build_objects` is `False`, an external build file isn't relative to the passed
92+
environment, or a file is being written directly into `bin`, this emitter does nothing.
9393
"""
9494
if not env["redirect_build_objects"]:
9595
return target, source

platform/linuxbsd/SCsub

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ common_linuxbsd = [
1313
"freedesktop_at_spi_monitor.cpp",
1414
]
1515

16-
libgodot_files = [
17-
"libgodot_linuxbsd.cpp",
18-
]
19-
20-
executable_files = ["godot_linuxbsd.cpp"]
16+
if env["library_type"] == "executable":
17+
common_linuxbsd += ["godot_linuxbsd.cpp"]
18+
else:
19+
common_linuxbsd += ["libgodot_linuxbsd.cpp"]
2120

2221
if env["use_sowrap"]:
2322
common_linuxbsd.append("xkbcommon-so_wrap.c")
@@ -42,12 +41,12 @@ if env["dbus"]:
4241
common_linuxbsd.append("dbus-so_wrap.c")
4342

4443
if env["library_type"] == "static_library":
45-
prog = env.add_library("#bin/godot", common_linuxbsd + libgodot_files)
44+
prog = env.add_library("#bin/godot", common_linuxbsd)
4645
elif env["library_type"] == "shared_library":
4746
env.Append(CCFLAGS=["-fPIC"])
48-
prog = env.add_shared_library("#bin/godot", common_linuxbsd + libgodot_files)
47+
prog = env.add_shared_library("#bin/godot", common_linuxbsd)
4948
else:
50-
prog = env.add_program("#bin/godot", common_linuxbsd + executable_files)
49+
prog = env.add_program("#bin/godot", common_linuxbsd)
5150

5251
if env["debug_symbols"] and env["separate_debug_symbols"]:
5352
env.AddPostAction(prog, env.Run(platform_linuxbsd_builders.make_debug_linuxbsd))

0 commit comments

Comments
 (0)