meson: added variants, changed defaults for the build system (#22715)
- Use debugoptimized as default build type, just like RelWithDebInfo for cmake - Do not strip by default, and add a default_library variant which conveniently support both shared and static
This commit is contained in:
parent
a4c3bc9893
commit
bbc666a1d2
@ -121,11 +121,15 @@ override the ``meson_args`` method like so:
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
def meson_args(self):
|
def meson_args(self):
|
||||||
return ['--default-library=both']
|
return ['--warnlevel=3']
|
||||||
|
|
||||||
|
|
||||||
This method can be used to pass flags as well as variables.
|
This method can be used to pass flags as well as variables.
|
||||||
|
|
||||||
|
Note that the ``MesonPackage`` base class already defines variants for
|
||||||
|
``buildtype``, ``default_library`` and ``strip``, which are mapped to default
|
||||||
|
Meson arguments, meaning that you don't have to specify these.
|
||||||
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
External documentation
|
External documentation
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -52,9 +52,13 @@ class MesonPackage(PackageBase):
|
|||||||
|
|
||||||
build_time_test_callbacks = ['check']
|
build_time_test_callbacks = ['check']
|
||||||
|
|
||||||
variant('buildtype', default='release',
|
variant('buildtype', default='debugoptimized',
|
||||||
description='Meson build type',
|
description='Meson build type',
|
||||||
values=('plain', 'debug', 'debugoptimized', 'release', 'minsize'))
|
values=('plain', 'debug', 'debugoptimized', 'release', 'minsize'))
|
||||||
|
variant('default_library', default='shared',
|
||||||
|
description=' Default library type',
|
||||||
|
values=('shared', 'static', 'both'))
|
||||||
|
variant('strip', default=False, description='Strip targets on install')
|
||||||
|
|
||||||
depends_on('meson', type='build')
|
depends_on('meson', type='build')
|
||||||
depends_on('ninja', type='build')
|
depends_on('ninja', type='build')
|
||||||
@ -96,6 +100,13 @@ def _std_args(pkg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
build_type = 'release'
|
build_type = 'release'
|
||||||
|
|
||||||
|
strip = 'true' if '+strip' in pkg.spec else 'false'
|
||||||
|
|
||||||
|
try:
|
||||||
|
default_library = pkg.spec.variants['default_library'].value
|
||||||
|
except KeyError:
|
||||||
|
default_library = 'shared'
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
'--prefix={0}'.format(pkg.prefix),
|
'--prefix={0}'.format(pkg.prefix),
|
||||||
# If we do not specify libdir explicitly, Meson chooses something
|
# If we do not specify libdir explicitly, Meson chooses something
|
||||||
@ -103,8 +114,9 @@ def _std_args(pkg):
|
|||||||
# find libraries and pkg-config files.
|
# find libraries and pkg-config files.
|
||||||
# See https://github.com/mesonbuild/meson/issues/2197
|
# See https://github.com/mesonbuild/meson/issues/2197
|
||||||
'--libdir={0}'.format(pkg.prefix.lib),
|
'--libdir={0}'.format(pkg.prefix.lib),
|
||||||
'--buildtype={0}'.format(build_type),
|
'-Dbuildtype={0}'.format(build_type),
|
||||||
'--strip',
|
'-Dstrip={0}'.format(strip),
|
||||||
|
'-Ddefault_library={0}'.format(default_library)
|
||||||
]
|
]
|
||||||
|
|
||||||
return args
|
return args
|
||||||
@ -131,6 +143,7 @@ def meson_args(self):
|
|||||||
* ``--libdir``
|
* ``--libdir``
|
||||||
* ``--buildtype``
|
* ``--buildtype``
|
||||||
* ``--strip``
|
* ``--strip``
|
||||||
|
* ``--default_library``
|
||||||
|
|
||||||
which will be set automatically.
|
which will be set automatically.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user