From 330c6a8f4f57b390aa0a56bca696168034cf0c44 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 24 Feb 2023 11:48:16 -0500 Subject: [PATCH 1/4] Fix macOS -> Linux cross cflag resolution --- conan/tools/gnu/autotoolstoolchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conan/tools/gnu/autotoolstoolchain.py b/conan/tools/gnu/autotoolstoolchain.py index 74f4470b5b1..0a1164f63d6 100644 --- a/conan/tools/gnu/autotoolstoolchain.py +++ b/conan/tools/gnu/autotoolstoolchain.py @@ -76,7 +76,7 @@ def __init__(self, conanfile, namespace=None, prefix="/"): # Build triplet self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler) # Apple Stuff - if os_build == "Macos": + if os_host == "Macos": # SDK path is mandatory for cross-building sdk_path = apple_sdk_path(self._conanfile) if not sdk_path: From 3a3328e1be1d65cd634311027caa0a28e7130f62 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Fri, 24 Feb 2023 11:57:03 -0500 Subject: [PATCH 2/4] Handle all apple OSes --- conan/tools/gnu/autotoolstoolchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conan/tools/gnu/autotoolstoolchain.py b/conan/tools/gnu/autotoolstoolchain.py index 0a1164f63d6..44d4f4bd8af 100644 --- a/conan/tools/gnu/autotoolstoolchain.py +++ b/conan/tools/gnu/autotoolstoolchain.py @@ -76,7 +76,7 @@ def __init__(self, conanfile, namespace=None, prefix="/"): # Build triplet self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler) # Apple Stuff - if os_host == "Macos": + if os_host in ["Macos", "iOS", "watchOS", "tvOS"]: # SDK path is mandatory for cross-building sdk_path = apple_sdk_path(self._conanfile) if not sdk_path: From bc7e7cc8d16a195ca929a3a5f2453ca2dd0bf789 Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Mon, 13 Mar 2023 15:57:40 +0000 Subject: [PATCH 3/4] Conditional on os_build being macOS and host OS being an apple OS --- conan/tools/gnu/autotoolstoolchain.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conan/tools/gnu/autotoolstoolchain.py b/conan/tools/gnu/autotoolstoolchain.py index 44d4f4bd8af..b44308132a2 100644 --- a/conan/tools/gnu/autotoolstoolchain.py +++ b/conan/tools/gnu/autotoolstoolchain.py @@ -1,5 +1,5 @@ from conan.internal import check_duplicated_generator -from conan.tools.apple.apple import apple_min_version_flag, to_apple_arch, apple_sdk_path +from conan.tools.apple.apple import apple_min_version_flag, is_apple_os, to_apple_arch, apple_sdk_path from conan.tools.apple.apple import get_apple_sdk_fullname from conan.tools.build import cmd_args_to_string, save_toolchain_args from conan.tools.build.cross_building import cross_building @@ -76,7 +76,7 @@ def __init__(self, conanfile, namespace=None, prefix="/"): # Build triplet self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler) # Apple Stuff - if os_host in ["Macos", "iOS", "watchOS", "tvOS"]: + if os_build == "Macos" and is_apple_os(conanfile): # SDK path is mandatory for cross-building sdk_path = apple_sdk_path(self._conanfile) if not sdk_path: From 291f1ffb03b11408a17cab1be96acefcc106b02e Mon Sep 17 00:00:00 2001 From: Luis Caro Campos <3535649+jcar87@users.noreply.github.com> Date: Tue, 14 Mar 2023 11:23:09 +0000 Subject: [PATCH 4/4] AutootolsToolchain: add test to ensure we don't Apple-flags when targetting non-Apple OS --- .../toolchain/autotools/autotools_toolchain_test.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py b/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py index 5fd1b6c01fa..09a2f0f3fed 100644 --- a/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py +++ b/conans/test/unittests/client/toolchain/autotools/autotools_toolchain_test.py @@ -328,6 +328,19 @@ def test_apple_min_os_flag(): assert expected in env["LDFLAGS"] +def test_crossbuild_from_macos_to_non_apple_os(): + """Check we are not adding Apple-specific flags + when the os_build is Macos, but we are targetting + a non-Apple OS (e.g. Linux, Android, QNX)""" + conanfile = ConanFileMock() + conanfile.settings = MockSettings({"os": "Android", "arch": "armv8"}) + conanfile.settings_build = MockSettings({"os": "Macos", "arch": "armv8"}) + be = AutotoolsToolchain(conanfile) + assert be.apple_min_version_flag == '' + assert be.apple_arch_flag is None + assert be.apple_isysroot_flag is None + + def test_apple_isysrootflag(): """Even when no cross building it is adjusted because it could target a Mac version""" conanfile = ConanFileMock()