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

Qbs: add explicit resolve method #16449

Merged
merged 2 commits into from
Jun 12, 2024
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
2 changes: 2 additions & 0 deletions conan/internal/api/new/qbs_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def build(self):
qbs = Qbs(self)
qbs_config = {"products.{{name}}.isShared": "true" if self.options.shared else "false"}
qbs.add_configuration("default", qbs_config)
qbs.resolve()
qbs.build()

def package(self):
Expand Down Expand Up @@ -67,6 +68,7 @@ def requirements(self):

def build(self):
qbs = Qbs(self)
qbs.resolve()
qbs.build()
qbs.install()

Expand Down
25 changes: 20 additions & 5 deletions conan/tools/qbs/qbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,26 @@ def _get_common_arguments(self):
'--file', self._project_file,
]

def resolve(self, parallel=True):
args = self._get_common_arguments()

if parallel:
args.extend(['--jobs', '%s' % self.jobs])
else:
args.extend(['--jobs', '1'])

if self.profile:
args.append('profile:%s' % self.profile)

for name in self._configuration:
config = self._configuration[name]
args.extend(_configuration_dict_to_commandlist(name, config))

cmd = 'qbs resolve %s' % cmd_args_to_string(args)
self._conanfile.run(cmd)

def _build(self, products, all_products):

args = self._get_common_arguments()
args.append('--no-install')

Expand All @@ -55,12 +74,8 @@ def _build(self, products, all_products):

args.extend(['--jobs', '%s' % self.jobs])

if self.profile:
args.append('profile:%s' % self.profile)

for name in self._configuration:
config = self._configuration[name]
args.extend(_configuration_dict_to_commandlist(name, config))
args.append('config:%s' % name)

cmd = 'qbs build %s' % cmd_args_to_string(args)
self._conanfile.run(cmd)
Expand Down
3 changes: 3 additions & 0 deletions test/functional/toolchains/qbs/test_qbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Recipe(ConanFile):

def build(self):
qbs = Qbs(self)
qbs.resolve()
qbs.build_all()
''')

Expand Down Expand Up @@ -89,6 +90,7 @@ class Recipe(ConanFile):

def build(self):
qbs = Qbs(self)
qbs.resolve()
qbs.build(products=["hello", "hello"])
''')

Expand Down Expand Up @@ -130,6 +132,7 @@ def build(self):
qbs = Qbs(self)
qbs.add_configuration("release", {"qbs.debugInformation": False})
qbs.add_configuration("debug", {"qbs.debugInformation": True})
qbs.resolve()
qbs.build()
''')

Expand Down