Skip to content

Commit 7f2af5e

Browse files
[MesonToolchain] needs_exe_wrapper depends on can_run function (#19382)
* Conditioned to can_run property * comments * without quotes * Fixed test
1 parent 4744d8e commit 7f2af5e

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

conan/tools/meson/toolchain.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from conan.internal.internal_tools import raise_on_universal_arch
99
from conan.tools.apple.apple import is_apple_os, apple_min_version_flag, \
1010
resolve_apple_flags, apple_extra_flags
11-
from conan.tools.build.cross_building import cross_building
11+
from conan.tools.build.cross_building import cross_building, can_run
1212
from conan.tools.build.flags import (architecture_link_flag, libcxx_flags, architecture_flag,
1313
threads_flags)
1414
from conan.tools.env import VirtualBuildEnv
@@ -266,7 +266,8 @@ def __init__(self, conanfile, backend=None, native=False):
266266
sdk_host = conanfile.settings.get_safe("os.sdk")
267267
self.cross_build["host"]["subsystem"] = get_apple_subsystem(sdk_host)
268268
self.cross_build["build"]["subsystem"] = get_apple_subsystem(sdk_build)
269-
self.properties["needs_exe_wrapper"] = True
269+
# Issue: https://github.com/conan-io/conan/issues/19217
270+
self.properties["needs_exe_wrapper"] = not can_run(self._conanfile)
270271
if hasattr(conanfile, 'settings_target') and conanfile.settings_target:
271272
settings_target = conanfile.settings_target
272273
os_target = settings_target.get_safe("os")

test/integration/toolchains/meson/test_mesontoolchain.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,3 +903,46 @@ def generate(self):
903903
backend = 'xcode'
904904
""")
905905
assert expected in content
906+
907+
908+
def test_needs_exe_wrapper():
909+
"""
910+
Tests needs_exe_wrapper depends on `can_run()` function instead of
911+
simply checking the cross_building() one.
912+
913+
Issue: https://github.com/conan-io/conan/issues/19217
914+
"""
915+
host = textwrap.dedent("""
916+
[settings]
917+
arch=x86_64
918+
build_type=Release
919+
compiler=apple-clang
920+
compiler.cppstd=gnu17
921+
compiler.libcxx=libc++
922+
compiler.version=16
923+
os=Macos
924+
[conf]
925+
tools.apple:sdk_path=/my/sdk/path
926+
tools.build.cross_building:can_run=True
927+
""")
928+
build = textwrap.dedent("""
929+
[settings]
930+
arch=armv8
931+
build_type=Release
932+
compiler=apple-clang
933+
compiler.cppstd=gnu17
934+
compiler.libcxx=libc++
935+
compiler.version=16
936+
os=Macos
937+
""")
938+
client = TestClient()
939+
client.save({
940+
"host": host,
941+
"build": build,
942+
"conanfile.py": GenConanfile("pkg", "1.0")
943+
.with_settings("os", "arch", "compiler", "build_type")
944+
.with_generator("MesonToolchain")
945+
})
946+
client.run("install . -pr:h host -pr:b build")
947+
content = client.load(MesonToolchain.cross_filename)
948+
assert "needs_exe_wrapper = false" in content

0 commit comments

Comments
 (0)