From 2771e352bd819179696f9a7cd3e8df956e1f9923 Mon Sep 17 00:00:00 2001 From: GustavoLCR Date: Wed, 17 Nov 2021 20:50:19 -0300 Subject: [PATCH] Fix vs backend cross compilation regression --- mesonbuild/backend/vs2010backend.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 8ec80871f..6885c63a2 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -520,18 +520,21 @@ class Vs2010Backend(backends.Backend): temp_dir, guid, conftype = 'Utility', - target_ext = None): + target_ext = None, + target_platform = None): root = ET.Element('Project', {'DefaultTargets': "Build", 'ToolsVersion': '4.0', 'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'}) confitems = ET.SubElement(root, 'ItemGroup', {'Label': 'ProjectConfigurations'}) + if not target_platform: + target_platform = self.platform prjconf = ET.SubElement(confitems, 'ProjectConfiguration', - {'Include': self.buildtype + '|' + self.platform}) + {'Include': self.buildtype + '|' + target_platform}) p = ET.SubElement(prjconf, 'Configuration') p.text = self.buildtype pl = ET.SubElement(prjconf, 'Platform') - pl.text = self.platform + pl.text = target_platform # Globals globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals') @@ -544,7 +547,7 @@ class Vs2010Backend(backends.Backend): ns.text = target_name p = ET.SubElement(globalgroup, 'Platform') - p.text = self.platform + p.text = target_platform pname = ET.SubElement(globalgroup, 'ProjectName') pname.text = target_name if self.windows_target_platform_version: @@ -613,9 +616,14 @@ class Vs2010Backend(backends.Backend): self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname) def gen_custom_target_vcxproj(self, target, ofname, guid): + if target.for_machine is MachineChoice.BUILD: + platform = self.build_platform + else: + platform = self.platform (root, type_config) = self.create_basic_project(target.name, temp_dir = target.get_id(), - guid = guid) + guid = guid, + target_platform = platform) # We need to always use absolute paths because our invocation is always # from the target dir, not the build root. target.absolute_paths = True @@ -869,7 +877,8 @@ class Vs2010Backend(backends.Backend): temp_dir = target.get_id(), guid = guid, conftype = conftype, - target_ext = tfilename[1]) + target_ext = tfilename[1], + target_platform = platform) # FIXME: Should these just be set in create_basic_project(), even if # irrelevant for current target?