Skip to content

Commit

Permalink
MSBuildDeps: map armv8 to ARM64 platform (#11504) (#11505)
Browse files Browse the repository at this point in the history
* fix: x86 msbuild platform is Win32, not x86

* MSBuildDeps: map armv7 and armv8 msbuild platforms

Fixes #11504

* fixed MSBuildDeps Win32 usage

* test: msbuilddeps mapping of arch to platform

* fixup: remove incorrect test description

Co-authored-by: Mark Ferry <mark@cognomen.co.uk>
Co-authored-by: memsharded <james@conan.io>
  • Loading branch information
3 people committed Jun 28, 2022
1 parent b7a8198 commit fa52c51
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
6 changes: 5 additions & 1 deletion conan/tools/microsoft/msbuilddeps.py
Expand Up @@ -86,8 +86,12 @@ class MSBuildDeps(object):
def __init__(self, conanfile):
self._conanfile = conanfile
self.configuration = conanfile.settings.build_type
# TODO: This platform is not exactly the same as ``msbuild_arch``, because it differs
# in x86=>Win32
self.platform = {'x86': 'Win32',
'x86_64': 'x64'}.get(str(conanfile.settings.arch))
'x86_64': 'x64',
'armv7': 'ARM',
'armv8': 'ARM64'}.get(str(conanfile.settings.arch))
ca_exclude = "tools.microsoft.msbuilddeps:exclude_code_analysis"
self.exclude_code_analysis = self._conanfile.conf.get(ca_exclude, check_type=list)
check_using_build_profile(self._conanfile)
Expand Down
7 changes: 5 additions & 2 deletions conan/tools/microsoft/toolchain.py
Expand Up @@ -55,9 +55,12 @@ def __init__(self, conanfile):

def _name_condition(self, settings):
props = [("Configuration", self.configuration),
# FIXME: This probably requires mapping ARM architectures
# TODO: refactor, put in common with MSBuildDeps. Beware this is != msbuild_arch
# because of Win32
("Platform", {'x86': 'Win32',
'x86_64': 'x64'}.get(settings.get_safe("arch")))]
'x86_64': 'x64',
'armv7': 'ARM',
'armv8': 'ARM64'}.get(settings.get_safe("arch")))]

name = "".join("_%s" % v for _, v in props if v is not None)
condition = " And ".join("'$(%s)' == '%s'" % (k, v) for k, v in props if v is not None)
Expand Down
23 changes: 23 additions & 0 deletions conans/test/integration/toolchains/microsoft/test_msbuilddeps.py
@@ -0,0 +1,23 @@
import os

import pytest

from conans.test.utils.tools import TestClient


@pytest.mark.parametrize(
"arch,exp_platform",
[
("x86", "Win32"),
("x86_64", "x64"),
("armv7", "ARM"),
("armv8", "ARM64"),
],
)
def test_msbuilddeps_maps_architecture_to_platform(arch, exp_platform):
client = TestClient(path_with_spaces=False)
client.run("new hello/0.1 --template=msbuild_lib")
client.run(f"install . -g MSBuildDeps -s arch={arch} -pr:b=default -if=install")
toolchain = client.load(os.path.join("conan", "conantoolchain.props"))
expected_import = f"""<Import Condition="'$(Configuration)' == 'Release' And '$(Platform)' == '{exp_platform}'" Project="conantoolchain_release_{exp_platform.lower()}.props"/>"""
assert expected_import in toolchain

0 comments on commit fa52c51

Please sign in to comment.