diff --git a/easybuild/easyblocks/generic/mesonninja.py b/easybuild/easyblocks/generic/mesonninja.py index 17f61afded..d04258caa9 100644 --- a/easybuild/easyblocks/generic/mesonninja.py +++ b/easybuild/easyblocks/generic/mesonninja.py @@ -53,12 +53,28 @@ def extra_options(extra_vars=None): extra_vars.update({ 'build_dir': [None, "build_dir to pass to meson", CUSTOM], 'build_cmd': [DEFAULT_BUILD_CMD, "Build command to use", CUSTOM], + 'build_type': [None, "Build type for meson, e.g. release." + "Defaults to 'release', 'debugoptimized' or 'debug' depending on " + "toolchainopts[debug,noopt]", CUSTOM], 'configure_cmd': [DEFAULT_CONFIGURE_CMD, "Configure command to use", CUSTOM], 'install_cmd': [DEFAULT_INSTALL_CMD, "Install command to use", CUSTOM], 'separate_build_dir': [True, "Perform build in a separate directory", CUSTOM], }) return extra_vars + @property + def build_type(self): + """Build type set in the EasyConfig with default determined by toolchainopts""" + build_type = self.cfg.get('build_type') + if build_type is None: + if self.toolchain.options.get('noopt', None): # also implies debug but is the closest match + build_type = 'debug' + elif self.toolchain.options.get('debug', None): + build_type = 'debugoptimized' + else: + build_type = 'release' + return build_type + def configure_step(self, cmd_prefix=''): """ Configure with Meson. @@ -92,13 +108,16 @@ def configure_step(self, cmd_prefix=''): build_dir = self.cfg.get('build_dir') or self.start_dir - cmd = "%(preconfigopts)s %(configure_cmd)s --prefix %(installdir)s %(configopts)s %(source_dir)s" % { + cmd = ("%(preconfigopts)s %(configure_cmd)s --prefix %(installdir)s --buildtype %(buildtype)s %(configopts)s " + "%(source_dir)s") % { 'configopts': self.cfg['configopts'], 'configure_cmd': configure_cmd, 'installdir': self.installdir, 'preconfigopts': self.cfg['preconfigopts'], 'source_dir': build_dir, + 'buildtype': self.build_type, } + res = run_shell_cmd(cmd) return res.output