diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-06-06 22:15:30 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-06-06 22:15:30 +0300 |
commit | 9c9ab251901912f5e96ffc186611fec7ddc635eb (patch) | |
tree | 7f842ed5a4fe128b2eabc7f5ba1b5a479d9f6b6b | |
parent | bf02849d59e1f39395982c7c7ab3322579ac39e9 (diff) | |
download | meson-9c9ab251901912f5e96ffc186611fec7ddc635eb.tar.gz |
Created a build_target function to set build target type dynamically.
-rw-r--r-- | interpreter.py | 16 | ||||
-rw-r--r-- | test cases/common/5 linkstatic/meson.build | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/interpreter.py b/interpreter.py index caa1948c5..98b517500 100644 --- a/interpreter.py +++ b/interpreter.py @@ -793,6 +793,7 @@ class Interpreter(): 'static_library' : self.func_static_lib, 'shared_library' : self.func_shared_lib, 'jar' : self.func_jar, + 'build_target': self.func_build_target, 'custom_target' : self.func_custom_target, 'run_target' : self.func_run_target, 'generator' : self.func_generator, @@ -1289,6 +1290,21 @@ class Interpreter(): def func_jar(self, node, args, kwargs): return self.build_target(node, args, kwargs, JarHolder) + def func_build_target(self, node, args, kwargs): + if 'target_type' not in kwargs: + raise InterpreterException('Missing target_type keyword argument') + target_type = kwargs.pop('target_type') + if target_type == 'executable': + return self.func_executable(node, args, kwargs) + elif target_type == 'shared_library': + return self.func_shared_lib(node, args, kwargs) + elif target_type == 'static_library': + return self.func_static_lib(node, args, kwargs) + elif target_type == 'jar': + return self.func_jar(node, args, kwargs) + else: + raise InterpreterException('Unknown target_type.') + def func_vcs_tag(self, node, args, kwargs): fallback = kwargs.pop('fallback', None) if not isinstance(fallback, str): diff --git a/test cases/common/5 linkstatic/meson.build b/test cases/common/5 linkstatic/meson.build index 5eaa942b1..c1cb8b639 100644 --- a/test cases/common/5 linkstatic/meson.build +++ b/test cases/common/5 linkstatic/meson.build @@ -1,5 +1,6 @@ project('static library linking test', 'c') -lib = static_library('mylib', 'libfile.c') + +lib = build_target('mylib', 'libfile.c', target_type : 'static_library') exe = executable('prog', 'main.c', link_with : lib) test('runtest', exe) |