diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-01-11 23:13:49 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-01-11 23:13:49 +0200 |
commit | 03e557992acc87e9ee545db74f8bb1b90592076e (patch) | |
tree | 63872828434a302b069e6723f469b9fd66ecb32f | |
parent | c71f82432fab3f031f1805595daf03e08c1b4b87 (diff) | |
download | meson-03e557992acc87e9ee545db74f8bb1b90592076e.zip meson-03e557992acc87e9ee545db74f8bb1b90592076e.tar.gz meson-03e557992acc87e9ee545db74f8bb1b90592076e.tar.bz2 |
Define used languages in project() function.
-rwxr-xr-x | interpreter.py | 17 | ||||
-rw-r--r-- | test cases/1 trivial/builder.txt | 3 | ||||
-rw-r--r-- | test cases/2 cxx/builder.txt | 3 | ||||
-rw-r--r-- | test cases/3 static/builder.txt | 3 | ||||
-rw-r--r-- | test cases/4 shared/builder.txt | 3 | ||||
-rw-r--r-- | test cases/5 linkstatic/builder.txt | 3 | ||||
-rw-r--r-- | test cases/6 linkshared/builder.txt | 3 |
7 files changed, 13 insertions, 22 deletions
diff --git a/interpreter.py b/interpreter.py index 85993fd..f651bdd 100755 --- a/interpreter.py +++ b/interpreter.py @@ -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() diff --git a/test cases/1 trivial/builder.txt b/test cases/1 trivial/builder.txt index c8a0ae2..dc2a992 100644 --- a/test cases/1 trivial/builder.txt +++ b/test cases/1 trivial/builder.txt @@ -1,4 +1,3 @@ -project('trivial test') -language('c') +project('trivial test', 'c') exe = executable('trivialprog', 'trivial.c') add_test('runtest', exe) diff --git a/test cases/2 cxx/builder.txt b/test cases/2 cxx/builder.txt index 031bc9e..8b5b286 100644 --- a/test cases/2 cxx/builder.txt +++ b/test cases/2 cxx/builder.txt @@ -1,4 +1,3 @@ -project('c++ test') -language('c++') +project('c++ test', 'c++') exe = executable('trivialprog', 'trivial.cc') add_test('runtest', exe) diff --git a/test cases/3 static/builder.txt b/test cases/3 static/builder.txt index 301aac1..fd33e1c 100644 --- a/test cases/3 static/builder.txt +++ b/test cases/3 static/builder.txt @@ -1,3 +1,2 @@ -project('static library test') -language('c') +project('static library test', 'c') lib = static_library('mylib', 'libfile.c') diff --git a/test cases/4 shared/builder.txt b/test cases/4 shared/builder.txt index a0505fe..a148272 100644 --- a/test cases/4 shared/builder.txt +++ b/test cases/4 shared/builder.txt @@ -1,3 +1,2 @@ -project('shared library test') -language('c') +project('shared library test', 'c') lib = shared_library('mylib', 'libfile.c') diff --git a/test cases/5 linkstatic/builder.txt b/test cases/5 linkstatic/builder.txt index 1b61eee..c858711 100644 --- a/test cases/5 linkstatic/builder.txt +++ b/test cases/5 linkstatic/builder.txt @@ -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) diff --git a/test cases/6 linkshared/builder.txt b/test cases/6 linkshared/builder.txt index 6bec6d2..5889e2e 100644 --- a/test cases/6 linkshared/builder.txt +++ b/test cases/6 linkshared/builder.txt @@ -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) |