From fe7c27b0868fe28194ab1cc9faf8d1805a11afea Mon Sep 17 00:00:00 2001
From: RedworkDE <10944644+RedworkDE@users.noreply.github.com>
Date: Mon, 26 Jun 2023 20:38:55 +0200
Subject: [PATCH] C#: Automatically generate version defines
---
modules/mono/build_scripts/build_assemblies.py | 16 +++++++++++++++-
.../Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props | 13 +++----------
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/modules/mono/build_scripts/build_assemblies.py b/modules/mono/build_scripts/build_assemblies.py
index 0b91cda9b89..580f51c9731 100755
--- a/modules/mono/build_scripts/build_assemblies.py
+++ b/modules/mono/build_scripts/build_assemblies.py
@@ -286,15 +286,29 @@ def generate_sdk_package_versions():
version_status = version_status[:pos] + "." + version_status[pos:]
version_str += "-" + version_status
+ import version
+
+ version_defines = (
+ [
+ f"GODOT{version.major}",
+ f"GODOT{version.major}_{version.minor}",
+ f"GODOT{version.major}_{version.minor}_{version.patch}",
+ ]
+ + [f"GODOT{v}_OR_GREATER" for v in range(4, version.major + 1)]
+ + [f"GODOT{version.major}_{v}_OR_GREATER" for v in range(0, version.minor + 1)]
+ + [f"GODOT{version.major}_{version.minor}_{v}_OR_GREATER" for v in range(0, version.patch + 1)]
+ )
+
props = """
{0}
{0}
{0}
+ {1}
""".format(
- version_str
+ version_str, ";".join(version_defines)
)
# We write in ../SdkPackageVersions.props.
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props
index 45f930fdf74..b0bee795f8d 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props
@@ -74,15 +74,8 @@
-
-
- GODOT;
- GODOT4;GODOT4_OR_GREATER;
- GODOT4_1;GODOT4_1_OR_GREATER;GODOT4_0_OR_GREATER;
- GODOT4_1_0;GODOT4_1_0_OR_GREATER;
-
-
- $(GodotDefineConstants.Replace('%0A','').Replace('%0D','').Replace('%09','').Replace(' ',''))
+
+ GODOT