From 60d76e05003a25f127118a23b1564fa487dd9449 Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Sun, 21 Feb 2021 18:12:18 +0100 Subject: [PATCH 1/3] Rename QbsToolchain to QbsProfile This generator generates a qbs profile. Renaming the class from Toolchain to Profile makes this more obvious. --- conan/tools/qbs/__init__.py | 3 +- .../qbs/{qbstoolchain.py => qbsprofile.py} | 6 ++-- ...est_qbs_generic.py => test_qbs_profile.py} | 30 +++++++++---------- 3 files changed, 21 insertions(+), 18 deletions(-) rename conan/tools/qbs/{qbstoolchain.py => qbsprofile.py} (98%) rename conans/test/unittests/client/toolchain/{test_qbs_generic.py => test_qbs_profile.py} (95%) diff --git a/conan/tools/qbs/__init__.py b/conan/tools/qbs/__init__.py index 102e73a682e..0b2f63f7d57 100644 --- a/conan/tools/qbs/__init__.py +++ b/conan/tools/qbs/__init__.py @@ -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 diff --git a/conan/tools/qbs/qbstoolchain.py b/conan/tools/qbs/qbsprofile.py similarity index 98% rename from conan/tools/qbs/qbstoolchain.py rename to conan/tools/qbs/qbsprofile.py index b988ad98aa2..5fce6b3ae1e 100644 --- a/conan/tools/qbs/qbstoolchain.py +++ b/conan/tools/qbs/qbsprofile.py @@ -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 @@ -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 diff --git a/conans/test/unittests/client/toolchain/test_qbs_generic.py b/conans/test/unittests/client/toolchain/test_qbs_profile.py similarity index 95% rename from conans/test/unittests/client/toolchain/test_qbs_generic.py rename to conans/test/unittests/client/toolchain/test_qbs_profile.py index b7c7f39c109..064970aa4ff 100644 --- a/conans/test/unittests/client/toolchain/test_qbs_generic.py +++ b/conans/test/unittests/client/toolchain/test_qbs_profile.py @@ -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 @@ -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(): @@ -67,7 +67,7 @@ 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): @@ -75,7 +75,7 @@ def test_convert_architecture(self): '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(): @@ -84,7 +84,7 @@ 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): @@ -92,7 +92,7 @@ def test_convert_optimization(self): '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(): @@ -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): @@ -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): @@ -130,7 +130,7 @@ 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): @@ -138,14 +138,14 @@ def test_convert_cxx_language_version(self): '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(): @@ -154,7 +154,7 @@ 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) @@ -162,7 +162,7 @@ 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(): @@ -170,7 +170,7 @@ def test_convert_target_platform(self): 'os': os, 'compiler': 'gcc'})) - qbs_toolchain = qbs.QbsToolchain(conanfile) + qbs_toolchain = qbs.QbsProfile(conanfile) self.assertEqual(qbs_toolchain._target_platform, target_platform) @@ -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) From 9b4ba1f175fa97a43320a0f31c1b2f7b2051022a Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Sun, 21 Feb 2021 18:21:04 +0100 Subject: [PATCH 2/3] Rename `use_toolchain_profile` to `use_profile` The qbs profiles are names `profile` not `toolchain_profile`. Rename to make this clear. --- conan/tools/qbs/qbs.py | 10 +++++----- conans/test/unittests/client/build/qbs_test.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conan/tools/qbs/qbs.py b/conan/tools/qbs/qbs.py index 8fd77a990c3..858002a5de8 100644 --- a/conan/tools/qbs/qbs.py +++ b/conan/tools/qbs/qbs.py @@ -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.use_profile = 'conan_toolchain_profile' self._conanfile = conanfile self._set_project_file(project_file) self.jobs = tools.cpu_count() @@ -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.use_profile: + args.append('profile:%s' % self.use_profile) for name in self._configuration: config = self._configuration[name] @@ -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.use_profile: + args.append('profile:%s' % self.use_profile) for name in self._configuration: config = self._configuration[name] diff --git a/conans/test/unittests/client/build/qbs_test.py b/conans/test/unittests/client/build/qbs_test.py index f18a58de811..4f235217185 100644 --- a/conans/test/unittests/client/build/qbs_test.py +++ b/conans/test/unittests/client/build/qbs_test.py @@ -99,7 +99,7 @@ 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.use_profile)) build_helper.build(products=['app1', 'app2', 'lib']) self.assertEqual( @@ -107,7 +107,7 @@ def test_build(self): ('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.use_profile)) def test_build_all(self): conanfile = MockConanfile( @@ -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.use_profile)) @unittest.skipIf(six.PY2, "Order of qbs output is defined only for PY3") def test_build_with_custom_configuration(self): @@ -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.use_profile, config_name, 'product.App.boolProperty', 'true', From a8d28a35c67b600fb3f51dec83175703813ddb8e Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Sun, 21 Feb 2021 18:37:19 +0100 Subject: [PATCH 3/3] Rename use_profile to just profile --- conan/tools/qbs/qbs.py | 10 +++++----- conans/test/unittests/client/build/qbs_test.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conan/tools/qbs/qbs.py b/conan/tools/qbs/qbs.py index 858002a5de8..62c3a2133c1 100644 --- a/conan/tools/qbs/qbs.py +++ b/conan/tools/qbs/qbs.py @@ -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_profile = 'conan_toolchain_profile' + self.profile = 'conan_toolchain_profile' self._conanfile = conanfile self._set_project_file(project_file) self.jobs = tools.cpu_count() @@ -52,8 +52,8 @@ def build(self, products=None): args.extend(['--jobs', '%s' % self.jobs]) - if self.use_profile: - args.append('profile:%s' % self.use_profile) + if self.profile: + args.append('profile:%s' % self.profile) for name in self._configuration: config = self._configuration[name] @@ -72,8 +72,8 @@ def build_all(self): args.extend(['--jobs', '%s' % self.jobs]) - if self.use_profile: - args.append('profile:%s' % self.use_profile) + if self.profile: + args.append('profile:%s' % self.profile) for name in self._configuration: config = self._configuration[name] diff --git a/conans/test/unittests/client/build/qbs_test.py b/conans/test/unittests/client/build/qbs_test.py index 4f235217185..e5163f5b047 100644 --- a/conans/test/unittests/client/build/qbs_test.py +++ b/conans/test/unittests/client/build/qbs_test.py @@ -99,7 +99,7 @@ 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_profile)) + build_helper.jobs, build_helper.profile)) build_helper.build(products=['app1', 'app2', 'lib']) self.assertEqual( @@ -107,7 +107,7 @@ def test_build(self): ('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_profile)) + build_helper.jobs, build_helper.profile)) def test_build_all(self): conanfile = MockConanfile( @@ -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_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): @@ -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_profile, + build_helper.jobs, build_helper.profile, config_name, 'product.App.boolProperty', 'true',