C#: Automatically generate version defines
This commit is contained in:
parent
c83f912bcb
commit
fe7c27b086
|
@ -286,15 +286,29 @@ def generate_sdk_package_versions():
|
||||||
version_status = version_status[:pos] + "." + version_status[pos:]
|
version_status = version_status[:pos] + "." + version_status[pos:]
|
||||||
version_str += "-" + version_status
|
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>
|
props = """<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageVersion_GodotSharp>{0}</PackageVersion_GodotSharp>
|
<PackageVersion_GodotSharp>{0}</PackageVersion_GodotSharp>
|
||||||
<PackageVersion_Godot_NET_Sdk>{0}</PackageVersion_Godot_NET_Sdk>
|
<PackageVersion_Godot_NET_Sdk>{0}</PackageVersion_Godot_NET_Sdk>
|
||||||
<PackageVersion_Godot_SourceGenerators>{0}</PackageVersion_Godot_SourceGenerators>
|
<PackageVersion_Godot_SourceGenerators>{0}</PackageVersion_Godot_SourceGenerators>
|
||||||
|
<GodotVersionConstants>{1}</GodotVersionConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
""".format(
|
""".format(
|
||||||
version_str
|
version_str, ";".join(version_defines)
|
||||||
)
|
)
|
||||||
|
|
||||||
# We write in ../SdkPackageVersions.props.
|
# We write in ../SdkPackageVersions.props.
|
||||||
|
|
|
@ -74,15 +74,8 @@
|
||||||
|
|
||||||
<!-- Godot DefineConstants. -->
|
<!-- Godot DefineConstants. -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Define constants to identify Godot builds and versions. -->
|
<!-- Define constants to identify Godot builds. -->
|
||||||
<GodotDefineConstants>
|
<GodotDefineConstants>GODOT</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 constant to determine the target Godot platform. This includes the
|
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)' == 'ios' ">GODOT_IPHONE;GODOT_IOS;GODOT_MOBILE</GodotPlatformConstants>
|
||||||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'web' ">GODOT_JAVASCRIPT;GODOT_HTML5;GODOT_WASM;GODOT_WEB</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>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
Loading…
Reference in New Issue