Skip to content

Commit

Permalink
Fix up build scripts
Browse files Browse the repository at this point in the history
See godot commit 3d2dd79ecd2c8456ba9401f6b12333d01f61e13e
godotengine/godot-proposals#3371
godotengine/godot#60723
  • Loading branch information
Meptl committed May 9, 2023
1 parent 86a8ee9 commit 3572f13
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 28 deletions.
3 changes: 1 addition & 2 deletions SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ env_goost.Prepend(CPPDEFINES={"SCALE_FACTOR" : env["goost_scale_factor"]})
godot_add_source_files = env_goost.__class__.add_source_files

def goost_add_source_files(self, sources, files):
from compat import isbasestring
# Convert string to list of absolute paths (including expanding wildcard)
if isbasestring(files):
if isinstance(files, (str, bytes)):
# Keep SCons project-absolute path as they are (no wildcard support)
if files.startswith("#"):
if "*" in files:
Expand Down
18 changes: 9 additions & 9 deletions builders.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python3

import os
from compat import iteritems, itervalues, open_utf8, escape_string

import goost

from core_builders import escape_string

def make_classes_enabled(target, source, env):
h = open(target[0].abspath, "w")
Expand Down Expand Up @@ -81,8 +81,8 @@ def make_authors_header(target, source, env):
]
src = source[0].abspath
dst = target[0].abspath
f = open_utf8(src, "r")
g = open_utf8(dst, "w")
f = open(src, "r", encoding="utf-8")
g = open(dst, "w", encoding="utf-8")

g.write("// THIS FILE IS GENERATED, DO NOT EDIT!\n")
g.write("#ifndef GOOST_AUTHORS_H\n")
Expand Down Expand Up @@ -153,7 +153,7 @@ def next_tag(self):
projects = OrderedDict()
license_list = []

with open_utf8(src_copyright, "r") as copyright_file:
with open(src_copyright, "r", encoding="utf-8") as copyright_file:
reader = LicenseReader(copyright_file)
part = {}
while reader.current:
Expand All @@ -173,21 +173,21 @@ def next_tag(self):
reader.next_line()

data_list = []
for project in itervalues(projects):
for project in iter(projects.values()):
for part in project:
part["file_index"] = len(data_list)
data_list += part["Files"]
part["copyright_index"] = len(data_list)
data_list += part["Copyright"]

with open_utf8(dst, "w") as f:
with open(dst, "w", encoding="utf-8") as f:

f.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
f.write("#ifndef GOOST_LICENSE_H\n")
f.write("#define GOOST_LICENSE_H\n")
f.write("const char *const GOOST_LICENSE_TEXT =")

with open_utf8(src_license, "r") as license_file:
with open(src_license, "r", encoding="utf-8") as license_file:
for line in license_file:
escaped_string = escape_string(line.strip())
f.write('\n\t\t"' + escaped_string + '\\n"')
Expand Down Expand Up @@ -219,7 +219,7 @@ def next_tag(self):
f.write("const ComponentCopyrightPart COPYRIGHT_PROJECT_PARTS[] = {\n")
part_index = 0
part_indexes = {}
for project_name, project in iteritems(projects):
for project_name, project in iter(projects.items()):
part_indexes[project_name] = part_index
for part in project:
f.write(
Expand All @@ -243,7 +243,7 @@ def next_tag(self):
f.write("const int COPYRIGHT_INFO_COUNT = " + str(len(projects)) + ";\n")

f.write("const ComponentCopyright COPYRIGHT_INFO[] = {\n")
for project_name, project in iteritems(projects):
for project_name, project in iter(projects.items()):
f.write(
'\t{ "'
+ escape_string(project_name)
Expand Down
2 changes: 1 addition & 1 deletion core/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ if env["goost_script_enabled"]:
env_goost.add_source_files(env.modules_sources, "*.cpp")
env_goost.add_source_files(env.modules_sources, "types/*.cpp")

if env["tools"]:
if env.editor_build:
env_goost.add_source_files(env.modules_sources, "types/editor/*.cpp")
2 changes: 1 addition & 1 deletion core/script/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Import("env_goost")
env_goost.add_source_files(env.modules_sources, "*.cpp")
env_goost.add_source_files(env.modules_sources, "mixin_script/*.cpp")

if env["tools"]:
if env.editor_build:
env_goost.add_source_files(env.modules_sources, "mixin_script/editor/*.cpp")
2 changes: 1 addition & 1 deletion editor/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Import("env")
Import("env_goost")

if env["tools"] and env["goost_editor_enabled"]:
if env.editor_build and env["goost_editor_enabled"]:
env_goost.add_source_files(env.modules_sources, "*.cpp")
2 changes: 1 addition & 1 deletion misc/patches/custom_app_icon_and_splash_images.patch
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ index 8ffff2e164..d9bfbcc7b6 100644
+env.Depends("#main/app_icon.gen.h", env["app_icon"])
+env.CommandNoCache("#main/app_icon.gen.h", env["app_icon"], run_in_subprocess(main_builders.make_app_icon))

if env["tools"]:
if env.editor_build:
SConscript("tests/SCsub")
2 changes: 1 addition & 1 deletion modules/gdscript_transpiler/register_types.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "register_types.h"
#include "core/engine.h"
#include "core/config/engine.h"

#include "bind/gdscript_transpiler_bind.h"
#include "gdscript_transpiler.h"
Expand Down
25 changes: 17 additions & 8 deletions register_types.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
#include "register_types.h"

#include "core/engine.h"

#include "core/register_core_types.h"
#include "editor/register_editor_types.h"
#include "scene/register_scene_types.h"

void register_goost_types() {
void initialize_goost_module(ModuleInitializationLevel p_level) {
#ifdef GOOST_CORE_ENABLED
goost::register_core_types();
if (p_level == MODULE_INITIALIZATION_LEVEL_CORE) {
goost::register_core_types();
}
#endif
#ifdef GOOST_SCENE_ENABLED
goost::register_scene_types();
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
goost::register_scene_types();
}
#endif
#if defined(TOOLS_ENABLED) && defined(GOOST_EDITOR_ENABLED)
goost::register_editor_types();
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
goost::register_editor_types();
}
#endif
}

void unregister_goost_types() {
void uninitialize_goost_module(ModuleInitializationLevel p_level) {
#ifdef GOOST_CORE_ENABLED
goost::unregister_core_types();
if (p_level == MODULE_INITIALIZATION_LEVEL_CORE) {
goost::unregister_core_types();
}
#endif
#ifdef GOOST_SCENE_ENABLED
goost::unregister_scene_types();
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
goost::unregister_scene_types();
}
#endif
}
6 changes: 3 additions & 3 deletions register_types.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include "core/engine.h"
#include "modules/register_module_types.h"

// Do not include `goost.h` here.
//
// This may lead to clashes with Godot's namespace, or produce include errors
// when `module_goost_enabled=no` is specified via command-line.

void register_goost_types();
void unregister_goost_types();
void initialize_goost_module(ModuleInitializationLevel p_level);
void uninitialize_goost_module(ModuleInitializationLevel p_level);

2 changes: 1 addition & 1 deletion scene/2d/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Import("env")
Import("env_goost")

if env["tools"] and env["goost_editor_enabled"]:
if env.editor_build and env["goost_editor_enabled"]:
SConscript("editor/SCsub", exports="env_goost")

sources = Glob("*.cpp")
Expand Down

0 comments on commit 3572f13

Please sign in to comment.