diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-10-16 22:33:33 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-10-16 22:33:33 +0300 |
commit | 309a5c1510810d3676dcec9962894a3353ce218c (patch) | |
tree | 60bff326cf68f7eb5c1422b5800bdbd30727bb4d /interpreter.py | |
parent | 4e522ef2158c8ba4bac3f13b31ecd2f746696a84 (diff) | |
download | meson-309a5c1510810d3676dcec9962894a3353ce218c.zip meson-309a5c1510810d3676dcec9962894a3353ce218c.tar.gz meson-309a5c1510810d3676dcec9962894a3353ce218c.tar.bz2 |
Options can be accessed from scripts.
Diffstat (limited to 'interpreter.py')
-rw-r--r-- | interpreter.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/interpreter.py b/interpreter.py index 4b35234..5c3a317 100644 --- a/interpreter.py +++ b/interpreter.py @@ -580,6 +580,7 @@ class Interpreter(): 'run_command' : self.func_run_command, 'gettext' : self.func_gettext, 'option' : self.func_option, + 'get_option' : self.func_get_option, } def get_build_def_files(self): @@ -696,6 +697,16 @@ class Interpreter(): def func_option(self, nodes, args, kwargs): raise InterpreterException('Tried to call option() in build description file. All options must be in the option file.') + def func_get_option(self, nodes, args, kwargs): + if len(args) != 1: + raise InterpreterException('Argument required for get_option.') + optname = args[0] + if not isinstance(optname, str): + raise InterpreterException('Argument of get_option must be a string.') + if optname not in self.build.user_options: + raise InterpreterException('Tried to access unknown option "%s".' % optname) + return self.build.user_options[optname].value + def func_configuration_data(self, node, args, kwargs): if len(args) != 0: raise InterpreterException('configuration_data takes no arguments') |