From a572ebd2a19ff9501e3c03b0cec71f5a5aef5ceb Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 31 Jul 2017 07:53:03 -0400 Subject: [PATCH] Convert man inputs to Files so you can install_man the output of configure_file. Closes #2135. --- mesonbuild/backend/ninjabackend.py | 4 ++-- mesonbuild/interpreter.py | 12 +++--------- test cases/common/10 man install/baz.1.in | 6 ++++++ test cases/common/10 man install/installed_files.txt | 1 + test cases/common/10 man install/meson.build | 8 ++++++++ 5 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 test cases/common/10 man install/baz.1.in diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 5fc6d6bc6..f77d2b181 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -782,8 +782,8 @@ int dummy; subdir = m.get_custom_install_dir() if subdir is None: subdir = os.path.join(manroot, 'man' + num) - srcabs = os.path.join(self.environment.get_source_dir(), m.get_source_subdir(), f) - dstabs = os.path.join(subdir, os.path.split(f)[1] + '.gz') + srcabs = f.absolute_path(self.environment.get_source_dir(), self.environment.get_build_dir()) + dstabs = os.path.join(subdir, os.path.split(f.fname)[1] + '.gz') i = [srcabs, dstabs] d.man.append(i) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 1858e8c36..94fb6497e 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -465,13 +465,10 @@ class InstallDir(InterpreterObject): class Man(InterpreterObject): - def __init__(self, source_subdir, sources, kwargs): + def __init__(self, sources, kwargs): InterpreterObject.__init__(self) - self.source_subdir = source_subdir self.sources = sources self.validate_sources() - if len(kwargs) > 1: - raise InvalidArguments('Man function takes at most one keyword arguments.') self.custom_install_dir = kwargs.get('install_dir', 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.') @@ -491,9 +488,6 @@ class Man(InterpreterObject): def get_sources(self): return self.sources - def get_source_subdir(self): - return self.source_subdir - class GeneratedObjectsHolder(InterpreterObject): def __init__(self, held_object): super().__init__() @@ -2354,9 +2348,9 @@ class Interpreter(InterpreterBase): return h @permittedKwargs(permitted_kwargs['install_man']) - @stringArgs def func_install_man(self, node, args, kwargs): - m = Man(self.subdir, args, kwargs) + fargs = self.source_strings_to_files(args) + m = Man(fargs, kwargs) self.build.man.append(m) return m diff --git a/test cases/common/10 man install/baz.1.in b/test cases/common/10 man install/baz.1.in new file mode 100644 index 000000000..d0b79b43e --- /dev/null +++ b/test cases/common/10 man install/baz.1.in @@ -0,0 +1,6 @@ +This is a man page of baz.1 it was generated @TODAY@. + +You should not put generation timestamps in real world projects +because they break reproducible builds. This manpage is written +by professionals or under the supervision of professionals. Do +not try this at home. diff --git a/test cases/common/10 man install/installed_files.txt b/test cases/common/10 man install/installed_files.txt index 7b1961628..c13baa4c0 100644 --- a/test cases/common/10 man install/installed_files.txt +++ b/test cases/common/10 man install/installed_files.txt @@ -2,3 +2,4 @@ usr/share/man/man1/foo.1.gz usr/share/man/man2/bar.2.gz usr/share/man/man1/vanishing.1.gz usr/share/man/man2/vanishing.2.gz +usr/share/man/man1/baz.1.gz diff --git a/test cases/common/10 man install/meson.build b/test cases/common/10 man install/meson.build index 8436fa588..8262ffc88 100644 --- a/test cases/common/10 man install/meson.build +++ b/test cases/common/10 man install/meson.build @@ -3,3 +3,11 @@ m1 = install_man('foo.1') m2 = install_man('bar.2') install_man('vanishing/vanishing.2') subdir('vanishing') + +cdata = configuration_data() +cdata.set('TODAY', '$this_day') +b1 = configure_file(input : 'baz.1.in', + output : 'baz.1', + configuration : cdata) + +install_man(b1)