From 7c7c2ecdf31c9e1b453ce3ca03f6e4a77c971a9b Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Mon, 11 Jan 2021 14:40:05 +0100 Subject: [PATCH 01/21] Add documentation for qbs build helper --- reference/build_helpers/qbs.rst | 142 ++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 reference/build_helpers/qbs.rst diff --git a/reference/build_helpers/qbs.rst b/reference/build_helpers/qbs.rst new file mode 100644 index 00000000000..8b4cb9902f9 --- /dev/null +++ b/reference/build_helpers/qbs.rst @@ -0,0 +1,142 @@ +.. _qbs_build_reference: + +Qbs +=== + +If you are using **Qbs** as your build system, you can use the **Qbs** build helper. + +.. code-block:: python + + from conans import ConanFile, tools, Qbs + import os + + class ConanFileToolsTest(ConanFile): + ... + + def build(self): + qbs = Qbs(self) + qbs.build() + +Constructor +----------- + +.. code-block:: python + + class Qbs(object): + + def __init__(self, conanfile, project_file=None) + +Parameters: + - **conanfile** (Required): Use ``self`` inside a ``conanfile.py``. + - **project_file** (Optional, Defaulted to ``None``): Path to the root project file. + +Methods +------- + +add_configuration() ++++++++++++ + +.. code-block:: python + + def add_configuration(self, name, values) + +Add a build configuration to use. + +Parameters: + - **name** (Required): Specifies build configuration name. + - **values** (Required): A dict of properties set for this build configuration. + + +build() ++++++++ + +.. code-block:: python + + def build(self, products=None) + +Build Qbs project. + +Parameters: + - **products** (Optional, Defaulted to ``None``): Specifies a list of products to build. If ``None`` build all products which have the qbs property ``buildByDefault`` set to ``true``. + + +build_all() +++++++ + +.. code-block:: python + + def build_all(self) + +Build all products of Qbs project, even products which set the qbs property ``buildByDefault`` set to ``false`` + + +install() ++++++++++ + +.. code-block:: python + + def install(self) + +Install products. + + +Example +------- + +A typical usage of the Qbs build helper, if you want to be able to both execute :command:`conan create` and also build your package for a +library locally (in your user folder, not in the local cache), could be: + +.. code-block:: python + + from conans import ConanFile, Qbs + + class HelloConan(ConanFile): + name = "hello" + version = "0.1" + settings = "os", "compiler", "build_type", "arch" + generators = "qbs" + exports_sources = "src/*", "*.qbs" + no_copy_source = True + requires = "zlib/1.2.11" + + def build(self): + qbs = Qbs(self) + qbs.add_configuration("default", { + "project.Hello.conanBuildInfo", self.build_folder + "/conanbuildinfo.qbs" + }) + qbs.build() + + def package(self): + self.copy("*.h", dst="include", src="src") + self.copy("*.lib", dst="lib", keep_path=False) + self.copy("*.dll", dst="bin", keep_path=False) + self.copy("*.dylib*", dst="lib", keep_path=False) + self.copy("*.so", dst="lib", keep_path=False) + self.copy("*.a", dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["hello"] + +Note the ``qbs`` generator, which generates the *conanbuildinfo.qbs* file, to process +dependencies information. Setting ``no_copy_source = True`` helps qbs to pick the right project file +and not get confused by the generated files. + +The *hello.qbs* could be as simple as: + +.. code-block:: text + + Project { + readonly property path conanBuildInfo + + references: conanBuildInfo + + DynamicLibrary { + name: "hello" + version: "0.1.0" + files: "src/hello.cpp" + cpp.cxxLanguageVersion: "c++11" + + Depends { name: "cpp" } + Depends { name: "zlib" } + } + } From a8200c813870fed90a7ec92809e9a595bb906bce Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Mon, 11 Jan 2021 15:18:40 +0100 Subject: [PATCH 02/21] Add documentation for qbs toolchain --- creating_packages/toolchains/qbs.rst | 68 ++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 creating_packages/toolchains/qbs.rst diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst new file mode 100644 index 00000000000..f11d31aeb58 --- /dev/null +++ b/creating_packages/toolchains/qbs.rst @@ -0,0 +1,68 @@ +.. _conan-qbs-toolchain: + +QbsToolchain +============== + +.. warning:: + + This is an **experimental** feature subject to breaking changes in future releases. + + +The ``QbsToolchain`` can be used in the ``generate()`` method: + + +.. code:: python + + from conans import ConanFile + from conan.tools.meson import QbsToolchain + + class App(ConanFile): + settings = "os", "arch", "compiler", "build_type" + requires = "hello/0.1" + options = {"shared": [True, False]} + default_options = {"shared": False} + + def generate(self): + tc = QbsToolchain(self) + tc.generate() + + +The ``QbsToolchain`` will generate the following file during ``conan install`` +command (or before calling the ``build()`` method when the package is being +built in the cache): ``conan_toolchain.qbs``. This file will contain a qbs profile +named ``conan_toolchain_profile``. + + +``conan_toolchain.qbs`` will contain the definitions of all the Qbs properties +related to the Conan options and settings for the current package, platform, +etc. This includes the following: + +* Detection of compiler + + * Based on the compiler set in environment variable ``CC`` + + * Uses detected system compiler based on Conan setting ``compiler`` if environment variable ``CC`` is not set + +* Detection of compiler flags from environment (as defined at https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html) + + * ``ASFLAGS`` + + * ``CFLAGS`` + + * ``CPPFLAGS`` + + * ``CXXFLAGS`` + + * ``LDFLAGS`` + +* Detection of sysroot from environment + +* Detection of ``build_type`` from Conan settings + +* Detection of ``arch`` from Conan settings + +* Detection of ``compiler.cxxstd`` from Conan settings + +* Detection of ``fPIC`` + + * Based on existance/value of a option named ``fPIC`` From 4e8d013feece763b4246bedffdd5b1718a02df65 Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Mon, 11 Jan 2021 15:19:00 +0100 Subject: [PATCH 03/21] Add documentation for attributes of qbs build helper --- reference/build_helpers/qbs.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/reference/build_helpers/qbs.rst b/reference/build_helpers/qbs.rst index 8b4cb9902f9..a4b5d4fd18f 100644 --- a/reference/build_helpers/qbs.rst +++ b/reference/build_helpers/qbs.rst @@ -30,6 +30,23 @@ Parameters: - **conanfile** (Required): Use ``self`` inside a ``conanfile.py``. - **project_file** (Optional, Defaulted to ``None``): Path to the root project file. +Attributes +---------- + +use_toolchain_profile ++++++++++++++++++++++ + +**Defaulted to**: ``conan_toolchain_profile`` + +Specifies the qbs profile to build the project for. + +jobs +++++ + +**Defaulted to**: ``tools.cpu_count()`` + +Specifies the number of concurrent build jobs. + Methods ------- From badd93191d542efb70b016cab52485b43327d160 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:05:13 +0100 Subject: [PATCH 04/21] Update reference/build_helpers/qbs.rst --- reference/build_helpers/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/build_helpers/qbs.rst b/reference/build_helpers/qbs.rst index a4b5d4fd18f..ade53d3c0a8 100644 --- a/reference/build_helpers/qbs.rst +++ b/reference/build_helpers/qbs.rst @@ -51,7 +51,7 @@ Methods ------- add_configuration() -+++++++++++ ++++++++++++++++++++ .. code-block:: python From d3c17711e9b86c94b59311e4b6fd3b66ec48f5fe Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:05:21 +0100 Subject: [PATCH 05/21] Update reference/build_helpers/qbs.rst --- reference/build_helpers/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/build_helpers/qbs.rst b/reference/build_helpers/qbs.rst index ade53d3c0a8..5a2c79289d6 100644 --- a/reference/build_helpers/qbs.rst +++ b/reference/build_helpers/qbs.rst @@ -78,7 +78,7 @@ Parameters: build_all() -++++++ ++++++++++++ .. code-block:: python From c2251ad3db7f81b2b648a11b81cb5c55d0329ce8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:05:33 +0100 Subject: [PATCH 06/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index f11d31aeb58..9e51cdf7234 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -27,7 +27,7 @@ The ``QbsToolchain`` can be used in the ``generate()`` method: tc.generate() -The ``QbsToolchain`` will generate the following file during ``conan install`` +The ``QbsToolchain`` will generate the following file during :command:`conan install` command (or before calling the ``build()`` method when the package is being built in the cache): ``conan_toolchain.qbs``. This file will contain a qbs profile named ``conan_toolchain_profile``. From c053b7d34512f2da80b22d5a3c9fe3c44dab5069 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:05:40 +0100 Subject: [PATCH 07/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 9e51cdf7234..33f740f25db 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -29,7 +29,7 @@ The ``QbsToolchain`` can be used in the ``generate()`` method: The ``QbsToolchain`` will generate the following file during :command:`conan install` command (or before calling the ``build()`` method when the package is being -built in the cache): ``conan_toolchain.qbs``. This file will contain a qbs profile +built in the cache): *conan_toolchain.qbs*. This file will contain a qbs profile named ``conan_toolchain_profile``. From 8f2a988981606dccd9228e1f48615a3ac002f631 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:05:45 +0100 Subject: [PATCH 08/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 33f740f25db..49f4abb6a10 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -33,7 +33,7 @@ built in the cache): *conan_toolchain.qbs*. This file will contain a qbs profile named ``conan_toolchain_profile``. -``conan_toolchain.qbs`` will contain the definitions of all the Qbs properties +*conan_toolchain.qbs* will contain the definitions of all the Qbs properties related to the Conan options and settings for the current package, platform, etc. This includes the following: From 50b429699140d0ac30d22f6fce981c3e0b43a6eb Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:05:51 +0100 Subject: [PATCH 09/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 49f4abb6a10..69d018b073f 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -30,7 +30,7 @@ The ``QbsToolchain`` can be used in the ``generate()`` method: The ``QbsToolchain`` will generate the following file during :command:`conan install` command (or before calling the ``build()`` method when the package is being built in the cache): *conan_toolchain.qbs*. This file will contain a qbs profile -named ``conan_toolchain_profile``. +named *conan_toolchain_profile*. *conan_toolchain.qbs* will contain the definitions of all the Qbs properties From d6ff2bd5175850440e7410e2c89f577b0b0308a6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:06:19 +0100 Subject: [PATCH 10/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 69d018b073f..c3b5225f403 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -63,6 +63,4 @@ etc. This includes the following: * Detection of ``compiler.cxxstd`` from Conan settings -* Detection of ``fPIC`` - - * Based on existance/value of a option named ``fPIC`` +* Detection of ``fPIC`` based on the existence of such option in the recipe. From 638362dda5056a34deb161684009ced8fdfc0280 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:06:26 +0100 Subject: [PATCH 11/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index c3b5225f403..5036b801053 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -61,6 +61,6 @@ etc. This includes the following: * Detection of ``arch`` from Conan settings -* Detection of ``compiler.cxxstd`` from Conan settings +* Detection of ``compiler.cxxstd`` from Conan settings. * Detection of ``fPIC`` based on the existence of such option in the recipe. From e1131fa2847cfef8193fc92304bcf0a0b600133d Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:06:32 +0100 Subject: [PATCH 12/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 5036b801053..4141e8e20c0 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -57,7 +57,7 @@ etc. This includes the following: * Detection of sysroot from environment -* Detection of ``build_type`` from Conan settings +* Detection of ``build_type`` from Conan settings. * Detection of ``arch`` from Conan settings From a692e6ee67e9b54f1de3e356264dc6772666955b Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:06:38 +0100 Subject: [PATCH 13/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 4141e8e20c0..5157df3e566 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -55,7 +55,7 @@ etc. This includes the following: * ``LDFLAGS`` -* Detection of sysroot from environment +* Detection of sysroot from environment. * Detection of ``build_type`` from Conan settings. From 22b79d90ce97763ecf26c1555d4765138a41ed14 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:06:49 +0100 Subject: [PATCH 14/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 5157df3e566..b91956bade2 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -59,7 +59,7 @@ etc. This includes the following: * Detection of ``build_type`` from Conan settings. -* Detection of ``arch`` from Conan settings +* Detection of ``arch`` from Conan settings. * Detection of ``compiler.cxxstd`` from Conan settings. From dd57116782658319dc0aee6b75f0c1ecb149029c Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:06:57 +0100 Subject: [PATCH 15/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index b91956bade2..889235c5639 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -43,7 +43,7 @@ etc. This includes the following: * Uses detected system compiler based on Conan setting ``compiler`` if environment variable ``CC`` is not set -* Detection of compiler flags from environment (as defined at https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html) +* Detection of compiler flags from environment (as defined at https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html): * ``ASFLAGS`` From e5d87d8e436472dbe5c13da9e65c62f41f0b2429 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:07:02 +0100 Subject: [PATCH 16/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 889235c5639..5047fdcd51d 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -41,7 +41,7 @@ etc. This includes the following: * Based on the compiler set in environment variable ``CC`` - * Uses detected system compiler based on Conan setting ``compiler`` if environment variable ``CC`` is not set + * Uses detected system compiler based on Conan setting ``compiler`` if environment variable ``CC`` is not set. * Detection of compiler flags from environment (as defined at https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html): From fdd2b287d40b5f79c34e59cc9fbfe302524c24cc Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:07:08 +0100 Subject: [PATCH 17/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 5047fdcd51d..ef3f0776459 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -37,7 +37,7 @@ named *conan_toolchain_profile*. related to the Conan options and settings for the current package, platform, etc. This includes the following: -* Detection of compiler + * Detection of compiler. * Based on the compiler set in environment variable ``CC`` From 4fb7ddacbc006c0a8179a8500fe06c39e30451b6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 13 Jan 2021 18:07:13 +0100 Subject: [PATCH 18/21] Update creating_packages/toolchains/qbs.rst --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index ef3f0776459..9fe63119bbc 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -39,7 +39,7 @@ etc. This includes the following: * Detection of compiler. - * Based on the compiler set in environment variable ``CC`` + * Based on the compiler set in environment variable ``CC``. * Uses detected system compiler based on Conan setting ``compiler`` if environment variable ``CC`` is not set. From c27f41115ca43c2b4666c868493900711e8ecd9a Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Wed, 13 Jan 2021 20:37:52 +0100 Subject: [PATCH 19/21] Fixed copy & paste error --- creating_packages/toolchains/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/qbs.rst b/creating_packages/toolchains/qbs.rst index 9fe63119bbc..53a4e998bc1 100644 --- a/creating_packages/toolchains/qbs.rst +++ b/creating_packages/toolchains/qbs.rst @@ -14,7 +14,7 @@ The ``QbsToolchain`` can be used in the ``generate()`` method: .. code:: python from conans import ConanFile - from conan.tools.meson import QbsToolchain + from conan.tools.qbs import QbsToolchain class App(ConanFile): settings = "os", "arch", "compiler", "build_type" From c91aba9afd8ec2e2b3f434119a201d26b97dc1d3 Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Wed, 13 Jan 2021 20:38:17 +0100 Subject: [PATCH 20/21] Removed project name to simplify line --- reference/build_helpers/qbs.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/build_helpers/qbs.rst b/reference/build_helpers/qbs.rst index 5a2c79289d6..04e701faf9f 100644 --- a/reference/build_helpers/qbs.rst +++ b/reference/build_helpers/qbs.rst @@ -119,7 +119,7 @@ library locally (in your user folder, not in the local cache), could be: def build(self): qbs = Qbs(self) qbs.add_configuration("default", { - "project.Hello.conanBuildInfo", self.build_folder + "/conanbuildinfo.qbs" + "project.conanBuildInfo", self.build_folder + "/conanbuildinfo.qbs" }) qbs.build() From b7ea033cf2d650d47dc2dc786c199ebd78cd5e63 Mon Sep 17 00:00:00 2001 From: Kai Dohmen Date: Wed, 13 Jan 2021 20:42:50 +0100 Subject: [PATCH 21/21] Referenced rst files --- creating_packages/toolchains.rst | 1 + reference/build_helpers.rst | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/creating_packages/toolchains.rst b/creating_packages/toolchains.rst index 43ebebcb416..6fe7f0fb68b 100644 --- a/creating_packages/toolchains.rst +++ b/creating_packages/toolchains.rst @@ -117,3 +117,4 @@ Built-in toolchains toolchains/make toolchains/meson toolchains/msbuild + toolchains/qbs diff --git a/reference/build_helpers.rst b/reference/build_helpers.rst index 4da2714a490..db3340514ea 100644 --- a/reference/build_helpers.rst +++ b/reference/build_helpers.rst @@ -16,8 +16,9 @@ Contents: build_helpers/visual_studio build_helpers/meson build_helpers/run_environment + build_helpers/qbs .. important:: If you need a build helper for any other tools, please check how you can create your own - :ref:`custom_build_helper`. \ No newline at end of file + :ref:`custom_build_helper`.