Define used languages in project() function.

pull/15/head
Jussi Pakkanen 12 years ago
parent c71f82432f
commit 03e557992a
  1. 17
      interpreter.py
  2. 3
      test cases/1 trivial/builder.txt
  3. 3
      test cases/2 cxx/builder.txt
  4. 3
      test cases/3 static/builder.txt
  5. 3
      test cases/4 shared/builder.txt
  6. 3
      test cases/5 linkstatic/builder.txt
  7. 3
      test cases/6 linkshared/builder.txt

@ -127,7 +127,6 @@ class Interpreter():
def build_func_dict(self):
self.funcs = {'project' : self.func_project,
'message' : self.func_message,
'language': self.func_language,
'executable': self.func_executable,
'find_dep' : self.func_find_dep,
'static_library' : self.func_static_lib,
@ -175,24 +174,22 @@ class Interpreter():
raise InvalidArguments('Incorrect argument type.')
def func_project(self, node, args):
self.validate_arguments(args, 1, [str])
if len(args) < 2:
raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
for a in args:
if not isinstance(a, str):
raise InvalidArguments('Line %d: Argument %s is not a string.' % (node.lineno(), str(a)))
if self.build.project is not None:
raise InvalidCode('Second call to project() on line %d.' % node.lineno())
self.build.project = args[0]
print('Project name is "%s".' % self.build.project)
self.add_languages(node, args[1:])
def func_message(self, node, args):
self.validate_arguments(args, 1, [str])
print('Message: %s' % args[0])
def func_language(self, node, args):
if len(args) == 0:
raise InvalidArguments('Line %d: no arguments to function language.' % 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)))
if len(self.build.compilers) > 0:
raise InvalidCode('Function language() can only be called once (line %d).' % node.lineno())
def add_languages(self, node, args):
for lang in args:
if lang.lower() == 'c':
comp = self.environment.detect_c_compiler()

@ -1,4 +1,3 @@
project('trivial test')
language('c')
project('trivial test', 'c')
exe = executable('trivialprog', 'trivial.c')
add_test('runtest', exe)

@ -1,4 +1,3 @@
project('c++ test')
language('c++')
project('c++ test', 'c++')
exe = executable('trivialprog', 'trivial.cc')
add_test('runtest', exe)

@ -1,3 +1,2 @@
project('static library test')
language('c')
project('static library test', 'c')
lib = static_library('mylib', 'libfile.c')

@ -1,3 +1,2 @@
project('shared library test')
language('c')
project('shared library test', 'c')
lib = shared_library('mylib', 'libfile.c')

@ -1,5 +1,4 @@
project('static library linking test')
language('c')
project('static library linking test', 'c')
lib = static_library('mylib', 'libfile.c')
exe = executable('prog', 'main.c')
exe.link(lib)

@ -1,5 +1,4 @@
project('shared library linking test')
language('c')
project('shared library linking test', 'c')
lib = shared_library('mylib', 'libfile.c')
exe = executable('prog', 'main.c')
exe.link(lib)

Loading…
Cancel
Save