From e574eba0a51b87270d43b738ab32895cdc7677a8 Mon Sep 17 00:00:00 2001 From: Caleb Cornett Date: Tue, 19 Jul 2022 10:07:02 -0400 Subject: [PATCH] Add cross-compile support for Microsoft GDK platforms --- mesonbuild/backend/vs2010backend.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index a2581e495..4171ce2df 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -21,6 +21,7 @@ import xml.etree.ElementTree as ET import uuid import typing as T from pathlib import Path, PurePath +import re from . import backends from .. import build @@ -96,6 +97,8 @@ def split_o_flags_args(args): def generate_guid_from_path(path, path_type): return str(uuid.uuid5(uuid.NAMESPACE_URL, 'meson-vs-' + path_type + ':' + str(path))).upper() +def detect_microsoft_gdk(platform: str) -> bool: + return re.match(r'Gaming\.(Desktop|Xbox.XboxOne|Xbox.Scarlett)\.x64', platform, re.IGNORECASE) class Vs2010Backend(backends.Backend): def __init__(self, build: T.Optional[build.Build], interpreter: T.Optional[Interpreter]): @@ -182,7 +185,11 @@ class Vs2010Backend(backends.Backend): target_machine = self.interpreter.builtin['target_machine'].cpu_family_method(None, None) if target_machine in {'64', 'x86_64'}: # amd64 or x86_64 - self.platform = 'x64' + target_system = self.interpreter.builtin['target_machine'].system_method(None, None) + if detect_microsoft_gdk(target_system): + self.platform = target_system + else: + self.platform = 'x64' elif target_machine == 'x86': # x86 self.platform = 'Win32' @@ -1321,7 +1328,7 @@ class Vs2010Backend(backends.Backend): targetplatform = self.platform.lower() if targetplatform == 'win32': targetmachine.text = 'MachineX86' - elif targetplatform == 'x64': + elif targetplatform == 'x64' or detect_microsoft_gdk(targetplatform): targetmachine.text = 'MachineX64' elif targetplatform == 'arm': targetmachine.text = 'MachineARM'