diff options
-rw-r--r-- | docs/markdown/Reference-manual.md | 4 | ||||
-rw-r--r-- | docs/markdown/snippets/destdir.md | 11 | ||||
-rw-r--r-- | mesonbuild/backend/backends.py | 1 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 7 | ||||
-rw-r--r-- | mesonbuild/minstall.py | 9 |
5 files changed, 28 insertions, 4 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 72199df..fa6321a 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -1851,6 +1851,10 @@ the following methods. `MESON_BUILD_ROOT`, `MESON_INSTALL_PREFIX`, `MESON_INSTALL_DESTDIR_PREFIX`, and `MESONINTROSPECT` set. All positional arguments are passed as parameters. + *since 0.57.0* `skip_if_destdir` boolean keyword argument (defaults to `false`) + can be specified. If `true` the script will not be run if DESTDIR is set during + installation. This is useful in the case the script updates system wide + cache that is only needed when copying files into final destination. *(since 0.54.0)* If `meson install` is called with the `--quiet` option, the environment variable `MESON_INSTALL_QUIET` will be set. diff --git a/docs/markdown/snippets/destdir.md b/docs/markdown/snippets/destdir.md new file mode 100644 index 0000000..d8cf55d --- /dev/null +++ b/docs/markdown/snippets/destdir.md @@ -0,0 +1,11 @@ +## Specify DESTDIR on command line + +`meson install` command now has `--destdir` argument that overrides DESTDIR +from environment. + +## Skip install scripts if DESTDIR is set + +`meson.add_install_script()` now has `skip_if_destdir` keyword argument. If set +to `true` the script won't be run if DESTDIR is set during installation. This is +useful in the case the script updates system wide cache that is only needed when +copying files into final destination. diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index caec761..badc2d0 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -137,6 +137,7 @@ class ExecutableSerialisation: self.extra_paths = extra_paths self.capture = capture self.pickled = False + self.skip_if_destdir = False class TestSerialisation: def __init__(self, name: str, project: str, suite: str, fname: T.List[str], diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index ceaa29a..0ce0fe8 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2015,15 +2015,20 @@ class MesonMain(InterpreterObject): '0.55.0', self.interpreter.subproject) return script_args - @permittedKwargs(set()) + @FeatureNewKwargs('add_install_script', '0.57.0', ['skip_if_destdir']) + @permittedKwargs({'skip_if_destdir'}) def add_install_script_method(self, args: 'T.Tuple[T.Union[str, mesonlib.File, ExecutableHolder], T.Union[str, mesonlib.File, CustomTargetHolder, CustomTargetIndexHolder, ConfigureFileHolder], ...]', kwargs): if len(args) < 1: raise InterpreterException('add_install_script takes one or more arguments') if isinstance(args[0], mesonlib.File): FeatureNew.single_use('Passing file object to script parameter of add_install_script', '0.57.0', self.interpreter.subproject) + skip_if_destdir = kwargs.get('skip_if_destdir', False) + if not isinstance(skip_if_destdir, bool): + raise InterpreterException('skip_if_destdir keyword argument must be boolean') script_args = self._process_script_args('add_install_script', args[1:], allow_built=True) script = self._find_source_script(args[0], script_args) + script.skip_if_destdir = skip_if_destdir self.build.install_scripts.append(script) @permittedKwargs(set()) diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index db08dfe..18dca8b 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -429,7 +429,7 @@ class Installer: self.install_man(d, dm, destdir, fullprefix) self.install_data(d, dm, destdir, fullprefix) restore_selinux_contexts() - self.run_install_script(d, fullprefix) + self.run_install_script(d, destdir, fullprefix) if not self.did_install_something: self.log('Nothing to install.') if not self.options.quiet and self.preserved_file_count > 0: @@ -483,7 +483,7 @@ class Installer: self.did_install_something = True set_mode(outfilename, install_mode, d.install_umask) - def run_install_script(self, d: InstallData, fullprefix: str) -> None: + def run_install_script(self, d: InstallData, destdir: str, fullprefix: str) -> None: env = {'MESON_SOURCE_ROOT': d.source_dir, 'MESON_BUILD_ROOT': d.build_dir, 'MESON_INSTALL_PREFIX': d.prefix, @@ -494,8 +494,11 @@ class Installer: env['MESON_INSTALL_QUIET'] = '1' for i in d.install_scripts: - self.did_install_something = True # Custom script must report itself if it does nothing. name = ' '.join(i.cmd_args) + if i.skip_if_destdir and destdir: + self.log('Skipping custom install script because DESTDIR is set {!r}'.format(name)) + continue + self.did_install_something = True # Custom script must report itself if it does nothing. self.log('Running custom install script {!r}'.format(name)) try: rc = run_exe(i, env) |