aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-10-16 14:14:05 -0700
committerDylan Baker <dylan@pnwbakers.com>2020-12-16 12:23:23 -0800
commit94b9e7b04ea4905a34dac2185ea58e561c3bf594 (patch)
tree5d919e7bb5bedf9778753b0fa0c4a02566e59c69 /mesonbuild/interpreter.py
parent7ffc678514e6d86ba7072d726f0ccc99a0ccdbc5 (diff)
downloadmeson-94b9e7b04ea4905a34dac2185ea58e561c3bf594.zip
meson-94b9e7b04ea4905a34dac2185ea58e561c3bf594.tar.gz
meson-94b9e7b04ea4905a34dac2185ea58e561c3bf594.tar.bz2
build/interpreter: fix layering violations for ManPages
Like `install_headers`, `install_man` used the same objects for both the interpreter and the build, this is bad. Let's have two separate objects.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py52
1 files changed, 25 insertions, 27 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 3433915..c78726a 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -763,34 +763,20 @@ class InstallDir(InterpreterObject):
self.strip_directory = strip_directory
self.from_source_dir = from_source_dir
-class Man(InterpreterObject):
+class ManHolder(InterpreterObject, ObjectHolder):
- def __init__(self, sources, kwargs):
+ def __init__(self, obj: build.Man):
InterpreterObject.__init__(self)
- self.sources = sources
- self.validate_sources()
- self.custom_install_dir = kwargs.get('install_dir', None)
- self.custom_install_mode = kwargs.get('install_mode', None)
- if self.custom_install_dir is not None and not isinstance(self.custom_install_dir, str):
- raise InterpreterException('Custom_install_dir must be a string.')
-
- def validate_sources(self):
- for s in self.sources:
- try:
- num = int(s.split('.')[-1])
- except (IndexError, ValueError):
- num = 0
- if num < 1 or num > 8:
- raise InvalidArguments('Man file must have a file extension of a number between 1 and 8')
+ ObjectHolder.__init__(self, obj)
- def get_custom_install_dir(self):
- return self.custom_install_dir
+ def get_custom_install_dir(self) -> T.Optional[str]:
+ return self.held_object.custom_install_dir
- def get_custom_install_mode(self):
- return self.custom_install_mode
+ def get_custom_install_mode(self) -> T.Optional[FileMode]:
+ return self.held_object.custom_install_mode
- def get_sources(self):
- return self.sources
+ def get_sources(self) -> T.List[mesonlib.File]:
+ return self.held_object.sources
class GeneratedObjectsHolder(InterpreterObject, ObjectHolder):
def __init__(self, held_object):
@@ -4201,11 +4187,23 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
@FeatureNewKwargs('install_man', '0.47.0', ['install_mode'])
@permittedKwargs(permitted_kwargs['install_man'])
def func_install_man(self, node, args, kwargs):
- fargs = self.source_strings_to_files(args)
- kwargs['install_mode'] = self._get_kwarg_install_mode(kwargs)
- m = Man(fargs, kwargs)
+ sources = self.source_strings_to_files(args)
+ for s in sources:
+ try:
+ num = int(s.split('.')[-1])
+ except (IndexError, ValueError):
+ num = 0
+ if num < 1 or num > 8:
+ raise InvalidArguments('Man file must have a file extension of a number between 1 and 8')
+ custom_install_mode = self._get_kwarg_install_mode(kwargs)
+ custom_install_dir = kwargs.get('install_dir', None)
+ if custom_install_dir is not None and not isinstance(custom_install_dir, str):
+ raise InterpreterException('install_dir must be a string.')
+
+ m = build.Man(sources, custom_install_dir, custom_install_mode)
self.build.man.append(m)
- return m
+
+ return ManHolder(m)
@FeatureNewKwargs('subdir', '0.44.0', ['if_found'])
@permittedKwargs(permitted_kwargs['subdir'])