From d2a4309006f06da42c165bb24d94071833244e35 Mon Sep 17 00:00:00 2001 From: Carlos Zoido Date: Fri, 25 Mar 2022 11:04:43 +0100 Subject: [PATCH] Add ios_version subsetting for catalyst to generate the correct --target triple (#10880) * add ios_version subsetting for catalyst * fix test --- conan/tools/_compilers.py | 3 ++- conans/client/build/compiler_flags.py | 3 ++- conans/client/conf/__init__.py | 20 +++++++++++-------- conans/client/migrations_settings.py | 20 +++++++++++-------- .../build_helpers/autotools_apple_test.py | 4 ++-- .../gnu/autotools/test_apple_toolchain.py | 4 ++-- .../client/build/compiler_flags_test.py | 10 ++++++---- 7 files changed, 38 insertions(+), 26 deletions(-) diff --git a/conan/tools/_compilers.py b/conan/tools/_compilers.py index c96521eaa27..5a4cc410c54 100644 --- a/conan/tools/_compilers.py +++ b/conan/tools/_compilers.py @@ -11,6 +11,7 @@ def architecture_flag(settings): arch = settings.get_safe("arch") the_os = settings.get_safe("os") subsystem = settings.get_safe("os.subsystem") + subsystem_ios_version = settings.get_safe("os.subsystem.ios_version") if not compiler or not arch: return "" @@ -22,7 +23,7 @@ def architecture_flag(settings): # FIXME: This might be conflicting with Autotools --target cli arg apple_arch = to_apple_arch(arch) if apple_arch: - return '--target=%s-apple-ios-macabi' % apple_arch + return '--target=%s-apple-ios%s-macabi' % (apple_arch, subsystem_ios_version) elif str(arch) in ['x86_64', 'sparcv9', 's390x']: return '-m64' elif str(arch) in ['x86', 'sparc']: diff --git a/conans/client/build/compiler_flags.py b/conans/client/build/compiler_flags.py index f7ef3646849..fe60015f9c5 100644 --- a/conans/client/build/compiler_flags.py +++ b/conans/client/build/compiler_flags.py @@ -43,6 +43,7 @@ def architecture_flag(settings): arch = settings.get_safe("arch") the_os = settings.get_safe("os") subsystem = settings.get_safe("os.subsystem") + subsystem_ios_version = settings.get_safe("os.subsystem.ios_version") if not compiler or not arch: return "" @@ -50,7 +51,7 @@ def architecture_flag(settings): if str(the_os) == 'Macos' and str(subsystem) == 'catalyst': apple_arch = to_apple_arch(arch) if apple_arch: - return '--target=%s-apple-ios-macabi' % apple_arch + return '--target=%s-apple-ios%s-macabi' % (apple_arch, subsystem_ios_version) elif str(arch) in ['x86_64', 'sparcv9', 's390x']: return '-m64' elif str(arch) in ['x86', 'sparc']: diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py index 979e4baf066..1135c527394 100644 --- a/conans/client/conf/__init__.py +++ b/conans/client/conf/__init__.py @@ -34,15 +34,9 @@ platform: ANY version: ["5.0", "6.0", "7.0", "8.0"] Linux: - Macos: - version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "12.0", "13.0"] - sdk: [None, "macosx"] - sdk_version: [None, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1", "12.3"] - subsystem: [None, catalyst] - Android: - api_level: ANY iOS: - version: ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", + version: &ios_version + ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", "11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7", "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", "14.8", @@ -64,6 +58,16 @@ sdk: [None, "appletvos", "appletvsimulator"] sdk_version: [None, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4", "13.0", "13.1", "13.2", "13.4", "14.0", "14.2", "14.3", "14.5", "15.0", "15.2", "15.4"] + Macos: + version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "12.0", "13.0"] + sdk: [None, "macosx"] + sdk_version: [None, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1", "12.3"] + subsystem: + None: + catalyst: + ios_version: *ios_version + Android: + api_level: ANY FreeBSD: SunOS: AIX: diff --git a/conans/client/migrations_settings.py b/conans/client/migrations_settings.py index f9a12dd4333..efea50fb15e 100644 --- a/conans/client/migrations_settings.py +++ b/conans/client/migrations_settings.py @@ -3424,15 +3424,9 @@ platform: ANY version: ["5.0", "6.0", "7.0", "8.0"] Linux: - Macos: - version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "12.0", "13.0"] - sdk: [None, "macosx"] - sdk_version: [None, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1", "12.3"] - subsystem: [None, catalyst] - Android: - api_level: ANY iOS: - version: ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", + version: &ios_version + ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", "11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7", "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", "14.8", @@ -3454,6 +3448,16 @@ sdk: [None, "appletvos", "appletvsimulator"] sdk_version: [None, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4", "13.0", "13.1", "13.2", "13.4", "14.0", "14.2", "14.3", "14.5", "15.0", "15.2", "15.4"] + Macos: + version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "12.0", "13.0"] + sdk: [None, "macosx"] + sdk_version: [None, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1", "12.3"] + subsystem: + None: + catalyst: + ios_version: *ios_version + Android: + api_level: ANY FreeBSD: SunOS: AIX: diff --git a/conans/test/functional/build_helpers/autotools_apple_test.py b/conans/test/functional/build_helpers/autotools_apple_test.py index 6f1045602dc..e68127762a8 100644 --- a/conans/test/functional/build_helpers/autotools_apple_test.py +++ b/conans/test/functional/build_helpers/autotools_apple_test.py @@ -82,7 +82,6 @@ def test_makefile_arch(self, arch, os_, os_version): self.assertIn("architecture: %s" % expected_arch, self.t.out) @parameterized.expand([("x86_64",), ("armv8",)]) - @pytest.mark.xfail(reason="Disabled until fix apple-clang 13.1 and --target value for catalyst") def test_catalyst(self, arch): profile = textwrap.dedent(""" include(default) @@ -91,6 +90,7 @@ def test_catalyst(self, arch): os.version = 12.0 os.sdk = macosx os.subsystem = catalyst + os.subsystem.ios_version = 13.1 arch = {arch} """).format(arch=arch) @@ -137,4 +137,4 @@ def test_catalyst(self, arch): if arch == "x86_64": self.t.run_command('"%s"' % app) - self.assertIn("running catalyst 130000", self.t.out) + self.assertIn("running catalyst 130100", self.t.out) diff --git a/conans/test/functional/toolchains/gnu/autotools/test_apple_toolchain.py b/conans/test/functional/toolchains/gnu/autotools/test_apple_toolchain.py index ae7adc4c8d1..5836c8e0438 100644 --- a/conans/test/functional/toolchains/gnu/autotools/test_apple_toolchain.py +++ b/conans/test/functional/toolchains/gnu/autotools/test_apple_toolchain.py @@ -80,7 +80,6 @@ def test_makefile_arch(config): @pytest.mark.skipif(platform.system() != "Darwin", reason="Only OSX") @pytest.mark.parametrize("arch", ["x86_64", "armv8"]) -@pytest.mark.xfail(reason="Disabled until fix apple-clang 13.1 and --target value for catalyst") def test_catalyst(arch): profile = textwrap.dedent(""" include(default) @@ -89,6 +88,7 @@ def test_catalyst(arch): os.version = 13.0 os.sdk = macosx os.subsystem = catalyst + os.subsystem.ios_version = 13.1 arch = {arch} """).format(arch=arch) @@ -135,4 +135,4 @@ def test_catalyst(arch): if arch == "x86_64": t.run_command('"%s"' % app) - assert "running catalyst 130000" in t.out + assert "running catalyst 130100" in t.out diff --git a/conans/test/unittests/client/build/compiler_flags_test.py b/conans/test/unittests/client/build/compiler_flags_test.py index 74d93bb3947..d9a4d1961bd 100644 --- a/conans/test/unittests/client/build/compiler_flags_test.py +++ b/conans/test/unittests/client/build/compiler_flags_test.py @@ -47,14 +47,16 @@ def test_catalyst(self): settings = MockSettings({"compiler": "apple-clang", "arch": "x86_64", "os": "Macos", - "os.subsystem": "catalyst"}) - self.assertEqual(architecture_flag(settings), "--target=x86_64-apple-ios-macabi") + "os.subsystem": "catalyst", + "os.subsystem.ios_version": "13.1"}) + self.assertEqual(architecture_flag(settings), "--target=x86_64-apple-ios13.1-macabi") settings = MockSettings({"compiler": "apple-clang", "arch": "armv8", "os": "Macos", - "os.subsystem": "catalyst"}) - self.assertEqual(architecture_flag(settings), "--target=arm64-apple-ios-macabi") + "os.subsystem": "catalyst", + "os.subsystem.ios_version": "13.1"}) + self.assertEqual(architecture_flag(settings), "--target=arm64-apple-ios13.1-macabi") @parameterized.expand([("gcc", "x86", "-m32"), ("gcc", "x86_64", "-m64"),