Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C#: Automatically generate version defines #78722

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 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,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 = """<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
13 changes: 3 additions & 10 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,15 +74,8 @@

<!-- Godot DefineConstants. -->
<PropertyGroup>
<!-- Define constants to identify Godot builds and versions. -->
<GodotDefineConstants>
GODOT;
GODOT4;GODOT4_OR_GREATER;
GODOT4_1;GODOT4_1_OR_GREATER;GODOT4_0_OR_GREATER;
GODOT4_1_0;GODOT4_1_0_OR_GREATER;
</GodotDefineConstants>
<!-- Ensure the define constants don't contain whitespace (see https://github.com/dotnet/roslyn/issues/58391). -->
<GodotDefineConstants>$(GodotDefineConstants.Replace('%0A','').Replace('%0D','').Replace('%09','').Replace(' ',''))</GodotDefineConstants>
<!-- Define constants to identify Godot builds. -->
<GodotDefineConstants>GODOT</GodotDefineConstants>

<!--
Define constant to determine the target Godot platform. This includes the
Expand All @@ -97,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