Merge pull request #66569 from akien-mga/dotnet-generate-sdkpackageversions
.NET: Generate SdkPackageVersions.props from version.py
This commit is contained in:
commit
e541f05c62
4 changed files with 62 additions and 17 deletions
18
methods.py
18
methods.py
|
@ -7,15 +7,6 @@ from collections import OrderedDict
|
|||
from collections.abc import Mapping
|
||||
from typing import Iterator
|
||||
|
||||
# We need to define our own `Action` method to control the verbosity of output
|
||||
# and whenever we need to run those commands in a subprocess on some platforms.
|
||||
from SCons import Node
|
||||
from SCons.Script import Action
|
||||
from SCons.Script import ARGUMENTS
|
||||
from SCons.Script import Glob
|
||||
from SCons.Variables.BoolVariable import _text2bool
|
||||
from platform_methods import run_in_subprocess
|
||||
|
||||
|
||||
def add_source_files(self, sources, files):
|
||||
# Convert string to list of absolute paths (including expanding wildcard)
|
||||
|
@ -220,6 +211,9 @@ def get_cmdline_bool(option, default):
|
|||
"""We use `ARGUMENTS.get()` to check if options were manually overridden on the command line,
|
||||
and SCons' _text2bool helper to convert them to booleans, otherwise they're handled as strings.
|
||||
"""
|
||||
from SCons.Script import ARGUMENTS
|
||||
from SCons.Variables.BoolVariable import _text2bool
|
||||
|
||||
cmdline_val = ARGUMENTS.get(option)
|
||||
if cmdline_val is not None:
|
||||
return _text2bool(cmdline_val)
|
||||
|
@ -703,6 +697,9 @@ def generate_cpp_hint_file(filename):
|
|||
|
||||
|
||||
def glob_recursive(pattern, node="."):
|
||||
from SCons import Node
|
||||
from SCons.Script import Glob
|
||||
|
||||
results = []
|
||||
for f in Glob(str(node) + "/*", source=True):
|
||||
if type(f) is Node.FS.Dir:
|
||||
|
@ -913,6 +910,9 @@ def CommandNoCache(env, target, sources, command, **args):
|
|||
|
||||
|
||||
def Run(env, function, short_message, subprocess=True):
|
||||
from SCons.Script import Action
|
||||
from platform_methods import run_in_subprocess
|
||||
|
||||
output_print = short_message if not env["verbose"] else ""
|
||||
if not subprocess:
|
||||
return Action(function, output_print)
|
||||
|
|
3
modules/mono/.gitignore
vendored
3
modules/mono/.gitignore
vendored
|
@ -1,2 +1,5 @@
|
|||
# Do not ignore solution files inside the mono module. Overrides Godot's global gitignore.
|
||||
!*.sln
|
||||
|
||||
# Generated by build_assemblies.py.
|
||||
SdkPackageVersions.props
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<PackageFloatingVersion_Godot>4.0.*-*</PackageFloatingVersion_Godot>
|
||||
<PackageVersion_GodotSharp>4.0.0-dev</PackageVersion_GodotSharp>
|
||||
<PackageVersion_Godot_NET_Sdk>4.0.0-dev8</PackageVersion_Godot_NET_Sdk>
|
||||
<PackageVersion_Godot_SourceGenerators>4.0.0-dev8</PackageVersion_Godot_SourceGenerators>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -256,7 +256,57 @@ def build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local, flo
|
|||
return 0
|
||||
|
||||
|
||||
def generate_sdk_package_versions():
|
||||
# I can't believe importing files in Python is so convoluted when not
|
||||
# following the golden standard for packages/modules.
|
||||
import os
|
||||
import sys
|
||||
from os.path import dirname
|
||||
|
||||
# We want ../../../methods.py.
|
||||
script_path = dirname(os.path.abspath(__file__))
|
||||
root_path = dirname(dirname(dirname(script_path)))
|
||||
|
||||
sys.path.insert(0, root_path)
|
||||
from methods import get_version_info
|
||||
|
||||
version_info = get_version_info("")
|
||||
sys.path.remove(root_path)
|
||||
|
||||
version_str = "{major}.{minor}.{patch}".format(**version_info)
|
||||
version_status = version_info["status"]
|
||||
if version_status != "stable": # Pre-release
|
||||
# If version was overridden to be e.g. "beta3", we insert a dot between
|
||||
# "beta" and "3" to follow SemVer 2.0.
|
||||
import re
|
||||
|
||||
match = re.search(r"[\d]+$", version_status)
|
||||
if match:
|
||||
pos = match.start()
|
||||
version_status = version_status[:pos] + "." + version_status[pos:]
|
||||
version_str += "-" + version_status
|
||||
|
||||
props = """<Project>
|
||||
<PropertyGroup>
|
||||
<PackageVersion_GodotSharp>{0}</PackageVersion_GodotSharp>
|
||||
<PackageVersion_Godot_NET_Sdk>{0}</PackageVersion_Godot_NET_Sdk>
|
||||
<PackageVersion_Godot_SourceGenerators>{0}</PackageVersion_Godot_SourceGenerators>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
""".format(
|
||||
version_str
|
||||
)
|
||||
|
||||
# We write in ../SdkPackageVersions.props.
|
||||
with open(os.path.join(dirname(script_path), "SdkPackageVersions.props"), "w") as f:
|
||||
f.write(props)
|
||||
f.close()
|
||||
|
||||
|
||||
def build_all(msbuild_tool, module_dir, output_dir, godot_platform, dev_debug, push_nupkgs_local, float_size):
|
||||
# Generate SdkPackageVersions.props
|
||||
generate_sdk_package_versions()
|
||||
|
||||
# Godot API
|
||||
exit_code = build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local, float_size)
|
||||
if exit_code != 0:
|
||||
|
|
Loading…
Reference in a new issue