Skip to content

Commit

Permalink
Merge pull request #86269 from aaronfranke/detect-module
Browse files Browse the repository at this point in the history
Allow detecting when building as an engine module
  • Loading branch information
akien-mga committed Jan 9, 2024
2 parents e9695d9 + 91b24b2 commit 079f1c1
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 20 deletions.
3 changes: 3 additions & 0 deletions modules/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Import("env")

env_modules = env.Clone()

# Allow modules to detect if they are being built as a module.
env_modules.Append(CPPDEFINES=["GODOT_MODULE"])

Export("env_modules")

# Header with MODULE_*_ENABLED defines.
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_adv/register_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#ifdef GDEXTENSION
#include <godot_cpp/core/class_db.hpp>
using namespace godot;
#else
#elif defined(GODOT_MODULE)
#include "modules/register_module_types.h"
#endif

Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_adv/script_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)

// Headers for building as built-in module.
#include "core/string/ustring.h"
Expand Down
8 changes: 4 additions & 4 deletions modules/text_server_adv/text_server_adv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using namespace godot;

#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get_setting_with_override(m_var)

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/config/project_settings.h"
Expand Down Expand Up @@ -370,7 +370,7 @@ bool TextServerAdvanced::_has_feature(Feature p_feature) const {
String TextServerAdvanced::_get_name() const {
#ifdef GDEXTENSION
return "ICU / HarfBuzz / Graphite (GDExtension)";
#else
#elif defined(GODOT_MODULE)
return "ICU / HarfBuzz / Graphite (Built-in)";
#endif
}
Expand Down Expand Up @@ -4852,7 +4852,7 @@ RID TextServerAdvanced::_find_sys_font_for_text(const RID &p_fdef, const String
#ifdef GDEXTENSION
for (int fb = 0; fb < fallback_font_name.size(); fb++) {
const String &E = fallback_font_name[fb];
#else
#elif defined(GODOT_MODULE)
for (const String &E : fallback_font_name) {
#endif
SystemFontKey key = SystemFontKey(E, font_style & TextServer::FONT_ITALIC, font_weight, font_stretch, p_fdef, this);
Expand Down Expand Up @@ -6757,7 +6757,7 @@ String TextServerAdvanced::_strip_diacritics(const String &p_string) const {
if (u_getCombiningClass(normalized_string[i]) == 0) {
#ifdef GDEXTENSION
result = result + String::chr(normalized_string[i]);
#else
#elif defined(GODOT_MODULE)
result = result + normalized_string[i];
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_adv/text_server_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/extension/ext_wrappers.gen.inc"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_adv/thorvg_bounds_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/typedefs.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_adv/thorvg_bounds_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/typedefs.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_adv/thorvg_svg_in_ot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/error/error_macros.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_adv/thorvg_svg_in_ot.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/os/mutex.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_fb/register_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#ifdef GDEXTENSION
#include <godot_cpp/core/class_db.hpp>
using namespace godot;
#else
#elif defined(GODOT_MODULE)
#include "modules/register_module_types.h"
#endif

Expand Down
6 changes: 3 additions & 3 deletions modules/text_server_fb/text_server_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using namespace godot;

#define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get_setting_with_override(m_var)

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/config/project_settings.h"
Expand Down Expand Up @@ -95,7 +95,7 @@ bool TextServerFallback::_has_feature(Feature p_feature) const {
String TextServerFallback::_get_name() const {
#ifdef GDEXTENSION
return "Fallback (GDExtension)";
#else
#elif defined(GODOT_MODULE)
return "Fallback (Built-in)";
#endif
}
Expand Down Expand Up @@ -3654,7 +3654,7 @@ RID TextServerFallback::_find_sys_font_for_text(const RID &p_fdef, const String
#ifdef GDEXTENSION
for (int fb = 0; fb < fallback_font_name.size(); fb++) {
const String &E = fallback_font_name[fb];
#else
#elif defined(GODOT_MODULE)
for (const String &E : fallback_font_name) {
#endif
SystemFontKey key = SystemFontKey(E, font_style & TextServer::FONT_ITALIC, font_weight, font_stretch, p_fdef, this);
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_fb/text_server_fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/extension/ext_wrappers.gen.inc"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_fb/thorvg_bounds_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/typedefs.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_fb/thorvg_bounds_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/typedefs.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_fb/thorvg_svg_in_ot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/error/error_macros.h"
Expand Down
2 changes: 1 addition & 1 deletion modules/text_server_fb/thorvg_svg_in_ot.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

using namespace godot;

#else
#elif defined(GODOT_MODULE)
// Headers for building as built-in module.

#include "core/os/mutex.h"
Expand Down

0 comments on commit 079f1c1

Please sign in to comment.