aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/minstall.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-10-03 14:35:30 -0400
committerEli Schwartz <eschwartz@archlinux.org>2021-10-08 14:35:00 -0400
commit108bd996ee72b16c14f0ee0ca86959b142582394 (patch)
tree2cc138363c7139ce3fa2ae918e75ac5b81d19c77 /mesonbuild/minstall.py
parent54e17ad5975252242712dc3b613bdbd0a2504e23 (diff)
downloadmeson-108bd996ee72b16c14f0ee0ca86959b142582394.zip
meson-108bd996ee72b16c14f0ee0ca86959b142582394.tar.gz
meson-108bd996ee72b16c14f0ee0ca86959b142582394.tar.bz2
add install_emptydir function
This replaces the absolute hack of using ``` install_subdir('nonexisting', install_dir: 'share') ``` which requires you to make sure you don't accidentally or deliberately have a completely different directory with the same name in your source tree that is full of files you don't want installed. It also avoids splitting the name in two and listing them in the wrong order. You can also set the install mode of each directory component by listing them one at a time in order, and in fact create nested structures at all. Fixes #1604 Properly fixes #2904
Diffstat (limited to 'mesonbuild/minstall.py')
-rw-r--r--mesonbuild/minstall.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 6284f95..7864742 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -25,7 +25,7 @@ import sys
import typing as T
from . import environment
-from .backend.backends import InstallData, InstallDataBase, TargetInstallData, ExecutableSerialisation
+from .backend.backends import InstallData, InstallDataBase, InstallEmptyDir, TargetInstallData, ExecutableSerialisation
from .coredata import major_versions_differ, MesonVersionMismatchException
from .coredata import version as coredata_version
from .mesonlib import Popen_safe, RealPathAction, is_windows
@@ -370,7 +370,7 @@ class Installer:
return run_exe(*args, **kwargs)
return 0
- def should_install(self, d: T.Union[TargetInstallData, InstallDataBase, ExecutableSerialisation]) -> bool:
+ def should_install(self, d: T.Union[TargetInstallData, InstallEmptyDir, InstallDataBase, ExecutableSerialisation]) -> bool:
if d.subproject and (d.subproject in self.skip_subprojects or '*' in self.skip_subprojects):
return False
if self.tags and d.tag not in self.tags:
@@ -531,6 +531,7 @@ class Installer:
self.install_targets(d, dm, destdir, fullprefix)
self.install_headers(d, dm, destdir, fullprefix)
self.install_man(d, dm, destdir, fullprefix)
+ self.install_emptydir(d, dm, destdir, fullprefix)
self.install_data(d, dm, destdir, fullprefix)
self.restore_selinux_contexts(destdir)
self.apply_ldconfig(destdir)
@@ -581,6 +582,19 @@ class Installer:
self.did_install_something = True
self.set_mode(outfilename, m.install_mode, d.install_umask)
+ def install_emptydir(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: str) -> None:
+ for e in d.emptydir:
+ if not self.should_install(e):
+ continue
+ self.did_install_something = True
+ full_dst_dir = get_destdir_path(destdir, fullprefix, e.path)
+ self.log(f'Installing new directory {full_dst_dir}')
+ if os.path.isfile(full_dst_dir):
+ print(f'Tried to create directory {full_dst_dir} but a file of that name already exists.')
+ sys.exit(1)
+ dm.makedirs(full_dst_dir, exist_ok=True)
+ self.set_mode(full_dst_dir, e.install_mode, d.install_umask)
+
def install_headers(self, d: InstallData, dm: DirMaker, destdir: str, fullprefix: str) -> None:
for t in d.headers:
if not self.should_install(t):