diff options
| author | RedworkDE <10944644+RedworkDE@users.noreply.github.com> | 2023-06-26 20:38:55 +0200 |
|---|---|---|
| committer | RedworkDE <10944644+RedworkDE@users.noreply.github.com> | 2023-06-28 21:45:58 +0200 |
| commit | fe7c27b0868fe28194ab1cc9faf8d1805a11afea (patch) | |
| tree | 7ecf0efa8e92ac416e49358593d0a6599026aed6 /modules/mono | |
| parent | c83f912bcb33d441b90afe36bad38880acbe5f15 (diff) | |
| download | redot-engine-fe7c27b0868fe28194ab1cc9faf8d1805a11afea.tar.gz | |
C#: Automatically generate version defines
Diffstat (limited to 'modules/mono')
| -rwxr-xr-x | modules/mono/build_scripts/build_assemblies.py | 16 | ||||
| -rw-r--r-- | modules/mono/editor/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 0b91cda9b8..580f51c973 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 = """<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. 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 45f930fdf7..b0bee795f8 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 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 @@ -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> |
