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

Feature: meson toolchain #1943

Merged
merged 6 commits into from Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions creating_packages/toolchains.rst
Expand Up @@ -102,4 +102,5 @@ Built-in toolchains

toolchains/cmake
toolchains/make
toolchains/meson
toolchains/msbuild
63 changes: 63 additions & 0 deletions creating_packages/toolchains/meson.rst
@@ -0,0 +1,63 @@
.. _conan-meson-toolchain:

MesonToolchain
==============

.. warning::

This is an **experimental** feature subject to breaking changes in future releases.


The ``MesonToolchain`` can be used in the ``generate()`` method:


.. code:: python

from conans import ConanFile
from conan.tools.meson import MesonToolchain

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 = MesonToolchain(self)
tc.generate()


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:
SSE4 marked this conversation as resolved.
Show resolved Hide resolved


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