Skip to content

Commit

Permalink
Merge pull request godotengine#78811 from RedworkDE/net-auto-version-…
Browse files Browse the repository at this point in the history
…defines-4.0

[4.0] C#: Automatically generate version defines
  • Loading branch information
akien-mga authored Jun 29, 2023
2 parents 98a4721 + 03ce3f5 commit 34b4cce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
20 changes: 19 additions & 1 deletion modules/mono/build_scripts/build_assemblies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 3 additions & 8 deletions modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>
Expand Down

0 comments on commit 34b4cce

Please sign in to comment.