diff options
-rw-r--r-- | backends.py | 7 | ||||
-rw-r--r-- | interpreter.py | 16 | ||||
-rw-r--r-- | modules/gnome.py | 14 | ||||
-rw-r--r-- | mparser.py | 23 | ||||
-rw-r--r-- | test cases/common/48 test args/meson.build | 1 | ||||
-rwxr-xr-x | test cases/common/48 test args/tester.py | 6 | ||||
-rw-r--r-- | test cases/common/48 test args/testfile.txt | 1 | ||||
-rw-r--r-- | test cases/common/91 plusassign/meson.build | 8 | ||||
-rw-r--r-- | test cases/failing/10 out of bounds/meson.build | 2 | ||||
-rw-r--r-- | test cases/frameworks/10 gtk-doc/doc/meson.build | 2 | ||||
-rw-r--r-- | test cases/frameworks/10 gtk-doc/meson.build | 2 |
11 files changed, 70 insertions, 12 deletions
diff --git a/backends.py b/backends.py index 760bc52..05e4429 100644 --- a/backends.py +++ b/backends.py @@ -267,8 +267,13 @@ class Backend(): extra_paths = self.determine_windows_extra_paths(exe) else: extra_paths = [] + cmd_args = [] + for a in t.cmd_args: + if isinstance(a, mesonlib.File): + a = os.path.join(self.environment.get_build_dir(), a.rel_to_builddir(self.build_to_src)) + cmd_args.append(a) ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper, - t.is_parallel, t.cmd_args, t.env, t.should_fail, t.valgrind_args, + t.is_parallel, cmd_args, t.env, t.should_fail, t.valgrind_args, t.timeout, extra_paths) arr.append(ts) pickle.dump(arr, datafile) diff --git a/interpreter.py b/interpreter.py index cd4788f..3443058 100644 --- a/interpreter.py +++ b/interpreter.py @@ -1056,6 +1056,8 @@ class Interpreter(): return self.evaluate_foreach(cur) elif isinstance(cur, mparser.PlusAssignmentNode): return self.evaluate_plusassign(cur) + elif isinstance(cur, mparser.IndexNode): + return self.evaluate_indexing(cur) elif self.is_elementary_type(cur): return cur else: @@ -1465,7 +1467,7 @@ class Interpreter(): if not isinstance(cmd_args, list): cmd_args = [cmd_args] for i in cmd_args: - if not isinstance(i, str): + if not isinstance(i, (str, mesonlib.File)): raise InterpreterException('Command line arguments must be strings') envlist = kwargs.get('env', []) if not isinstance(envlist, list): @@ -1903,6 +1905,18 @@ class Interpreter(): new_value = old_variable + [addition] self.set_variable(varname, new_value) + def evaluate_indexing(self, node): + assert(isinstance(node, mparser.IndexNode)) + iobject = self.evaluate_statement(node.iobject) + if not isinstance(iobject, list): + raise InterpreterException('Tried to index a non-array object.') + index = self.evaluate_statement(node.index) + if not isinstance(index, int): + raise InterpreterException('Index value is not an integer.') + if index < -len(iobject) or index >= len(iobject): + raise InterpreterException('Index %d out of bounds of array of size %d.' % (index, len(iobject))) + return iobject[index] + def is_elementary_type(self, v): if isinstance(v, (int, float, str, bool, list)): return True diff --git a/modules/gnome.py b/modules/gnome.py index fc3f408..7e51174 100644 --- a/modules/gnome.py +++ b/modules/gnome.py @@ -59,7 +59,7 @@ class GnomeModule: scan_command = ['g-ir-scanner', '@INPUT@'] scan_command += pkgargs - scan_command += ['--namespace='+ns, '--nsversion=' + nsversion, '--warn-all', + scan_command += ['--no-libtool', '--namespace='+ns, '--nsversion=' + nsversion, '--warn-all', '--output', '@OUTPUT@'] extra_args = kwargs.pop('extra_args', []) @@ -208,10 +208,20 @@ class GnomeModule: src_dir = kwargs['src_dir'] targetname = modulename + '-doc' command = os.path.normpath(os.path.join(os.path.split(__file__)[0], "../gtkdochelper.py")) + if hasattr(src_dir, 'held_object'): + src_dir= src_dir.held_object + if not isinstance(src_dir, build.IncludeDirs): + raise MesonException('Invalidt keyword argument for src_dir.') + incdirs = src_dir.get_incdirs() + if len(incdirs) != 1: + raise MesonException('Argument src_dir has more than one directory specified.') + header_dir = os.path.join(state.environment.get_source_dir(), src_dir.get_curdir(), incdirs[0]) + else: + header_dir = os.path.normpath(os.path.join(state.subdir, src_dir)) args = [state.environment.get_source_dir(), state.environment.get_build_dir(), state.subdir, - os.path.normpath(os.path.join(state.subdir, src_dir)), + header_dir, main_file, modulename] res = [build.RunTarget(targetname, command, args, state.subdir)] @@ -210,6 +210,13 @@ class CodeBlockNode: self.colno = colno self.lines = [] +class IndexNode: + def __init__(self, iobject, index): + self.iobject = iobject + self.index = index + self.lineno = iobject.lineno + self.colno = iobject.colno + class MethodNode: def __init__(self, lineno, colno, source_object, name, args): self.lineno = lineno @@ -429,8 +436,15 @@ class Parser: raise ParseException('Function call must be applied to plain id', left.lineno, left.colno) left = FunctionNode(left.lineno, left.colno, left.value, args) - while self.accept('dot'): - left = self.method_call(left) + go_again = True + while go_again: + go_again = False + if self.accept('dot'): + go_again = True + left = self.method_call(left) + if self.accept('lbracket'): + go_again = True + left = self.index_call(left) return left def e8(self): @@ -492,6 +506,11 @@ class Parser: return self.method_call(method) return method + def index_call(self, source_object): + index_statement = self.statement() + self.expect('rbracket') + return IndexNode(source_object, index_statement) + def foreachblock(self): t = self.current self.expect('id') diff --git a/test cases/common/48 test args/meson.build b/test cases/common/48 test args/meson.build index 1243c21..f81450c 100644 --- a/test cases/common/48 test args/meson.build +++ b/test cases/common/48 test args/meson.build @@ -5,3 +5,4 @@ e2 = executable('envvars', 'envvars.c') test('command line arguments', e1, args : ['first', 'second']) test('environment variables', e2, env : ['first=val1', 'second=val2']) +test('file arg', find_program('tester.py'), args : files('testfile.txt')) diff --git a/test cases/common/48 test args/tester.py b/test cases/common/48 test args/tester.py new file mode 100755 index 0000000..36e510d --- /dev/null +++ b/test cases/common/48 test args/tester.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import sys + +if open(sys.argv[1]).read() != 'contents\n': + sys.exit(1) diff --git a/test cases/common/48 test args/testfile.txt b/test cases/common/48 test args/testfile.txt new file mode 100644 index 0000000..12f00e9 --- /dev/null +++ b/test cases/common/48 test args/testfile.txt @@ -0,0 +1 @@ +contents diff --git a/test cases/common/91 plusassign/meson.build b/test cases/common/91 plusassign/meson.build index 0093d88..c1e47e0 100644 --- a/test cases/common/91 plusassign/meson.build +++ b/test cases/common/91 plusassign/meson.build @@ -8,7 +8,7 @@ if x.length() != 1 error('Incorrect append') endif -if x.get(0) != 'a' +if x[0] != 'a' error('Incorrect append 2.') endif @@ -20,7 +20,7 @@ if y.length() != 1 error('Immutability broken.') endif -if y.get(0) != 'a' +if y[0] != 'a' error('Immutability broken 2.') endif @@ -28,11 +28,11 @@ if x.length() != 2 error('Incorrect append 3') endif -if x.get(0) != 'a' +if x[0] != 'a' error('Incorrect append 4.') endif -if x.get(1) != 'b' +if x[1] != 'b' error('Incorrect append 5.') endif diff --git a/test cases/failing/10 out of bounds/meson.build b/test cases/failing/10 out of bounds/meson.build index 5c7f267..f791675 100644 --- a/test cases/failing/10 out of bounds/meson.build +++ b/test cases/failing/10 out of bounds/meson.build @@ -1,4 +1,4 @@ project('out of bounds', 'c') x = [] -y = x.get(0) +y = x[0] diff --git a/test cases/frameworks/10 gtk-doc/doc/meson.build b/test cases/frameworks/10 gtk-doc/doc/meson.build index c9b4089..3172b42 100644 --- a/test cases/frameworks/10 gtk-doc/doc/meson.build +++ b/test cases/frameworks/10 gtk-doc/doc/meson.build @@ -6,4 +6,4 @@ configure_file(input : 'version.xml.in', output : 'version.xml', configuration : cdata) -gnome.gtkdoc('foobar', src_dir : '../include', main_sgml : 'foobar-docs.sgml', install : true) +gnome.gtkdoc('foobar', src_dir : inc, main_sgml : 'foobar-docs.sgml', install : true) diff --git a/test cases/frameworks/10 gtk-doc/meson.build b/test cases/frameworks/10 gtk-doc/meson.build index bb2e340..1aad637 100644 --- a/test cases/frameworks/10 gtk-doc/meson.build +++ b/test cases/frameworks/10 gtk-doc/meson.build @@ -1,3 +1,5 @@ project('gtkdoctest', 'c') +inc = include_directories('include') + subdir('doc') |