Allow getting builtin options with get_option. Fixes #23.
This commit is contained in:
parent
e0ec0c977f
commit
47bea98298
27
coredata.py
27
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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue