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

add options to MesonNinja easyblock to customize build_cmd, install_cmd, builddir #2963

Merged
merged 4 commits into from
Aug 31, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions easybuild/easyblocks/generic/mesonninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
from easybuild.tools.run import run_cmd

DEFAULT_CONFIGURE_CMD = 'meson'
DEFAULT_BUILD_CMD = 'ninja'
DEFAULT_INSTALL_CMD = 'ninja'


class MesonNinja(EasyBlock):
Expand All @@ -51,6 +53,9 @@ def extra_options(extra_vars=None):
extra_vars.update({
'configure_cmd': [DEFAULT_CONFIGURE_CMD, "Configure command to use", CUSTOM],
'separate_build_dir': [True, "Perform build in a separate directory", CUSTOM],
'build_cmd': [DEFAULT_BUILD_CMD, "Build command to use", CUSTOM],
'build_dir': [None, "build_dir to pass to meson", CUSTOM],
'install_cmd': [DEFAULT_INSTALL_CMD, "Install command to use", CUSTOM],
mboisson marked this conversation as resolved.
Show resolved Hide resolved
})
return extra_vars

Expand Down Expand Up @@ -85,12 +90,14 @@ def configure_step(self, cmd_prefix=''):
configure_cmd == DEFAULT_CONFIGURE_CMD):
configure_cmd += ' setup'

cmd = "%(preconfigopts)s %(configure_cmd)s --prefix %(installdir)s %(configopts)s %(sourcedir)s" % {
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" % {
'configopts': self.cfg['configopts'],
'configure_cmd': configure_cmd,
'installdir': self.installdir,
'preconfigopts': self.cfg['preconfigopts'],
'sourcedir': self.start_dir,
'source_dir': build_dir,
}
(out, _) = run_cmd(cmd, log_all=True, simple=False)
return out
Expand All @@ -99,12 +106,15 @@ def build_step(self, verbose=False, path=None):
"""
Build with Ninja.
"""
build_cmd = self.cfg.get('build_cmd') or DEFAULT_BUILD_CMD
mboisson marked this conversation as resolved.
Show resolved Hide resolved

parallel = ''
if self.cfg['parallel']:
parallel = "-j %s" % self.cfg['parallel']

cmd = "%(prebuildopts)s ninja %(parallel)s %(buildopts)s" % {
cmd = "%(prebuildopts)s %(build_cmd)s %(parallel)s %(buildopts)s" % {
'buildopts': self.cfg['buildopts'],
'build_cmd': build_cmd,
'parallel': parallel,
'prebuildopts': self.cfg['prebuildopts'],
}
Expand All @@ -124,13 +134,16 @@ def install_step(self):
"""
Install with 'ninja install'.
"""
install_cmd = self.cfg.get('install_cmd') or DEFAULT_INSTALL_CMD
mboisson marked this conversation as resolved.
Show resolved Hide resolved

parallel = ''
if self.cfg['parallel']:
parallel = "-j %s" % self.cfg['parallel']

cmd = "%(preinstallopts)s ninja %(parallel)s %(installopts)s install" % {
cmd = "%(preinstallopts)s %(install_cmd)s %(parallel)s %(installopts)s install" % {
'installopts': self.cfg['installopts'],
'parallel': parallel,
'install_cmd': install_cmd,
'preinstallopts': self.cfg['preinstallopts'],
}
(out, _) = run_cmd(cmd, log_all=True, simple=False)
Expand Down