From 570c9b150b9c604b3c221d7684a5cee3494d3d7a Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 6 Jan 2017 19:22:56 +0200 Subject: [PATCH] Fix a few more modules. --- mesonbuild/interpreter.py | 35 ++++++++++++++++++++++++++++------- mesonbuild/modules/i18n.py | 7 +++++-- mesonbuild/modules/qt4.py | 3 ++- mesonbuild/modules/qt5.py | 3 ++- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index d4aacbd1a..19e73de61 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -420,11 +420,9 @@ class Headers(InterpreterObject): return self.custom_install_dir class DataHolder(InterpreterObject): - def __init__(self, sources, install_dir): + def __init__(self, data): super().__init__() - if not isinstance(install_dir, str): - raise InterpreterException('Custom_install_dir must be a string.') - self.held_object = build.Data(sources, install_dir) + self.held_object = data def get_source_subdir(self): return self.held_object.source_subdir @@ -1231,6 +1229,29 @@ class Interpreter(InterpreterBase): 'join_paths': self.func_join_paths, }) + def holderify(self, item): + if isinstance(item, list): + return [self.holderify(x) for x in item] + if isinstance(item, build.CustomTarget): + return CustomTargetHolder(item, self) + elif isinstance(item, (int, str)) or item is None: + return item + elif isinstance(item, build.Executable): + return ExecutableHolder(item, self) + elif isinstance(item, build.GeneratedList): + return GeneratedListHolder(item) + elif isinstance(item, build.RunTarget): + raise RuntimeError('This is not a pipe.') + elif isinstance(item, build.RunScript): + raise RuntimeError('Do not do this.') + elif isinstance(item, build.Data): + return DataHolder(item) + elif isinstance(item, dependencies.InternalDependency): + return InternalDependencyHolder(item) + else: + print(item) + raise InterpreterException('Module returned a value of unknown type.') + def module_method_callback(self, return_object): if not isinstance(return_object, ModuleReturnValue): raise InterpreterException('Bug in module, it returned an invalid object') @@ -1271,7 +1292,7 @@ class Interpreter(InterpreterBase): raise InterpreterException('Module returned a value of unknown type.') if len(outvalues) == 1 and unwrap_single: return outvalues[0] - return return_object.return_value + return self.holderify(return_object.return_value) def get_build_def_files(self): return self.build_def_files @@ -2109,7 +2130,7 @@ requirements use the version keyword argument instead.''') source_strings.append(s) sources += self.source_strings_to_files(source_strings) install_dir = kwargs.get('install_dir', None) - data = DataHolder(sources, install_dir) + data = DataHolder(build.Data(sources, install_dir)) self.build.data.append(data.held_object) return data @@ -2169,7 +2190,7 @@ requirements use the version keyword argument instead.''') idir = kwargs.get('install_dir', None) if isinstance(idir, str): cfile = mesonlib.File.from_built_file(ofile_path, ofile_fname) - self.build.data.append(DataHolder([cfile], idir).held_object) + self.build.data.append(build.Data([cfile], idir)) return mesonlib.File.from_built_file(self.subdir, output) @stringArgs diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py index 4b4ae3deb..fa52463a7 100644 --- a/mesonbuild/modules/i18n.py +++ b/mesonbuild/modules/i18n.py @@ -15,6 +15,8 @@ from os import path from .. import coredata, mesonlib, build from ..mesonlib import MesonException +from . import ModuleReturnValue + import sys import shutil @@ -59,7 +61,8 @@ class I18nModule: kwargs['command'] = ['msgfmt', '--' + file_type, '--template', '@INPUT@', '-d', podir, '-o', '@OUTPUT@'] - return build.CustomTarget(kwargs['output'] + '_merge', state.subdir, kwargs) + ct = build.CustomTarget(kwargs['output'] + '_merge', state.subdir, kwargs) + return ModuleReturnValue(ct, [ct]) def gettext(self, state, args, kwargs): if len(args) != 1: @@ -114,7 +117,7 @@ class I18nModule: args.append(lang_arg) iscript = build.RunScript(script, args) - return [pottarget, gmotarget, iscript, updatepotarget] + return ModuleReturnValue(None, [pottarget, gmotarget, iscript, updatepotarget]) def initialize(): return I18nModule() diff --git a/mesonbuild/modules/qt4.py b/mesonbuild/modules/qt4.py index beb7ca5f5..6759270f7 100644 --- a/mesonbuild/modules/qt4.py +++ b/mesonbuild/modules/qt4.py @@ -18,6 +18,7 @@ from .. import build from ..mesonlib import MesonException, Popen_safe from ..dependencies import Qt4Dependency import xml.etree.ElementTree as ET +from . import ModuleReturnValue class Qt4Module(): tools_detected = False @@ -153,7 +154,7 @@ class Qt4Module(): moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt4 moc source', moc_sources, state) sources.append(moc_output) - return sources + return ModuleReturnValue(sources, sources) def initialize(): mlog.warning('rcc dependencies will not work properly until this upstream issue is fixed:', diff --git a/mesonbuild/modules/qt5.py b/mesonbuild/modules/qt5.py index 2e348db69..53f1cb5ec 100644 --- a/mesonbuild/modules/qt5.py +++ b/mesonbuild/modules/qt5.py @@ -18,6 +18,7 @@ from .. import build from ..mesonlib import MesonException, Popen_safe from ..dependencies import Qt5Dependency import xml.etree.ElementTree as ET +from . import ModuleReturnValue class Qt5Module(): tools_detected = False @@ -159,7 +160,7 @@ class Qt5Module(): moc_gen = build.Generator([self.moc], moc_kwargs) moc_output = moc_gen.process_files('Qt5 moc source', moc_sources, state) sources.append(moc_output) - return sources + return ModuleReturnValue(sources, sources) def initialize(): mlog.warning('rcc dependencies will not work reliably until this upstream issue is fixed:',