Skip to content

Commit

Permalink
Add cross-compile support for Microsoft GDK platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpydog authored and xclaesse committed Sep 29, 2022
1 parent 2dfd952 commit e574eba
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mesonbuild/backend/vs2010backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import uuid
import typing as T
from pathlib import Path, PurePath
import re

from . import backends
from .. import build
Expand Down Expand Up @@ -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]):
Expand Down Expand Up @@ -182,7 +185,11 @@ def generate(self):
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'
Expand Down Expand Up @@ -1321,7 +1328,7 @@ def gen_vcxproj(self, target, ofname, guid):
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'
Expand Down

0 comments on commit e574eba

Please sign in to comment.