summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2021-04-06 17:57:31 +0200
committerGitHub <noreply@github.com>2021-04-06 17:57:31 +0200
commitbbc666a1d239f6d5bba66df3fdd10a7eb261dc03 (patch)
tree72e253f78d62625c61433af99da18291b0f17b8a
parenta4c3bc9893b2f76f72e3dd1f98221a286285c2df (diff)
downloadspack-bbc666a1d239f6d5bba66df3fdd10a7eb261dc03.tar.gz
spack-bbc666a1d239f6d5bba66df3fdd10a7eb261dc03.tar.bz2
spack-bbc666a1d239f6d5bba66df3fdd10a7eb261dc03.tar.xz
spack-bbc666a1d239f6d5bba66df3fdd10a7eb261dc03.zip
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
-rw-r--r--lib/spack/docs/build_systems/mesonpackage.rst6
-rw-r--r--lib/spack/spack/build_systems/meson.py19
2 files changed, 21 insertions, 4 deletions
diff --git a/lib/spack/docs/build_systems/mesonpackage.rst b/lib/spack/docs/build_systems/mesonpackage.rst
index 652a10db92..a7dd7a76fb 100644
--- a/lib/spack/docs/build_systems/mesonpackage.rst
+++ b/lib/spack/docs/build_systems/mesonpackage.rst
@@ -121,11 +121,15 @@ override the ``meson_args`` method like so:
.. code-block:: python
def meson_args(self):
- return ['--default-library=both']
+ return ['--warnlevel=3']
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
^^^^^^^^^^^^^^^^^^^^^^
diff --git a/lib/spack/spack/build_systems/meson.py b/lib/spack/spack/build_systems/meson.py
index 33ed756786..8f9972ba2e 100644
--- a/lib/spack/spack/build_systems/meson.py
+++ b/lib/spack/spack/build_systems/meson.py
@@ -52,9 +52,13 @@ class MesonPackage(PackageBase):
build_time_test_callbacks = ['check']
- variant('buildtype', default='release',
+ variant('buildtype', default='debugoptimized',
description='Meson build type',
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('ninja', type='build')
@@ -96,6 +100,13 @@ class MesonPackage(PackageBase):
except KeyError:
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 = [
'--prefix={0}'.format(pkg.prefix),
# If we do not specify libdir explicitly, Meson chooses something
@@ -103,8 +114,9 @@ class MesonPackage(PackageBase):
# find libraries and pkg-config files.
# See https://github.com/mesonbuild/meson/issues/2197
'--libdir={0}'.format(pkg.prefix.lib),
- '--buildtype={0}'.format(build_type),
- '--strip',
+ '-Dbuildtype={0}'.format(build_type),
+ '-Dstrip={0}'.format(strip),
+ '-Ddefault_library={0}'.format(default_library)
]
return args
@@ -131,6 +143,7 @@ class MesonPackage(PackageBase):
* ``--libdir``
* ``--buildtype``
* ``--strip``
+ * ``--default_library``
which will be set automatically.