Skip to content

Commit

Permalink
updated godot-cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Jul 20, 2024
1 parent 6dafad2 commit 0c5f621
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 64 deletions.
1 change: 0 additions & 1 deletion .github/actions/compile_gdextension/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ runs:
run: |
echo "::group::🛠️ GDExtesion Compilation 🛠️"
cd godot-cpp
git apply --ignore-space-change --ignore-whitespace ../patches/visibilty_hidden.patch
git apply --ignore-space-change --ignore-whitespace ../patches/godot_cpp_exclude_unused_classes.patch
git apply --ignore-space-change --ignore-whitespace ../patches/unity_build.patch
cd ..
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/godotengine/godot-cpp.git
branch = 3.4
branch = 4.1

[submodule "src/thirdparty/tracy"]
path = src/thirdparty/tracy
Expand Down
1 change: 0 additions & 1 deletion dev_build_godot_cpp.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ cd godot-cpp
::set api=custom_api_file="../api.json"
set api=

git apply --ignore-space-change --ignore-whitespace ../patches/visibilty_hidden.patch
git apply --ignore-space-change --ignore-whitespace ../patches/godot_cpp_exclude_unused_classes.patch
git apply --ignore-space-change --ignore-whitespace ../patches/unity_build.patch
::git apply --ignore-space-change --ignore-whitespace ../patches/debug_string.patch
Expand Down
2 changes: 1 addition & 1 deletion godot-cpp
Submodule godot-cpp updated 117 files
44 changes: 23 additions & 21 deletions patches/godot_cpp_exclude_unused_classes.patch
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
diff --git a/binding_generator.py b/binding_generator.py
index 18db9fd..0e00eb1 100644
index 7911a7e..58188f7 100644
--- a/binding_generator.py
+++ b/binding_generator.py
@@ -1,5 +1,9 @@
#!/usr/bin/env python
@@ -5,6 +5,11 @@ import re
import shutil
from pathlib import Path

+import sys
+
+sys.path.insert(0, "../patches")
+import get_used_classes
+
import json
import re
import shutil
@@ -76,6 +80,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):

def generate_mod_version(argcount, const=False, returns=False):
s = """
@@ -76,6 +81,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False, profil
with open(api_filepath, encoding="utf-8") as api_file:
api = json.load(api_file)

+ get_used_classes.scan_dependencies(api)
build_profile = parse_build_profile(profile_filepath, api)

core_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp" / "core"
include_gen_folder = Path(output_dir) / "gen" / "include" / "godot_cpp"
source_gen_folder = Path(output_dir) / "gen" / "src"
@@ -131,6 +136,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
@@ -133,6 +139,7 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False, profil
utility_functions_source_path = source_gen_folder / "variant" / "utility_functions.cpp"
files.append(str(utility_functions_source_path.as_posix()))

+ files = get_used_classes.delete_useless(files)
return files


@@ -141,6 +147,8 @@ def print_file_list(api_filepath, output_dir, headers=False, sources=False):
@@ -230,6 +237,8 @@ def parse_build_profile(profile_filepath, api):


def scons_emit_files(target, source, env):
+ get_used_classes.setup(env.get("exclude_unused_classes", True), env.get("folder_to_include_classes", "../src"))
+
files = [env.File(f) for f in get_file_list(str(source[0]), target[0].abspath, True, True)]
env.Clean(target, files)
env["godot_cpp_gen_dir"] = target[0].abspath
profile_filepath = env.get("build_profile", "")
if profile_filepath and not Path(profile_filepath).is_absolute():
profile_filepath = str((Path(env.Dir("#").abspath) / profile_filepath).as_posix())
diff --git a/tools/godotcpp.py b/tools/godotcpp.py
index efe632a..a35b752 100644
index cc2b02f..d138052 100644
--- a/tools/godotcpp.py
+++ b/tools/godotcpp.py
@@ -183,6 +183,9 @@ def options(opts, env):
)
)
@@ -322,6 +322,9 @@ def options(opts, env):
opts.Add(BoolVariable("dev_build", "Developer build with dev-only debugging code (DEV_ENABLED)", False))
opts.Add(BoolVariable("verbose", "Enable verbose output for the compilation", False))

+ opts.Add(BoolVariable("exclude_unused_classes", "Disable generation of unused classes.", True))
+ opts.Add(PathVariable("folder_to_include_classes", "Path to the directory containing extension sources", "../src", PathVariable.PathIsDir))
+
# Add platform options
for pl in platforms:
tool = Tool(pl, toolpath=["tools"])
# Add platform options (custom tools can override platforms)
for pl in sorted(set(platforms + custom_platforms)):
tool = Tool(pl, toolpath=get_platform_tools_paths(env))
9 changes: 5 additions & 4 deletions patches/unity_build.patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
diff --git a/tools/godotcpp.py b/tools/godotcpp.py
index 60cd34b..6815eaa 100644
index cc2b02f..b0d3017 100644
--- a/tools/godotcpp.py
+++ b/tools/godotcpp.py
@@ -6,6 +6,8 @@ from SCons.Builder import Builder
@@ -12,6 +12,9 @@ from SCons.Variables.BoolVariable import _text2bool

from binding_generator import scons_generate_bindings, scons_emit_files
from binding_generator import scons_emit_files, scons_generate_bindings

+sys.path.insert(0, "../patches")
+import unity_tools
+

def add_sources(sources, dir, extension):
for f in os.listdir(dir):
@@ -282,6 +284,9 @@ def _godot_cpp(env):
@@ -468,6 +471,9 @@ def _godot_cpp(env):
"binding_generator.py",
],
)
Expand Down
35 changes: 0 additions & 35 deletions patches/visibilty_hidden.patch

This file was deleted.

0 comments on commit 0c5f621

Please sign in to comment.