From eb51163185fdeaf50646d0ae2876c94c230fa61a Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 12 Feb 2014 22:50:45 +0200 Subject: [PATCH] Fix the remaining custom install dirs. --- backends.py | 11 +++++++---- interpreter.py | 18 +++++++++++++++--- .../common/52 custom install dirs/datafile.cat | 1 + .../52 custom install dirs/installed_files.txt | 2 ++ .../common/52 custom install dirs/meson.build | 2 ++ .../common/52 custom install dirs/prog.1 | 1 + 6 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 test cases/common/52 custom install dirs/datafile.cat create mode 100644 test cases/common/52 custom install dirs/prog.1 diff --git a/backends.py b/backends.py index 6a1109b3c..e4aaced65 100644 --- a/backends.py +++ b/backends.py @@ -587,10 +587,11 @@ class NinjaBackend(Backend): for m in man: for f in m.get_sources(): num = f.split('.')[-1] - subdir = 'man' + num + 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(), f) - dstabs = os.path.join(manroot, - os.path.join(subdir, f + '.gz')) + dstabs = os.path.join(subdir, f + '.gz') i = [srcabs, dstabs] d.man.append(i) @@ -598,7 +599,9 @@ class NinjaBackend(Backend): dataroot = self.environment.get_datadir() data = self.build.get_data() for de in data: - subdir = os.path.join(dataroot, de.get_subdir()) + subdir = de.get_custom_install_dir() + if subdir is None: + subdir = os.path.join(dataroot, de.get_subdir()) for f in de.get_sources(): srcabs = os.path.join(self.environment.get_source_dir(), f) dstabs = os.path.join(subdir, f) diff --git a/interpreter.py b/interpreter.py index 1e74f4091..3ca425f91 100644 --- a/interpreter.py +++ b/interpreter.py @@ -293,6 +293,9 @@ class Data(InterpreterObject): if not isinstance(kwsource, list): kwsource = [kwsource] self.sources += kwsource + 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.') def get_subdir(self): return self.subdir @@ -300,21 +303,30 @@ class Data(InterpreterObject): def get_sources(self): return self.sources + def get_custom_install_dir(self): + return self.custom_install_dir + class Man(InterpreterObject): def __init__(self, sources, kwargs): InterpreterObject.__init__(self) self.sources = sources self.validate_sources() - if len(kwargs) > 0: - raise InvalidArguments('Man function takes no keyword arguments.') - + 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.') + def validate_sources(self): for s in self.sources: num = int(s.split('.')[-1]) if num < 1 or num > 8: raise InvalidArguments('Man file must have a file extension of a number between 1 and 8') + def get_custom_install_dir(self): + return self.custom_install_dir + def get_sources(self): return self.sources diff --git a/test cases/common/52 custom install dirs/datafile.cat b/test cases/common/52 custom install dirs/datafile.cat new file mode 100644 index 000000000..53d81fc2a --- /dev/null +++ b/test cases/common/52 custom install dirs/datafile.cat @@ -0,0 +1 @@ +Installed cat is installed. diff --git a/test cases/common/52 custom install dirs/installed_files.txt b/test cases/common/52 custom install dirs/installed_files.txt index a8a496c82..ad6ce3bac 100644 --- a/test cases/common/52 custom install dirs/installed_files.txt +++ b/test cases/common/52 custom install dirs/installed_files.txt @@ -1,2 +1,4 @@ dib/dab/dub/prog some/dir/sample.h +woman/prog.1.gz +meow/datafile.cat diff --git a/test cases/common/52 custom install dirs/meson.build b/test cases/common/52 custom install dirs/meson.build index 5f1919a0c..4a222bac3 100644 --- a/test cases/common/52 custom install dirs/meson.build +++ b/test cases/common/52 custom install dirs/meson.build @@ -2,3 +2,5 @@ project('custom install dirs', 'c') executable('prog', 'prog.c', install : true, install_dir : 'dib/dab/dub') headers('sample.h', install_dir : 'some/dir') +man('prog.1', install_dir : 'woman') +data('foobar', 'datafile.cat', install_dir : 'meow') diff --git a/test cases/common/52 custom install dirs/prog.1 b/test cases/common/52 custom install dirs/prog.1 new file mode 100644 index 000000000..08ef7da62 --- /dev/null +++ b/test cases/common/52 custom install dirs/prog.1 @@ -0,0 +1 @@ +Man up, you.