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

Rename QbsToolchain to QbsProfile #8537

Merged
merged 3 commits into from
Feb 22, 2021
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: 2 additions & 1 deletion conan/tools/qbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from conan.tools.qbs.qbstoolchain import QbsToolchain
from conan.tools.qbs.qbsprofile import QbsProfile
from conan.tools.qbs.qbsprofile import QbsProfile as QbsToolchain
from conan.tools.qbs.qbs import Qbs
10 changes: 5 additions & 5 deletions conan/tools/qbs/qbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _configuration_dict_to_commandlist(name, config_dict):
class Qbs(object):
def __init__(self, conanfile, project_file=None):
# hardcoded name, see qbs toolchain
self.use_toolchain_profile = 'conan_toolchain_profile'
self.profile = 'conan_toolchain_profile'
self._conanfile = conanfile
self._set_project_file(project_file)
self.jobs = tools.cpu_count()
Expand Down Expand Up @@ -52,8 +52,8 @@ def build(self, products=None):

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

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

for name in self._configuration:
config = self._configuration[name]
Expand All @@ -72,8 +72,8 @@ def build_all(self):

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

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

for name in self._configuration:
config = self._configuration[name]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ def _flags_from_env():
return flags_from_env


class QbsToolchain(object):
filename = 'conan_toolchain.qbs'
class QbsProfile(object):
filename = 'conan_toolchain_profile.qbs'
old_filename = 'conan_toolchain.qbs'

_template_toolchain = textwrap.dedent('''\
import qbs
Expand Down Expand Up @@ -266,6 +267,7 @@ def __init__(self, conanfile):
conanfile.options.get_safe('fPIC'))

def generate(self):
save(self.old_filename, self.content)
save(self.filename, self.content)

@property
Expand Down
8 changes: 4 additions & 4 deletions conans/test/unittests/client/build/qbs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ def test_build(self):
('qbs build --no-install --build-directory %s '
'--file %s --jobs %s profile:%s') % (
conanfile.build_folder, build_helper._project_file,
build_helper.jobs, build_helper.use_toolchain_profile))
build_helper.jobs, build_helper.profile))

build_helper.build(products=['app1', 'app2', 'lib'])
self.assertEqual(
conanfile.runner.command_called,
('qbs build --no-install --build-directory %s '
'--file %s --products app1,app2,lib --jobs %s profile:%s') % (
conanfile.build_folder, build_helper._project_file,
build_helper.jobs, build_helper.use_toolchain_profile))
build_helper.jobs, build_helper.profile))

def test_build_all(self):
conanfile = MockConanfile(
Expand All @@ -123,7 +123,7 @@ def test_build_all(self):
('qbs build --no-install --build-directory %s '
'--file %s --all-products --jobs %s profile:%s') % (
conanfile.build_folder, build_helper._project_file,
build_helper.jobs, build_helper.use_toolchain_profile))
build_helper.jobs, build_helper.profile))

@unittest.skipIf(six.PY2, "Order of qbs output is defined only for PY3")
def test_build_with_custom_configuration(self):
Expand All @@ -148,7 +148,7 @@ def test_build_with_custom_configuration(self):
'--file %s --jobs %s profile:%s '
'config:%s %s:%s %s:%s %s:%s %s:%s') % (
conanfile.build_folder, build_helper._project_file,
build_helper.jobs, build_helper.use_toolchain_profile,
build_helper.jobs, build_helper.profile,
config_name,
'product.App.boolProperty',
'true',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import six

import conan.tools.qbs.qbstoolchain as qbs
import conan.tools.qbs.qbsprofile as qbs

from conans import tools
from conans.errors import ConanException
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_convert_build_variant(self):
'os': 'Linux',
'compiler': 'gcc'}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._build_variant, None)

for build_type, build_variant in qbs._build_variant.items():
Expand All @@ -67,15 +67,15 @@ def test_convert_build_variant(self):
'compiler': 'gcc',
'build_type': build_type}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._build_variant, build_variant)

def test_convert_architecture(self):
conanfile = MockConanfileWithFolders(MockSettings({
'os': 'Linux',
'compiler': 'gcc'}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._architecture, None)

for arch, architecture in qbs._architecture.items():
Expand All @@ -84,15 +84,15 @@ def test_convert_architecture(self):
'compiler': 'gcc',
'arch': arch}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._architecture, architecture)

def test_convert_optimization(self):
conanfile = MockConanfileWithFolders(MockSettings({
'os': 'Linux',
'compiler': 'gcc'}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._optimization, None)

for build_type, optimization in qbs._optimization.items():
Expand All @@ -101,7 +101,7 @@ def test_convert_optimization(self):
'compiler': 'gcc',
'build_type': build_type}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._optimization, optimization)

def test_use_sysroot_from_env(self):
Expand All @@ -111,7 +111,7 @@ def test_use_sysroot_from_env(self):

sysroot = '/path/to/sysroot/foo/bar'
with tools.environment_append({'SYSROOT': sysroot}):
qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._sysroot, sysroot)

def test_detect_fpic_from_options(self):
Expand All @@ -130,22 +130,22 @@ def test_detect_fpic_from_options(self):
'fPIC': option
}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._position_independent_code, value)

def test_convert_cxx_language_version(self):
conanfile = MockConanfileWithFolders(MockSettings({
'os': 'Linux',
'compiler': 'gcc'}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._cxx_language_version, None)
conanfile = MockConanfileWithFolders(MockSettings({
'os': 'Linux',
'compiler': 'gcc',
'compiler.cppstd': 17}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._cxx_language_version, 'c++17')

for cppstd, cxx_language_version in qbs._cxx_language_version.items():
Expand All @@ -154,23 +154,23 @@ def test_convert_cxx_language_version(self):
'compiler': 'gcc',
'compiler.cppstd': cppstd}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._cxx_language_version,
cxx_language_version)

def test_convert_target_platform(self):
conanfile = MockConanfileWithFolders(MockSettings({
'compiler': 'gcc'}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._target_platform, None)

for os, target_platform in qbs._target_platform.items():
conanfile = MockConanfileWithFolders(MockSettings({
'os': os,
'compiler': 'gcc'}))

qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)
self.assertEqual(qbs_toolchain._target_platform,
target_platform)

Expand Down Expand Up @@ -408,6 +408,6 @@ def test_toolchain_content(self):
]))

with tools.environment_append({'SYSROOT': '/foo/bar/path'}):
qbs_toolchain = qbs.QbsToolchain(conanfile)
qbs_toolchain = qbs.QbsProfile(conanfile)

self.assertEqual(qbs_toolchain.content, expected_content)