diff --git a/.github/actions/compile_gdextension/action.yml b/.github/actions/compile_gdextension/action.yml index 93123494..22f55078 100644 --- a/.github/actions/compile_gdextension/action.yml +++ b/.github/actions/compile_gdextension/action.yml @@ -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 .. diff --git a/.gitmodules b/.gitmodules index 0e697b1f..98dc79e2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/dev_build_godot_cpp.bat b/dev_build_godot_cpp.bat index db2e3222..b0e4a3f5 100644 --- a/dev_build_godot_cpp.bat +++ b/dev_build_godot_cpp.bat @@ -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 diff --git a/godot-cpp b/godot-cpp index 4b63d795..a4f9d22a 160000 --- a/godot-cpp +++ b/godot-cpp @@ -1 +1 @@ -Subproject commit 4b63d795e4279838d988399f008eec47eb2dcc7f +Subproject commit a4f9d22ac54e05ca6a41d54a59afd7555cb7d292 diff --git a/patches/godot_cpp_exclude_unused_classes.patch b/patches/godot_cpp_exclude_unused_classes.patch index ffe4ded5..9344f7e8 100644 --- a/patches/godot_cpp_exclude_unused_classes.patch +++ b/patches/godot_cpp_exclude_unused_classes.patch @@ -1,26 +1,28 @@ 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())) @@ -28,26 +30,26 @@ index 18db9fd..0e00eb1 100644 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)) diff --git a/patches/unity_build.patch b/patches/unity_build.patch index fa23ee51..541dca05 100644 --- a/patches/unity_build.patch +++ b/patches/unity_build.patch @@ -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", ], ) diff --git a/patches/visibilty_hidden.patch b/patches/visibilty_hidden.patch deleted file mode 100644 index 72fc3f34..00000000 --- a/patches/visibilty_hidden.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/tools/godotcpp.py b/tools/godotcpp.py -index efe632a..46d64fb 100644 ---- a/tools/godotcpp.py -+++ b/tools/godotcpp.py -@@ -183,6 +183,15 @@ def options(opts, env): - ) - ) - -+ opts.Add( -+ EnumVariable( -+ key="symbols_visibility", -+ help="Symbols visibility on GNU platforms. Use 'auto' to apply the default values.", -+ default=env.get("symbols_visibility", "hidden"), -+ allowed_values=["auto", "visible", "hidden"], -+ ) -+ ) -+ - # Add platform options - for pl in platforms: - tool = Tool(pl, toolpath=["tools"]) -@@ -258,6 +267,14 @@ def generate(env): - elif env.get("is_msvc", False): - env.Append(CXXFLAGS=["/EHsc"]) - -+ if not env.get("is_msvc", False): -+ if env["symbols_visibility"] == "visible": -+ env.Append(CCFLAGS=["-fvisibility=default"]) -+ env.Append(LINKFLAGS=["-fvisibility=default"]) -+ elif env["symbols_visibility"] == "hidden": -+ env.Append(CCFLAGS=["-fvisibility=hidden"]) -+ env.Append(LINKFLAGS=["-fvisibility=hidden"]) -+ - # Require C++17 - if env.get("is_msvc", False): - env.Append(CXXFLAGS=["/std:c++17"])