From 834cbe8cef88fd2177c71480c82ab5802c725ca2 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 11 Jul 2023 16:07:36 +0200 Subject: [PATCH] Ported: Single Compilation Unit build. Adds support for simple SCU build. This speeds up compilation by compiling multiple cpp files within a single translation unit. - lawnjelly https://github.com/godotengine/godot/commit/43e181a00ab39671a3bb0b2d0302e25313f18aef --- SConstruct | 6 + core/math/color_names.inc | 7 + core/object/make_binders.py | 6 +- drivers/gles2/rasterizer_scene_gles2.cpp | 4 +- drivers/gles2/rasterizer_scene_gles2.h | 2 + drivers/gles2/shader_gles2.cpp | 2 +- drivers/gles2/shader_gles2.h | 2 + editor/editor_about.cpp | 2 +- editor/editor_about.h | 2 + .../editor_script_text_editor.cpp | 2 +- .../editor_script_text_editor.h | 2 + .../editor_code_editor/editor_text_editor.cpp | 2 +- .../editor_code_editor/editor_text_editor.h | 2 + main/tests/test_string.cpp.old | 2 + main/tests/test_theme.cpp | 2 + methods.py | 83 ++- scene/gui/box_container.cpp | 6 - scene/gui/box_container.h | 6 + scene/gui/line_edit.cpp | 2 +- scene/gui/line_edit.h | 1 + scu_builders.py | 578 ++++++++++++++++++ servers/physics/joints/hinge_joint_sw.cpp | 4 +- servers/physics/joints/hinge_joint_sw.h | 3 + servers/physics/joints/slider_joint_sw.cpp | 2 +- servers/physics/joints/slider_joint_sw.h | 3 + 25 files changed, 713 insertions(+), 20 deletions(-) create mode 100644 scu_builders.py diff --git a/SConstruct b/SConstruct index 1dcc4b6b6..b4dc25f62 100644 --- a/SConstruct +++ b/SConstruct @@ -14,6 +14,7 @@ from collections import OrderedDict # Local import methods import gles_builders +import scu_builders from platform_methods import run_in_subprocess # scan possible build platforms @@ -159,6 +160,7 @@ opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and be opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", True)) opts.Add("system_certs_path", "Use this path as SSL certificates default for editor (for package maintainers)", "") opts.Add(BoolVariable("use_precise_math_checks", "Math checks use very precise epsilon (debug option)", False)) +opts.Add(BoolVariable("scu_build", "Use single compilation unit build", False)) opts.Add( EnumVariable( "rids", @@ -428,6 +430,10 @@ if selected_platform in platform_list: "for an optimized template with debug features)." ) + # Run SCU file generation script if in a SCU build. + if env["scu_build"]: + methods.set_scu_folders(scu_builders.generate_scu_files(env["verbose"], env_base["target"] != "debug")) + # Must happen after the flags' definition, as configure is when most flags # are actually handled to change compile options, etc. detect.configure(env) diff --git a/core/math/color_names.inc b/core/math/color_names.inc index bee1ed5c8..d6ca0c063 100644 --- a/core/math/color_names.inc +++ b/core/math/color_names.inc @@ -1,4 +1,9 @@ + +#ifndef COLOR_NAMES_INC_H +#define COLOR_NAMES_INC_H + // Names from https://en.wikipedia.org/wiki/X11_color_names + #include "core/containers/rb_map.h" static RBMap _named_colors; @@ -153,3 +158,5 @@ static void _populate_named_colors() { _named_colors.insert("yellow", Color(1.00, 1.00, 0.00)); _named_colors.insert("yellowgreen", Color(0.60, 0.80, 0.20)); } + +#endif diff --git a/core/object/make_binders.py b/core/object/make_binders.py index d6ccdf9f7..bf211f2b7 100644 --- a/core/object/make_binders.py +++ b/core/object/make_binders.py @@ -343,8 +343,8 @@ def run(target, source, env): versions = 13 versions_ext = 6 - text = "" - text_ext = "" + text = "#ifndef METHOD_BIND_GEN_INC_H\n#define METHOD_BIND_GEN_INC_H\n" + text_ext = "#ifndef METHOD_BIND_EXT_GEN_INC_H\n#define METHOD_BIND_EXT_GEN_INC_H\n" text_free_func = "#ifndef METHOD_BIND_FREE_FUNC_H\n#define METHOD_BIND_FREE_FUNC_H\n" text_free_func += "\n//including this header file allows method binding to use free functions\n" text_free_func += ( @@ -372,6 +372,8 @@ def run(target, source, env): text_free_func += make_version(template_typed_free_func, i, versions, True, False) text_free_func += make_version(template_typed_free_func, i, versions, True, True) + text += "#endif" + text_ext += "#endif" text_free_func += "#endif" with open(target[0], "w") as f: diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index bc35fea99..3aed4b799 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -52,7 +52,7 @@ #endif #endif -static const GLenum _cube_side_enum[6] = { +const GLenum RasterizerSceneGLES2::_cube_side_enum[6] = { GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_X, @@ -1304,7 +1304,7 @@ void RasterizerSceneGLES2::_fill_render_list(InstanceBase **p_cull_result, int p } } -static const GLenum gl_primitive[] = { +const GLenum RasterizerSceneGLES2::gl_primitive[] = { GL_POINTS, GL_LINES, GL_LINE_STRIP, diff --git a/drivers/gles2/rasterizer_scene_gles2.h b/drivers/gles2/rasterizer_scene_gles2.h index 600044369..0ac2e84da 100644 --- a/drivers/gles2/rasterizer_scene_gles2.h +++ b/drivers/gles2/rasterizer_scene_gles2.h @@ -89,6 +89,8 @@ public: private: uint32_t _light_counter; + static const GLenum gl_primitive[]; + static const GLenum _cube_side_enum[6]; public: RasterizerStorageGLES2 *storage; diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp index 16da66d7c..665405757 100644 --- a/drivers/gles2/shader_gles2.cpp +++ b/drivers/gles2/shader_gles2.cpp @@ -126,7 +126,7 @@ static void _display_error_with_code(const String &p_error, const Vector &p_sections, const char *const *const p_src[], const int p_flag_single_column = 0); diff --git a/editor_modules/editor_code_editor/editor_script_text_editor.cpp b/editor_modules/editor_code_editor/editor_script_text_editor.cpp index 5b6d34300..fbd8caf43 100644 --- a/editor_modules/editor_code_editor/editor_script_text_editor.cpp +++ b/editor_modules/editor_code_editor/editor_script_text_editor.cpp @@ -1846,7 +1846,7 @@ EditorScriptTextEditor::~EditorScriptTextEditor() { } } -static EditorScriptEditorBase *create_editor(const RES &p_resource) { +EditorScriptEditorBase *EditorScriptTextEditor::create_editor(const RES &p_resource) { if (Object::cast_to