Repository: conan-io/conan

Issue:
[feature] Make Qbs generator transitive
Currently the Qbs generator creates Products for every required package. But it does not create [dependencies](https://doc.qt.io/qbs/qml-qbslanguageitems-depends.html) between the different required packages. This leads to two problems:
*  if you have a big project with many dependencies it cludders the project files
*  Qbs cannot track dependencies and may mess up the library order when linking

- [x] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).



Discussion:

Resolving patch:
diff --git a/conans/client/generators/qbs.py b/conans/client/generators/qbs.py
--- a/conans/client/generators/qbs.py
+++ b/conans/client/generators/qbs.py
@@ -9,7 +9,7 @@ def __init__(self, cpp_info):
                                             for p in cpp_info.include_paths)
         self.lib_paths = delimiter.join('"%s"' % p.replace("\\", "/")
                                         for p in cpp_info.lib_paths)
-        self.libs = delimiter.join('"%s"' % l for l in (cpp_info.libs + cpp_info.system_libs))
+        self.libs = delimiter.join('"%s"' % lib for lib in (cpp_info.libs + cpp_info.system_libs))
         self.framework_paths = delimiter.join('"%s"' % p.replace("\\", "/")
                                               for p in cpp_info.framework_paths)
         self.frameworks = delimiter.join('"%s"' % f for f in cpp_info.frameworks)
@@ -26,6 +26,8 @@ def __init__(self, cpp_info):
 
 
 class QbsGenerator(Generator):
+    name = "qbs"
+
     @property
     def filename(self):
         return BUILD_INFO_QBS
@@ -48,17 +50,24 @@ def content(self):
                     '            cpp.cxxFlags: [{deps.cxxflags}]\n'
                     '            cpp.cFlags: [{deps.cflags}]\n'
                     '            cpp.linkerFlags: [{deps.linkerFlags}]\n'
+                    '{depends_items}'
                     '        }}\n'
                     '    }}\n')
 
+        depends_template = '            Depends {{ name: "{dep}" }}\n'
+
         sections = []
-        all_flags = template.format(dep="ConanBasicSetup", deps=deps)
+        all_flags = template.format(dep="ConanBasicSetup", deps=deps, depends_items="")
         sections.append(all_flags)
         template_deps = template + '    // {dep} root path: {deps.rootpath}\n'
 
         for dep_name, dep_cpp_info in self.deps_build_info.dependencies:
             deps = DepsCppQbs(dep_cpp_info)
-            dep_flags = template_deps.format(dep=dep_name, deps=deps)
+            depends_items = ""
+            for public_dep in dep_cpp_info.public_deps:
+                name = self.deps_build_info[public_dep].get_name(QbsGenerator.name)
+                depends_items += depends_template.format(dep=name)
+            dep_flags = template_deps.format(dep=dep_name, deps=deps, depends_items=depends_items)
             sections.append(dep_flags)
 
         output = 'import qbs 1.0\n\nProject {\n'


Test patch:
diff --git a/conans/test/functional/generators/qbs_test.py b/conans/test/functional/generators/qbs_test.py
new file mode 100644
--- /dev/null
+++ b/conans/test/functional/generators/qbs_test.py
@@ -0,0 +1,19 @@
+import unittest
+
+from conans.test.utils.genconanfile import GenConanfile
+from conans.test.utils.tools import TestClient
+
+
+class QbsGeneratorTest(unittest.TestCase):
+
+    def test(self):
+        client = TestClient()
+
+        client.run("new dep/0.1 -b")
+        client.run("create . user/testing")
+        pkg = GenConanfile("pkg", "0.1").with_requires("dep/0.1@user/testing")
+        client.save({"conanfile.py": pkg}, clean_first=True)
+        client.run("create . user/testing")
+        client.run("install pkg/0.1@user/testing -g=qbs")
+        qbs = client.load("conanbuildinfo.qbs")
+        self.assertIn('Depends { name: "dep" }', qbs)