diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2014-11-16 18:30:38 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2014-11-16 18:30:38 +0200 |
commit | 47bea982980ab6d9d31e623579b94fcbe1c66c9a (patch) | |
tree | 607b1bc6b9ce1ac9d476273603dbb03165127936 | |
parent | e0ec0c977f50c63c177c2a6a1e8e8e8bf9d5969e (diff) | |
download | meson-47bea982980ab6d9d31e623579b94fcbe1c66c9a.zip meson-47bea982980ab6d9d31e623579b94fcbe1c66c9a.tar.gz meson-47bea982980ab6d9d31e623579b94fcbe1c66c9a.tar.bz2 |
Allow getting builtin options with get_option. Fixes #23.
-rw-r--r-- | coredata.py | 27 | ||||
-rw-r--r-- | interpreter.py | 4 | ||||
-rw-r--r-- | test cases/common/47 options/meson.build | 4 |
3 files changed, 35 insertions, 0 deletions
diff --git a/coredata.py b/coredata.py index e7d8bcd..177a9d0 100644 --- a/coredata.py +++ b/coredata.py @@ -55,6 +55,33 @@ class CoreData(): self.ext_progs = {} self.ext_libs = {} + def get_builtin_option(self, optname): + if optname == 'type': + return self.buildtype + if optname == 'strip': + return self.strip + if optname == 'coverage': + return self.coverage + if optname == 'pch': + return self.use_pch + if optname == 'unity': + return self.unity + if optname == 'prefix': + return self.prefix + if optname == 'libdir': + return self.libdir + if optname == 'bindir': + return self.bindir + if optname == 'includedir': + return self.includedir + if optname == 'datadir': + return self.datadir + if optname == 'mandir': + return self.mandir + if optname == 'localedir': + return self.localedir + raise RuntimeError('Tried to get unknown builtin option %s' % optname) + def load(filename): obj = pickle.load(open(filename, 'rb')) if not isinstance(obj, CoreData): diff --git a/interpreter.py b/interpreter.py index e2a7b16..a28d660 100644 --- a/interpreter.py +++ b/interpreter.py @@ -932,6 +932,10 @@ class Interpreter(): raise InterpreterException('Argument of get_option must be a string.') if self.subproject != '': optname = self.subproject + '-' + optname + try: + return self.environment.get_coredata().get_builtin_option(optname) + except RuntimeError: + pass if optname not in self.environment.coredata.user_options: raise InterpreterException('Tried to access unknown option "%s".' % optname) return self.environment.coredata.user_options[optname].value diff --git a/test cases/common/47 options/meson.build b/test cases/common/47 options/meson.build index 6604d8a..796c27f 100644 --- a/test cases/common/47 options/meson.build +++ b/test cases/common/47 options/meson.build @@ -11,3 +11,7 @@ endif if get_option('combo_opt') != 'combo' error('Incorrect value to combo option.') endif + +if get_option('includedir') != 'include' + error('Incorrect value in builtin option.') +endif |