diff --git a/coredata.py b/coredata.py index e7d8bcdf3..177a9d0f9 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 e2a7b16dd..a28d660ba 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 6604d8a3f..796c27f65 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