Allow getting builtin options with get_option. Fixes #23.

pull/24/head
Jussi Pakkanen 10 years ago
parent e0ec0c977f
commit 47bea98298
  1. 27
      coredata.py
  2. 4
      interpreter.py
  3. 4
      test cases/common/47 options/meson.build

@ -55,6 +55,33 @@ class CoreData():
self.ext_progs = {} self.ext_progs = {}
self.ext_libs = {} 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): def load(filename):
obj = pickle.load(open(filename, 'rb')) obj = pickle.load(open(filename, 'rb'))
if not isinstance(obj, CoreData): if not isinstance(obj, CoreData):

@ -932,6 +932,10 @@ class Interpreter():
raise InterpreterException('Argument of get_option must be a string.') raise InterpreterException('Argument of get_option must be a string.')
if self.subproject != '': if self.subproject != '':
optname = self.subproject + '-' + optname 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: if optname not in self.environment.coredata.user_options:
raise InterpreterException('Tried to access unknown option "%s".' % optname) raise InterpreterException('Tried to access unknown option "%s".' % optname)
return self.environment.coredata.user_options[optname].value return self.environment.coredata.user_options[optname].value

@ -11,3 +11,7 @@ endif
if get_option('combo_opt') != 'combo' if get_option('combo_opt') != 'combo'
error('Incorrect value to combo option.') error('Incorrect value to combo option.')
endif endif
if get_option('includedir') != 'include'
error('Incorrect value in builtin option.')
endif

Loading…
Cancel
Save