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

Do not add transitive deps to conandeps.xcconfig #14898

Merged
merged 1 commit into from
Oct 10, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions conan/tools/apple/xcodedeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
47 changes: 47 additions & 0 deletions conans/test/integration/toolchains/apple/test_xcodedeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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