C#: Automatically generate version defines

This commit is contained in:
RedworkDE 2023-06-26 20:38:55 +02:00
parent 98a47218a4
commit 03ce3f5027
2 changed files with 22 additions and 9 deletions

View File

@ -286,15 +286,33 @@ 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)]
+ [
# Skip GODOT4_0_0_OR_GREATER to GODOT4_0_3_OR_GREATER because the versions defines don't exist for these version.
f"GODOT{version.major}_{version.minor}_{v}_OR_GREATER"
for v in range(4, version.patch + 1)
]
)
props = """<Project>
<PropertyGroup>
<PackageVersion_GodotSharp>{0}</PackageVersion_GodotSharp>
<PackageVersion_Godot_NET_Sdk>{0}</PackageVersion_Godot_NET_Sdk>
<PackageVersion_Godot_SourceGenerators>{0}</PackageVersion_Godot_SourceGenerators>
<GodotVersionConstants>{1}</GodotVersionConstants>
</PropertyGroup>
</Project>
""".format(
version_str
version_str, ";".join(version_defines)
)
# We write in ../SdkPackageVersions.props.

View File

@ -74,13 +74,8 @@
<!-- Godot DefineConstants. -->
<PropertyGroup>
<!-- Define constants to identify Godot builds and versions. GODOT4_0_0_OR_GREATER to GODOT4_0_3_OR_GREATER are omitted because the versions defines don't exist for these version. -->
<GodotDefineConstants>
GODOT;
GODOT4;GODOT4_OR_GREATER;
GODOT4_0;GODOT4_0_OR_GREATER;
GODOT4_0_4;GODOT4_0_4_OR_GREATER;
</GodotDefineConstants>
<!-- Define constants to identify Godot builds. -->
<GodotDefineConstants>GODOT</GodotDefineConstants>
<!--
Define constant to determine the target Godot platform. This includes the
@ -95,7 +90,7 @@
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'ios' ">GODOT_IPHONE;GODOT_IOS;GODOT_MOBILE</GodotPlatformConstants>
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'web' ">GODOT_JAVASCRIPT;GODOT_HTML5;GODOT_WASM;GODOT_WEB</GodotPlatformConstants>
<GodotDefineConstants>$(GodotDefineConstants);$(GodotPlatformConstants)</GodotDefineConstants>
<GodotDefineConstants>$(GodotDefineConstants);$(GodotPlatformConstants);$(GodotVersionConstants)</GodotDefineConstants>
</PropertyGroup>
<PropertyGroup>