Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSBuildDeps: map armv8 to ARM64 platform (#11504) #11505

Merged
merged 7 commits into from Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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