diff options
Diffstat (limited to 'methods.py')
-rw-r--r-- | methods.py | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/methods.py b/methods.py index 3f11d39bd0..04541c72ad 100644 --- a/methods.py +++ b/methods.py @@ -795,9 +795,9 @@ def get_compiler_version(env): "major": -1, "minor": -1, "patch": -1, - "metadata1": None, - "metadata2": None, - "date": None, + "metadata1": "", + "metadata2": "", + "date": "", "apple_major": -1, "apple_minor": -1, "apple_patch1": -1, @@ -806,7 +806,35 @@ def get_compiler_version(env): } if env.msvc and not using_clang(env): - # TODO: Implement for MSVC + try: + # FIXME: `-latest` works for most cases, but there are edge-cases where this would + # benefit from a more nuanced search. + # https://github.com/godotengine/godot/pull/91069#issuecomment-2358956731 + # https://github.com/godotengine/godot/pull/91069#issuecomment-2380836341 + args = [ + env["VSWHERE"], + "-latest", + "-prerelease", + "-products", + "*", + "-requires", + "Microsoft.Component.MSBuild", + "-utf8", + ] + version = subprocess.check_output(args, encoding="utf-8").strip() + for line in version.splitlines(): + split = line.split(":", 1) + if split[0] == "catalog_productDisplayVersion": + sem_ver = split[1].split(".") + ret["major"] = int(sem_ver[0]) + ret["minor"] = int(sem_ver[1]) + ret["patch"] = int(sem_ver[2]) + # Could potentially add section for determining preview version, but + # that can wait until metadata is actually used for something. + if split[0] == "catalog_buildVersion": + ret["metadata1"] = split[1] + except (subprocess.CalledProcessError, OSError): + print_warning("Couldn't find vswhere to determine compiler version.") return ret # Not using -dumpversion as some GCC distros only return major, and |