aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinterpreter.py14
-rw-r--r--test cases/12 data/builder.txt2
2 files changed, 10 insertions, 6 deletions
diff --git a/interpreter.py b/interpreter.py
index 2dccd61..4f8ff59 100755
--- a/interpreter.py
+++ b/interpreter.py
@@ -92,10 +92,14 @@ class Headers(InterpreterObject):
class Data(InterpreterObject):
- def __init__(self, subdir, sources):
+ def __init__(self, subdir, sources, kwargs):
InterpreterObject.__init__(self)
self.subdir = subdir
self.sources = sources
+ kwsource = kwargs.get('sources', [])
+ if not isinstance(kwsource, list):
+ kwsource = [kwsource]
+ self.sources += kwsource
def get_subdir(self):
return self.subdir
@@ -496,13 +500,13 @@ class Interpreter():
self.evaluate_codeblock(codeblock)
self.subdir = prev_subdir
- def func_data(self, node, args):
- if len(args ) < 2:
- raise InvalidArguments('Line %d: Data function must have at least two arguments: name and source file(s)' % node.lineno())
+ def func_data(self, node, args, kwargs):
+ if len(args ) < 1:
+ raise InvalidArguments('Line %d: Data function must have at least one argument: the subdirectory.' % node.lineno())
for a in args:
if not isinstance(a, str):
raise InvalidArguments('Line %d: Argument %s is not a string.' % (node.lineno(), str(a)))
- data = Data(args[0], args[1:])
+ data = Data(args[0], args[1:], kwargs)
self.build.data.append(data)
return data
diff --git a/test cases/12 data/builder.txt b/test cases/12 data/builder.txt
index 6171940..f529bac 100644
--- a/test cases/12 data/builder.txt
+++ b/test cases/12 data/builder.txt
@@ -1,2 +1,2 @@
project('data install test', 'c')
-data('progname', 'datafile.dat')
+data('progname', sources : 'datafile.dat')