aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interpreter.py8
-rwxr-xr-xmeson.py7
-rwxr-xr-xmesongui.py2
-rw-r--r--optinterpreter.py5
-rw-r--r--test cases/common/50 subproject options/meson.build7
-rw-r--r--test cases/common/50 subproject options/meson_options.txt1
-rw-r--r--test cases/common/50 subproject options/subproject/meson.build5
-rw-r--r--test cases/common/50 subproject options/subproject/meson_options.txt1
8 files changed, 28 insertions, 8 deletions
diff --git a/interpreter.py b/interpreter.py
index 61f5938..b32e47a 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -19,6 +19,7 @@ import coredata
import dependencies
import mlog
import build
+import optinterpreter
import os, sys, platform, subprocess, shutil
class InterpreterException(coredata.MesonException):
@@ -558,6 +559,11 @@ class Interpreter():
self.build = build
self.subproject = subproject
self.source_root = os.path.join(build.environment.get_source_dir(), subproject)
+ option_file = os.path.join(self.source_root, 'meson_options.txt')
+ if os.path.exists(option_file):
+ oi = optinterpreter.OptionInterpreter(self.subproject)
+ oi.process(option_file)
+ self.build.environment.merge_options(oi.options)
code = open(os.path.join(self.source_root, environment.build_filename)).read()
if len(code.strip()) == 0:
raise InvalidCode('Builder file is empty.')
@@ -754,6 +760,8 @@ class Interpreter():
optname = args[0]
if not isinstance(optname, str):
raise InterpreterException('Argument of get_option must be a string.')
+ if self.subproject != '':
+ optname = self.subproject + '-' + optname
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/meson.py b/meson.py
index 4aa7b1c..d96dffc 100755
--- a/meson.py
+++ b/meson.py
@@ -17,7 +17,7 @@
from optparse import OptionParser
import sys, stat, traceback, pickle
import os.path
-import environment, interpreter, optinterpreter
+import environment, interpreter
import backends, build
import mlog, coredata
@@ -121,11 +121,6 @@ itself as required.'''
else:
mlog.log('Build type:', mlog.bold('native build'))
b = build.Build(env)
- option_file = os.path.join(self.source_dir, 'meson_options.txt')
- if os.path.exists(option_file):
- oi = optinterpreter.OptionInterpreter()
- oi.process(option_file)
- env.merge_options(oi.options)
intr = interpreter.Interpreter(b)
intr.run()
if options.backend == 'ninja':
diff --git a/mesongui.py b/mesongui.py
index 77853de..ad15522 100755
--- a/mesongui.py
+++ b/mesongui.py
@@ -413,7 +413,7 @@ class MesonGui():
self.ui.save_button.clicked.connect(self.save)
def fill_data(self):
- self.ui.project_label.setText(self.build.project)
+ self.ui.project_label.setText(self.build.projects[''])
self.ui.srcdir_label.setText(self.src_dir)
self.ui.builddir_label.setText(self.build_dir)
if self.coredata.cross_file is None:
diff --git a/optinterpreter.py b/optinterpreter.py
index 154b5fe..756ec5f 100644
--- a/optinterpreter.py
+++ b/optinterpreter.py
@@ -69,8 +69,9 @@ option_types = {'string' : UserStringOption,
}
class OptionInterpreter:
- def __init__(self):
+ def __init__(self, subproject):
self.options = {}
+ self.subproject = subproject
def process(self, option_file):
try:
@@ -137,6 +138,8 @@ class OptionInterpreter:
opt_name = posargs[0]
if not isinstance(opt_name, str):
raise OptionException('Positional argument must be a string.')
+ if self.subproject != '':
+ opt_name = self.subproject + '-' + opt_name
opt = option_types[opt_type](kwargs)
if opt.description == '':
opt.description = opt_name
diff --git a/test cases/common/50 subproject options/meson.build b/test cases/common/50 subproject options/meson.build
new file mode 100644
index 0000000..d4598b6
--- /dev/null
+++ b/test cases/common/50 subproject options/meson.build
@@ -0,0 +1,7 @@
+project('suboptions', 'c')
+
+subproject('subproject')
+
+if not get_option('opt')
+ error('option unset when it should be set')
+endif
diff --git a/test cases/common/50 subproject options/meson_options.txt b/test cases/common/50 subproject options/meson_options.txt
new file mode 100644
index 0000000..658c4b0
--- /dev/null
+++ b/test cases/common/50 subproject options/meson_options.txt
@@ -0,0 +1 @@
+option('opt', type : 'boolean', value : true)
diff --git a/test cases/common/50 subproject options/subproject/meson.build b/test cases/common/50 subproject options/subproject/meson.build
new file mode 100644
index 0000000..1f52e19
--- /dev/null
+++ b/test cases/common/50 subproject options/subproject/meson.build
@@ -0,0 +1,5 @@
+project('subproject', 'c')
+
+if get_option('opt')
+ error('option unset when it should be set.')
+endif
diff --git a/test cases/common/50 subproject options/subproject/meson_options.txt b/test cases/common/50 subproject options/subproject/meson_options.txt
new file mode 100644
index 0000000..071740b
--- /dev/null
+++ b/test cases/common/50 subproject options/subproject/meson_options.txt
@@ -0,0 +1 @@
+option('opt', type : 'boolean', value : false)