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

[3.x] Add support for single compilation unit builds #78113

Merged
merged 1 commit into from
Jul 3, 2023
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
6 changes: 6 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -155,6 +156,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",
Expand Down Expand Up @@ -442,6 +444,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)
Expand Down
2 changes: 2 additions & 0 deletions core/color_names.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Names from https://en.wikipedia.org/wiki/X11_color_names
#pragma once

#include "core/map.h"

static Map<String, Color> _named_colors;
Expand Down
3 changes: 2 additions & 1 deletion core/make_binders.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind {
#endif
"""

template = """
template = """#pragma once

#ifndef TYPED_METHOD_BIND
$iftempl template<$ $ifret class R$ $ifretargs ,$ $arg, class P@$ $iftempl >$
class MethodBind$argc$$ifret R$$ifconst C$ : public MethodBind {
Expand Down
4 changes: 2 additions & 2 deletions drivers/gles2/rasterizer_scene_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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,
Expand Down Expand Up @@ -1332,7 +1332,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,
Expand Down
2 changes: 2 additions & 0 deletions drivers/gles2/rasterizer_scene_gles2.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class RasterizerSceneGLES2 : public RasterizerScene {

private:
uint32_t _light_counter;
static const GLenum gl_primitive[];
static const GLenum _cube_side_enum[6];

public:
RasterizerStorageGLES2 *storage;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles2/shader_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
ERR_PRINT(p_error);
}

static String _mkid(const String &p_id) {
String ShaderGLES2::_mkid(const String &p_id) {
String id = "m_" + p_id;
return id.replace("__", "_dus_"); //doubleunderscore is reserved in glsl
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/gles2/shader_gles2.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
class RasterizerStorageGLES2;

class ShaderGLES2 {
static String _mkid(const String &p_id);

protected:
struct Enum {
uint64_t mask;
Expand Down
8 changes: 4 additions & 4 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define glClearDepth glClearDepthf
#endif

static const GLenum _cube_side_enum[6] = {
const GLenum RasterizerSceneGLES3::_cube_side_enum[6] = {

GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
Expand All @@ -52,7 +52,7 @@ static const GLenum _cube_side_enum[6] = {

};

static _FORCE_INLINE_ void store_transform(const Transform &p_mtx, float *p_array) {
void RasterizerSceneGLES3::store_transform(const Transform &p_mtx, float *p_array) {
p_array[0] = p_mtx.basis.elements[0][0];
p_array[1] = p_mtx.basis.elements[1][0];
p_array[2] = p_mtx.basis.elements[2][0];
Expand All @@ -71,7 +71,7 @@ static _FORCE_INLINE_ void store_transform(const Transform &p_mtx, float *p_arra
p_array[15] = 1;
}

static _FORCE_INLINE_ void store_camera(const CameraMatrix &p_mtx, float *p_array) {
void RasterizerSceneGLES3::store_camera(const CameraMatrix &p_mtx, float *p_array) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
p_array[i * 4 + j] = p_mtx.matrix[i][j];
Expand Down Expand Up @@ -1482,7 +1482,7 @@ void RasterizerSceneGLES3::_setup_geometry(RenderList::Element *e, const Transfo
}
}

static const GLenum gl_primitive[] = {
const GLenum RasterizerSceneGLES3::gl_primitive[] = {
GL_POINTS,
GL_LINES,
GL_LINE_STRIP,
Expand Down
7 changes: 7 additions & 0 deletions drivers/gles3/rasterizer_scene_gles3.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,13 @@ class RasterizerSceneGLES3 : public RasterizerScene {
virtual void set_scene_pass(uint64_t p_pass);
virtual void set_debug_draw_mode(VS::ViewportDebugDraw p_debug_draw);

private:
_FORCE_INLINE_ void store_transform(const Transform &p_mtx, float *p_array);
_FORCE_INLINE_ void store_camera(const CameraMatrix &p_mtx, float *p_array);
static const GLenum gl_primitive[];
static const GLenum _cube_side_enum[6];

public:
void iteration();
void initialize();
void finalize();
Expand Down
9 changes: 7 additions & 2 deletions editor/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ if env["tools"]:
reg_exporters = "void register_exporters() {\n"
for e in env.platform_exporters:
# Glob all .cpp files in export folder
files = Glob("#platform/" + e + "/export/" + "*.cpp")
env.add_source_files(env.editor_sources, files)
if not env["scu_build"]:
files = Glob("#platform/" + e + "/export/" + "*.cpp")
env.add_source_files(env.editor_sources, files)

reg_exporters += "\tregister_" + e + "_exporter();\n"
reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n'
reg_exporters += "}\n"

# If we are in a SCU build, we add all the platform exporters in one SCU file.
if env["scu_build"]:
env.add_source_files(env.editor_sources, "../platform/*.cpp")
Copy link
Member

@akien-mga akien-mga Jul 2, 2023

Choose a reason for hiding this comment

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

Should be platform/*/export/*.cpp, no?

This didn't seem needed in the master version, what's the difference here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Slight difference here:
In master it compiles each export platform individually. In 3.x, particularly as the export platforms are fairly finalized, these are amalgamated as a single SCU file which is stored in platform/.scu/ folder. (The path is correct, but it will be confusing as this is the first time you have seen this pattern.)

This makes more sense when read with the scu_builders.py file for this:

    process_folder(
        [
            "platform",
            "android/export",
            "iphone/export",
            "javascript/export",
            "osx/export",
            "uwp/export",
            "windows/export",
            "x11/export",
        ]
    )

This is adding all the various platform exporter folders all into a single uber-SCU file which is stored off the platform folder.

To explain further, the array argument, the first string is the "main" folder, and the following folders are considered sub-folders to be added to the same SCU file.

I'm happy to simplify if preferred to the same method as master, but will lose out on acceleration, but it is worth bearing in mind the exporters are quite significant in the incremental rebuilds. In 3.x, each export directory typically only contains a single file, so there is no accelerating unless they are amalgamated.


# NOTE: It is safe to generate this file here, since this is still executed serially
with open_utf8("register_exporters.gen.cpp", "w") as f:
f.write(reg_exporters_inc)
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "editor_node.h"

// The metadata key used to store and retrieve the version text to copy to the clipboard.
static const String META_TEXT_TO_COPY = "text_to_copy";
const String EditorAbout::META_TEXT_TO_COPY = "text_to_copy";

void EditorAbout::_notification(int p_what) {
switch (p_what) {
Expand Down
1 change: 1 addition & 0 deletions editor/editor_about.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class EditorAbout : public AcceptDialog {
GDCLASS(EditorAbout, AcceptDialog);

private:
static const String META_TEXT_TO_COPY;
void _license_tree_selected();
void _version_button_pressed();
ScrollContainer *_populate_list(const String &p_name, const List<String> &p_sections, const char *const *const p_src[], const int p_flag_single_column = 0);
Expand Down
28 changes: 14 additions & 14 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,6 @@
#include "scene/property_utils.h"
#include "scene/resources/packed_scene.h"

static bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) {
if (p_property_path.findn(p_filter) != -1) {
return true;
}

const Vector<String> sections = p_property_path.split("/");
for (int i = 0; i < sections.size(); i++) {
if (p_filter.is_subsequence_ofi(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i], p_style))) {
return true;
}
}
return false;
}

Size2 EditorProperty::get_minimum_size() const {
Size2 ms;
Ref<Font> font = get_font("font", "Tree");
Expand Down Expand Up @@ -1232,6 +1218,20 @@ EditorInspectorSection::~EditorInspectorSection() {
Ref<EditorInspectorPlugin> EditorInspector::inspector_plugins[MAX_PLUGINS];
int EditorInspector::inspector_plugin_count = 0;

bool EditorInspector::_property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) {
if (p_property_path.findn(p_filter) != -1) {
return true;
}

const Vector<String> sections = p_property_path.split("/");
for (int i = 0; i < sections.size(); i++) {
if (p_filter.is_subsequence_ofi(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i], p_style))) {
return true;
}
}
return false;
}

EditorProperty *EditorInspector::instantiate_property_editor(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
for (int i = inspector_plugin_count - 1; i >= 0; i--) {
inspector_plugins[i]->parse_property(p_object, p_type, p_path, p_hint, p_hint_text, p_usage);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ class EditorInspector : public ScrollContainer {
void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance);
void _property_checked(const String &p_path, bool p_checked);
void _property_pinned(const String &p_path, bool p_pinned);
bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style);

void _resource_selected(const String &p_path, RES p_resource);
void _property_selected(const String &p_path, int p_focusable);
Expand Down
28 changes: 14 additions & 14 deletions editor/editor_sectioned_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@
#include "editor_scale.h"
#include "editor_settings.h"

static bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) {
if (p_property_path.findn(p_filter) != -1) {
return true;
}

const Vector<String> sections = p_property_path.split("/");
for (int i = 0; i < sections.size(); i++) {
if (p_filter.is_subsequence_ofi(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i], p_style))) {
return true;
}
}
return false;
}

class SectionedInspectorFilter : public Object {
GDCLASS(SectionedInspectorFilter, Object);

Expand Down Expand Up @@ -145,6 +131,20 @@ class SectionedInspectorFilter : public Object {
}
};

bool SectionedInspector::_property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style) {
if (p_property_path.findn(p_filter) != -1) {
return true;
}

const Vector<String> sections = p_property_path.split("/");
for (int i = 0; i < sections.size(); i++) {
if (p_filter.is_subsequence_ofi(EditorPropertyNameProcessor::get_singleton()->process_name(sections[i], p_style))) {
return true;
}
}
return false;
}

void SectionedInspector::_bind_methods() {
ClassDB::bind_method("_section_selected", &SectionedInspector::_section_selected);
ClassDB::bind_method("_search_changed", &SectionedInspector::_search_changed);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_sectioned_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SectionedInspector : public HSplitContainer {
void _section_selected();

void _search_changed(const String &p_what);
bool _property_path_matches(const String &p_property_path, const String &p_filter, EditorPropertyNameProcessor::Style p_style);

protected:
void _notification(int p_what);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/text_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void TextEditor::_bind_methods() {
ClassDB::bind_method("_prepare_edit_menu", &TextEditor::_prepare_edit_menu);
}

static ScriptEditorBase *create_editor(const RES &p_resource) {
ScriptEditorBase *TextEditor::create_editor(const RES &p_resource) {
if (Object::cast_to<TextFile>(*p_resource)) {
return memnew(TextEditor);
}
Expand Down
1 change: 1 addition & 0 deletions editor/plugins/text_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class TextEditor : public ScriptEditorBase {
BOOKMARK_GOTO_PREV,
BOOKMARK_REMOVE_ALL,
};
static ScriptEditorBase *create_editor(const RES &p_resource);

protected:
static void _bind_methods();
Expand Down
2 changes: 2 additions & 0 deletions main/tests/test_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,3 +1330,5 @@ MainLoop *test() {
return nullptr;
}
} // namespace TestString

#undef CHECK
2 changes: 2 additions & 0 deletions main/tests/test_theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,5 @@ MainLoop *test() {
return nullptr;
}
} // namespace TestTheme

#undef CHECK
Loading