From 0164582a6457bf9e019a4dc727c7df2eef01279f Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 9 Oct 2023 17:26:51 +0200 Subject: [PATCH] not add transitive deps to conandeps.xcconfig --- conan/tools/apple/xcodedeps.py | 3 -- .../toolchains/apple/test_xcodedeps.py | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/conan/tools/apple/xcodedeps.py b/conan/tools/apple/xcodedeps.py index 73a4fc04995..369e025ef63 100644 --- a/conan/tools/apple/xcodedeps.py +++ b/conan/tools/apple/xcodedeps.py @@ -323,10 +323,7 @@ def _transitive_components(component): result["conan_{}.xcconfig".format(dep_name)] = self._pkg_xconfig_file(include_components_names) - # Include transitive requires all_file_content = "" - for require, dep in requires: - all_file_content = self._all_xconfig_file(get_transitive_requires(self._conanfile, dep), all_file_content) # Include direct requires direct_deps = self._conanfile.dependencies.filter({"direct": True, "build": False, "skip": False}) diff --git a/conans/test/integration/toolchains/apple/test_xcodedeps.py b/conans/test/integration/toolchains/apple/test_xcodedeps.py index 664418c14d3..09489b79da4 100644 --- a/conans/test/integration/toolchains/apple/test_xcodedeps.py +++ b/conans/test/integration/toolchains/apple/test_xcodedeps.py @@ -534,3 +534,50 @@ def test_skipped_not_included(): assert re.search(r"Skipped binaries\n\s+(.*?)", client.out, re.DOTALL) dep_xconfig = client.load("consumer/conan_pkg_pkg.xcconfig") assert "conan_dep.xcconfig" not in dep_xconfig + + +def test_correctly_handle_transitive_components(): + # https://github.com/conan-io/conan/issues/14887 + client = TestClient() + has_components = textwrap.dedent(""" + from conan import ConanFile + class PkgWithComponents(ConanFile): + name = 'has_components' + version = '1.0' + settings = 'os', 'compiler', 'arch', 'build_type' + def package_info(self): + self.cpp_info.components['first'].libs = ['first'] + self.cpp_info.components['second'].libs = ['donottouch'] + self.cpp_info.components['second'].requires = ['first'] + """) + + uses_components = textwrap.dedent(""" + from conan import ConanFile + class PkgUsesComponent(ConanFile): + name = 'uses_components' + version = '1.0' + settings = 'os', 'compiler', 'arch', 'build_type' + def requirements(self): + self.requires('has_components/1.0') + def package_info(self): + self.cpp_info.libs = ['uses_only_first'] + self.cpp_info.requires = ['has_components::first'] + """) + + consumer = textwrap.dedent(""" + [requires] + uses_components/1.0 + """) + + client.save({"has_components.py": has_components, + "uses_components.py": uses_components, + "consumer.txt": consumer}) + client.run("create has_components.py") + client.run("create uses_components.py") + client.run("install consumer.txt -g XcodeDeps") + conandeps = client.load("conandeps.xcconfig") + assert '#include "conan_has_components.xcconfig"' not in conandeps + assert '#include "conan_uses_components.xcconfig"' in conandeps + conan_uses_xcconfig = client.load("conan_uses_components_uses_components.xcconfig") + assert '#include "conan_has_components_first.xcconfig"' in conan_uses_xcconfig + assert '#include "conan_has_components_second.xcconfig"' not in conan_uses_xcconfig