Can specify PCH with keyword arguments.

This commit is contained in:
Jussi Pakkanen 2013-02-10 02:45:15 +02:00
parent c2e9de4f7f
commit d62f14b419
4 changed files with 15 additions and 12 deletions

View File

@ -153,7 +153,6 @@ class BuildTarget(InterpreterObject):
self.external_deps = []
self.include_dirs = []
self.methods.update({'add_dep': self.add_dep_method,
'pch' : self.pch_method,
'add_include_dirs': self.add_include_dirs_method,
'add_compiler_args' : self.add_compiler_args_method,
})
@ -171,6 +170,10 @@ class BuildTarget(InterpreterObject):
llist = [llist]
for linktarget in llist:
self.link(linktarget)
pchlist = kwargs.get('pch', [])
if not isinstance(pchlist, list):
pchlist = [pchlist]
self.add_pch(pchlist)
def get_subdir(self):
return self.subdir
@ -223,10 +226,8 @@ class BuildTarget(InterpreterObject):
raise InvalidArguments('Link target is not library.')
self.link_targets.append(target)
def pch_method(self, args):
if len(args) == 0:
raise InvalidArguments('Pch requires arguments.')
for a in args:
def add_pch(self, pchlist):
for a in pchlist:
self.pch.append(a)
def add_include_dirs_method(self, args):
@ -593,6 +594,7 @@ class Interpreter():
def assignment(self, node):
var_name = node.var_name
print(node.value)
if not isinstance(var_name, nodes.AtomExpression):
raise InvalidArguments('Line %d: Tried to assign value to a non-variable.' % node.lineno())
var_name = var_name.get_value()
@ -682,7 +684,9 @@ class Interpreter():
raise InvalidCode('You broke me.')
def evaluate_arraystatement(self, cur):
arguments = self.reduce_arguments(cur.get_args())
(arguments, kwargs) = self.reduce_arguments(cur.get_args())
if len(kwargs) > 0:
raise InvalidCode('Line %d: Keyword arguments are invalid in array construction.' % cur.lineno())
return arguments
if __name__ == '__main__':

View File

@ -1,4 +1,3 @@
project('pch test', 'c')
exe = executable('prog', 'prog.c')
exe.pch('pch/prog.h')
exe = executable('prog', 'prog.c', pch : 'pch/prog.h')

View File

@ -1,3 +1,2 @@
project('c++ pch test', 'cxx')
exe = executable('prog', 'prog.cc')
exe.pch('pch/prog.hh')
exe = executable('prog', 'prog.cc', pch : 'pch/prog.hh')

View File

@ -1,4 +1,5 @@
project('mixed C and C++ pch test', 'cxx', 'c')
exe = executable('prog', 'main.cc', 'func.c')
exe.pch('pch/main.hh', 'pch/func.h')
pch = ['pch/main.hh', 'pch/func.h']
exe = executable('prog', 'main.cc', 'func.c', pch : pch)