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

Fix #if *_ENABLED inconsistencies, should check if defined #87286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/input/input_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def make_default_controller_mappings(target, source, env):
platform_mappings[current_platform][guid] = line

platform_variables = {
"Linux": "#if LINUXBSD_ENABLED",
"Linux": "#ifdef LINUXBSD_ENABLED",
"Windows": "#ifdef WINDOWS_ENABLED",
"Mac OS X": "#ifdef MACOS_ENABLED",
"Android": "#if defined(__ANDROID__)",
"Android": "#ifdef ANDROID_ENABLED",
Copy link
Member Author

Choose a reason for hiding this comment

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

I added this, which is the only functional change in this PR.
I couldn't see a reason why this one used a compiler-provided macro instead of our own like other platforms.

I guess at the time it was authored we might not have had an ANDROID_ENABLED define yet? Or it was just an oversight.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did a quick blame trip, seems like this was added in 40b0c55 as is, but that was copied from the defines used at the time in main/input_default.cpp. And those date back to af633c7, which already had the ANDROID_ENABLED define, so I think this was just an oversight.

Copy link
Contributor

@YuriSizov YuriSizov Jan 17, 2024

Choose a reason for hiding this comment

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

which already had the ANDROID_ENABLED define

Well, we had it since GODOT IS OPEN SOURCE, so I think your assessment is correct. It's strange, because it's inconsistent, but you'd have to ask Ariel about it, because it originates from 0d80726. 🙃

"iOS": "#ifdef IOS_ENABLED",
"Web": "#ifdef WEB_ENABLED",
}
Expand Down
2 changes: 1 addition & 1 deletion main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
OS::get_singleton()->print(" --gpu-profile Show a GPU profile of the tasks that took the most time during frame rendering.\n");
OS::get_singleton()->print(" --gpu-validation Enable graphics API validation layers for debugging.\n");
#if DEBUG_ENABLED
#ifdef DEBUG_ENABLED
OS::get_singleton()->print(" --gpu-abort Abort on graphics API usage errors (usually validation layer errors). May help see the problem if your system freezes.\n");
#endif
OS::get_singleton()->print(" --generate-spirv-debug-info Generate SPIR-V debug information. This allows source-level shader debugging with RenderDoc.\n");
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_byte_codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator {
RBMap<MethodBind *, int> method_bind_map;
RBMap<GDScriptFunction *, int> lambdas_map;

#if DEBUG_ENABLED
#ifdef DEBUG_ENABLED
// Keep method and property names for pointer and validated operations.
// Used when disassembling the bytecode.
Vector<String> operator_names;
Expand Down
6 changes: 3 additions & 3 deletions modules/mono/csharp_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
}
// The script instance could not be instantiated or wasn't in the list of placeholders to replace.
obj->set_script(scr);
#if DEBUG_ENABLED
#ifdef DEBUG_ENABLED
// If we reached here, the instantiated script must be a placeholder.
CRASH_COND(!obj->get_script_instance()->is_placeholder());
#endif
Expand Down Expand Up @@ -2310,7 +2310,7 @@ void CSharpScript::reload_registered_script(Ref<CSharpScript> p_script) {

p_script->_update_exports();

#if TOOLS_ENABLED
#ifdef TOOLS_ENABLED
// If the EditorFileSystem singleton is available, update the file;
// otherwise, the file will be updated when the singleton becomes available.
EditorFileSystem *efs = EditorFileSystem::get_singleton();
Expand Down Expand Up @@ -2666,7 +2666,7 @@ Error CSharpScript::reload(bool p_keep_state) {

_update_exports();

#if TOOLS_ENABLED
#ifdef TOOLS_ENABLED
// If the EditorFileSystem singleton is available, update the file;
// otherwise, the file will be updated when the singleton becomes available.
EditorFileSystem *efs = EditorFileSystem::get_singleton();
Expand Down
2 changes: 1 addition & 1 deletion modules/mono/glue/runtime_interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void godotsharp_internal_new_csharp_script(Ref<CSharpScript> *r_dest) {
}

void godotsharp_internal_editor_file_system_update_file(const String *p_script_path) {
#if TOOLS_ENABLED
#ifdef TOOLS_ENABLED
// If the EditorFileSystem singleton is available, update the file;
// otherwise, the file will be updated when the singleton becomes available.
EditorFileSystem *efs = EditorFileSystem::get_singleton();
Expand Down
2 changes: 1 addition & 1 deletion modules/mono/utils/path_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ String realpath(const String &p_path) {
}

return result.simplify_path();
#elif UNIX_ENABLED
#elif defined(UNIX_ENABLED)
char *resolved_path = ::realpath(p_path.utf8().get_data(), nullptr);

if (!resolved_path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "openxr_fb_update_swapchain_extension.h"

// always include this as late as possible
// Always include this as late as possible.
#include "../openxr_platform_inc.h"

OpenXRFBUpdateSwapchainExtension *OpenXRFBUpdateSwapchainExtension::singleton = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions modules/openxr/extensions/openxr_opengl_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#include "core/templates/vector.h"

// always include this as late as possible
// Always include this as late as possible.
#include "../openxr_platform_inc.h"

class OpenXROpenGLExtension : public OpenXRGraphicsExtensionWrapper {
Expand All @@ -65,9 +65,9 @@ class OpenXROpenGLExtension : public OpenXRGraphicsExtensionWrapper {

#ifdef WIN32
static XrGraphicsBindingOpenGLWin32KHR graphics_binding_gl;
#elif ANDROID_ENABLED
#elif defined(ANDROID_ENABLED)
static XrGraphicsBindingOpenGLESAndroidKHR graphics_binding_gl;
#else
#else // Linux/X11
static XrGraphicsBindingOpenGLXlibKHR graphics_binding_gl;
#endif

Expand Down
2 changes: 1 addition & 1 deletion modules/openxr/extensions/openxr_vulkan_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include "core/templates/vector.h"

// always include this as late as possible
// Always include this as late as possible.
#include "../openxr_platform_inc.h"

class OpenXRVulkanExtension : public OpenXRGraphicsExtensionWrapper, VulkanHooks {
Expand Down
2 changes: 1 addition & 1 deletion tests/scene/test_audio_stream_wav.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void run_test(String file_name, AudioStreamWAV::Format data_format, bool stereo,
Ref<FileAccess> wav_file = FileAccess::open(save_path, FileAccess::READ, &error);
REQUIRE(error == OK);

#if TOOLS_ENABLED
#ifdef TOOLS_ENABLED
// The WAV importer can be used if enabled to check that the saved file is valid.
Ref<ResourceImporterWAV> wav_importer = memnew(ResourceImporterWAV);

Expand Down
Loading