From 99f8e0a430e09c54eaee6b24588579d0b9384c5a Mon Sep 17 00:00:00 2001 From: SSE4 Date: Tue, 1 Dec 2020 19:52:39 +0700 Subject: [PATCH 1/6] - docs for meson toolchain Signed-off-by: SSE4 --- creating_packages/toolchains.rst | 1 + creating_packages/toolchains/meson.rst | 62 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 creating_packages/toolchains/meson.rst diff --git a/creating_packages/toolchains.rst b/creating_packages/toolchains.rst index bbeecc23ea1..7877a675946 100644 --- a/creating_packages/toolchains.rst +++ b/creating_packages/toolchains.rst @@ -102,4 +102,5 @@ Built-in toolchains toolchains/cmake toolchains/make + toolchains/meson toolchains/msbuild diff --git a/creating_packages/toolchains/meson.rst b/creating_packages/toolchains/meson.rst new file mode 100644 index 00000000000..18c7fd03b5e --- /dev/null +++ b/creating_packages/toolchains/meson.rst @@ -0,0 +1,62 @@ +.. _conan-meson-toolchain: + +MesonToolchain +============== + +.. warning:: + + This is an **experimental** feature subject to breaking changes in future releases. + + +The ``MesonToolchain`` can be used in the ``toolchain()`` method: + + +.. code:: python + + from conans import ConanFile, MesonToolchain + + class App(ConanFile): + settings = "os", "arch", "compiler", "build_type" + requires = "hello/0.1" + options = {"shared": [True, False]} + default_options = {"shared": False} + + def toolchain(self): + tc = MesonToolchain(self) + tc.write_toolchain_files() + + +The ``MesonToolchain`` 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_meson_native.ini`` + +``conan_meson_native.ini`` will contain the definitions of all the Meson properties +related to the Conan options and settings for the current package, platform, +etc. This includes but is not limited to the following: + + +Generators +---------- + +The ``MesonToolchain`` only works with the ``pkg_config`` generator. +Please, do not use other generators, as they can have overlapping definitions that can conflict. + + +Using the toolchain in developer flow +------------------------------------- + +One of the advantages of using Conan toolchains is that they can help to achieve the exact same build +with local development flows, than when the package is created in the cache. + +With the ``MesonToolchain`` it is possible to do: + +.. code:: bash + + # Lets start in the folder containing the conanfile.py + $ mkdir build && cd build + # Install both debug and release deps and create the toolchain + $ conan install .. + # the build type Release is encoded in the toolchain already. + # This conan_meson_native.iniis specific for release + $ meson setup --native-file conan_meson_native.ini build . + $ meson compile -C build From 3816a3fe83bfa7e93f0d2860c9ee24579981da60 Mon Sep 17 00:00:00 2001 From: SSE4 Date: Wed, 2 Dec 2020 01:22:28 +0700 Subject: [PATCH 2/6] Update meson.rst --- creating_packages/toolchains/meson.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/creating_packages/toolchains/meson.rst b/creating_packages/toolchains/meson.rst index 18c7fd03b5e..6d29087c263 100644 --- a/creating_packages/toolchains/meson.rst +++ b/creating_packages/toolchains/meson.rst @@ -13,7 +13,8 @@ The ``MesonToolchain`` can be used in the ``toolchain()`` method: .. code:: python - from conans import ConanFile, MesonToolchain + from conans import ConanFile + from conan.tools.meson import MesonToolchain class App(ConanFile): settings = "os", "arch", "compiler", "build_type" @@ -23,7 +24,7 @@ The ``MesonToolchain`` can be used in the ``toolchain()`` method: def toolchain(self): tc = MesonToolchain(self) - tc.write_toolchain_files() + tc.generate() The ``MesonToolchain`` will generate the following file during ``conan install`` From b3557984be749e69eef15fec8f305dbcf3a6ec85 Mon Sep 17 00:00:00 2001 From: SSE4 Date: Wed, 2 Dec 2020 16:31:28 +0700 Subject: [PATCH 3/6] Update creating_packages/toolchains/meson.rst Co-authored-by: Carlos Zoido --- creating_packages/toolchains/meson.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/meson.rst b/creating_packages/toolchains/meson.rst index 6d29087c263..0234ca5071d 100644 --- a/creating_packages/toolchains/meson.rst +++ b/creating_packages/toolchains/meson.rst @@ -22,7 +22,7 @@ The ``MesonToolchain`` can be used in the ``toolchain()`` method: options = {"shared": [True, False]} default_options = {"shared": False} - def toolchain(self): + def generate(self): tc = MesonToolchain(self) tc.generate() From 390104dd011e4f751da90373557f567578d2b90a Mon Sep 17 00:00:00 2001 From: SSE4 Date: Wed, 2 Dec 2020 17:35:03 +0700 Subject: [PATCH 4/6] Update creating_packages/toolchains/meson.rst Co-authored-by: Carlos Zoido --- creating_packages/toolchains/meson.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/meson.rst b/creating_packages/toolchains/meson.rst index 0234ca5071d..09ce360961d 100644 --- a/creating_packages/toolchains/meson.rst +++ b/creating_packages/toolchains/meson.rst @@ -8,7 +8,7 @@ MesonToolchain This is an **experimental** feature subject to breaking changes in future releases. -The ``MesonToolchain`` can be used in the ``toolchain()`` method: +The ``MesonToolchain`` can be used in the ``generate()`` method: .. code:: python From 12b5d9c7811424237fd52e068b01fa9c4d08bf3a Mon Sep 17 00:00:00 2001 From: SSE4 Date: Wed, 2 Dec 2020 17:46:40 +0700 Subject: [PATCH 5/6] forgotten Signed-off-by: SSE4 --- creating_packages/toolchains/meson.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/creating_packages/toolchains/meson.rst b/creating_packages/toolchains/meson.rst index 09ce360961d..b85f86320c7 100644 --- a/creating_packages/toolchains/meson.rst +++ b/creating_packages/toolchains/meson.rst @@ -35,6 +35,15 @@ built in the cache): ``conan_meson_native.ini`` related to the Conan options and settings for the current package, platform, etc. This includes but is not limited to the following: +* Detection of ``default_library`` from Conan settings + + * Based on existance/value of a option named ``shared`` + +* Detection of ``buildtype`` from Conan settings + +* Definition of the C++ standard as necessary + +- The Visual Studio runtime (``b_vscrt ``), obtained from Conan input settings Generators ---------- From c2384e843782fcfc6ae22c44de5609db2d571abd Mon Sep 17 00:00:00 2001 From: SSE4 Date: Wed, 2 Dec 2020 19:13:47 +0700 Subject: [PATCH 6/6] Update meson.rst --- creating_packages/toolchains/meson.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/creating_packages/toolchains/meson.rst b/creating_packages/toolchains/meson.rst index b85f86320c7..89c8cdcf6de 100644 --- a/creating_packages/toolchains/meson.rst +++ b/creating_packages/toolchains/meson.rst @@ -43,7 +43,7 @@ etc. This includes but is not limited to the following: * Definition of the C++ standard as necessary -- The Visual Studio runtime (``b_vscrt ``), obtained from Conan input settings +* The Visual Studio runtime (``b_vscrt``), obtained from Conan input settings Generators ----------