diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2023-04-16 23:08:05 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2023-05-02 19:28:35 -0400 |
commit | 6823cabb83c77fa19ebf594acceea7314b9e8fd7 (patch) | |
tree | d4e9bee35020945a7253329f4be4a1252c93b3c9 | |
parent | 7c78c2b5a0314078bdabb998ead56925dc8b0fc0 (diff) | |
download | meson-6823cabb83c77fa19ebf594acceea7314b9e8fd7.zip meson-6823cabb83c77fa19ebf594acceea7314b9e8fd7.tar.gz meson-6823cabb83c77fa19ebf594acceea7314b9e8fd7.tar.bz2 |
extend install scripts to allow specific directory variable exports
This is useful for internal scripts that want to know about something
other than MESON_INSTALL_PREFIX and MESON_INSTALL_DESTDIR_PREFIX, which
is very specific to the prefix.
-rw-r--r-- | mesonbuild/backend/backends.py | 5 | ||||
-rw-r--r-- | mesonbuild/minstall.py | 13 | ||||
-rw-r--r-- | mesonbuild/utils/core.py | 1 |
3 files changed, 14 insertions, 5 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 4972eab..a13c0ec 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -499,7 +499,8 @@ class Backend: feed: T.Optional[bool] = None, env: T.Optional[build.EnvironmentVariables] = None, tag: T.Optional[str] = None, - verbose: bool = False) -> 'ExecutableSerialisation': + verbose: bool = False, + installdir_map: T.Optional[T.Dict[str, str]] = None) -> 'ExecutableSerialisation': # XXX: cmd_args either need to be lowered to strings, or need to be checked for non-string arguments, right? exe, *raw_cmd_args = cmd @@ -560,7 +561,7 @@ class Backend: workdir = workdir or self.environment.get_build_dir() return ExecutableSerialisation(exe_cmd + cmd_args, env, exe_wrapper, workdir, - extra_paths, capture, feed, tag, verbose) + extra_paths, capture, feed, tag, verbose, installdir_map) def as_meson_exe_cmdline(self, exe: T.Union[str, mesonlib.File, build.BuildTarget, build.CustomTarget, programs.ExternalProgram], cmd_args: T.Sequence[T.Union[str, mesonlib.File, build.BuildTarget, build.CustomTarget, programs.ExternalProgram]], diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py index b9fe7d5..ec01fe7 100644 --- a/mesonbuild/minstall.py +++ b/mesonbuild/minstall.py @@ -672,8 +672,6 @@ class Installer: 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, - 'MESON_INSTALL_DESTDIR_PREFIX': fullprefix, 'MESONINTROSPECT': ' '.join([shlex.quote(x) for x in d.mesonintrospect]), } if self.options.quiet: @@ -684,6 +682,15 @@ class Installer: for i in d.install_scripts: if not self.should_install(i): continue + + if i.installdir_map is not None: + mapp = i.installdir_map + else: + mapp = {'prefix': d.prefix} + localenv = env.copy() + localenv.update({'MESON_INSTALL_'+k.upper(): os.path.join(d.prefix, v) for k, v in mapp.items()}) + localenv.update({'MESON_INSTALL_DESTDIR_'+k.upper(): get_destdir_path(destdir, fullprefix, v) for k, v in mapp.items()}) + name = ' '.join(i.cmd_args) if i.skip_if_destdir and destdir: self.log(f'Skipping custom install script because DESTDIR is set {name!r}') @@ -691,7 +698,7 @@ class Installer: self.did_install_something = True # Custom script must report itself if it does nothing. self.log(f'Running custom install script {name!r}') try: - rc = self.run_exe(i, env) + rc = self.run_exe(i, localenv) except OSError: print(f'FAILED: install script \'{name}\' could not be run, stopped') # POSIX shells return 127 when a command could not be found diff --git a/mesonbuild/utils/core.py b/mesonbuild/utils/core.py index 03a8c63..eee88b9 100644 --- a/mesonbuild/utils/core.py +++ b/mesonbuild/utils/core.py @@ -152,6 +152,7 @@ class ExecutableSerialisation: feed: T.Optional[bool] = None tag: T.Optional[str] = None verbose: bool = False + installdir_map: T.Optional[T.Dict[str, str]] = None def __post_init__(self) -> None: self.pickled = False |