aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--environment.py1
-rw-r--r--interpreter.py3
-rwxr-xr-xmeson.py2
-rw-r--r--optinterpreter.py20
-rw-r--r--readme.txt4
5 files changed, 25 insertions, 5 deletions
diff --git a/environment.py b/environment.py
index bd9a745..7072005 100644
--- a/environment.py
+++ b/environment.py
@@ -1376,6 +1376,7 @@ class Environment():
self.cross_info = CrossBuildInfo(self.coredata.cross_file)
else:
self.cross_info = None
+ self.cmd_line_options = options.projectoptions
# List of potential compilers.
if is_windows():
diff --git a/interpreter.py b/interpreter.py
index 776a897..d226d86 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -639,7 +639,8 @@ class Interpreter():
self.source_root = build.environment.get_source_dir()
option_file = os.path.join(self.source_root, self.subdir, 'meson_options.txt')
if os.path.exists(option_file):
- oi = optinterpreter.OptionInterpreter(self.subproject)
+ oi = optinterpreter.OptionInterpreter(self.subproject,\
+ self.build.environment.cmd_line_options)
oi.process(option_file)
self.build.environment.merge_options(oi.options)
mesonfile = os.path.join(self.source_root, self.subdir, environment.build_filename)
diff --git a/meson.py b/meson.py
index 0c6ae36..a53ebd6 100755
--- a/meson.py
+++ b/meson.py
@@ -70,6 +70,8 @@ parser.add_option('--werror', action='store_true', dest='werror', default=False,
help='Treat warnings as errors')
parser.add_option('--cross-file', default=None, dest='cross_file',
help='file describing cross compilation environment')
+parser.add_option('-D', action='append', type='string', dest='projectoptions', default=[],
+ help='Set project options.')
class MesonApp():
diff --git a/optinterpreter.py b/optinterpreter.py
index 812b6f4..900ecbf 100644
--- a/optinterpreter.py
+++ b/optinterpreter.py
@@ -39,6 +39,9 @@ class UserOption:
super().__init__()
self.description = kwargs.get('description', '')
+ def parse_string(self, valuestring):
+ return valuestring
+
class UserStringOption(UserOption):
def __init__(self, kwargs):
super().__init__(kwargs)
@@ -59,6 +62,13 @@ class UserBooleanOption(UserOption):
raise OptionException('Value of boolean option is not boolean.')
self.value = newvalue
+ def parse_string(self, valuestring):
+ if valuestring == 'false':
+ return False
+ if valuestring == 'true':
+ return True
+ raise OptionException('Value %s is not a boolean.' % valuestring)
+
class UserComboOption(UserOption):
def __init__(self, kwargs):
super().__init__(kwargs)
@@ -83,10 +93,14 @@ option_types = {'string' : UserStringOption,
}
class OptionInterpreter:
- def __init__(self, subproject):
+ def __init__(self, subproject, command_line_options):
self.options = {}
self.subproject = subproject
-
+ self.cmd_line_options = {}
+ for o in command_line_options:
+ (key, value) = o.split('=', 1)
+ self.cmd_line_options[key] = value
+
def process(self, option_file):
try:
ast = mparser.Parser(open(option_file, 'r').read()).parse()
@@ -159,4 +173,6 @@ class OptionInterpreter:
opt = option_types[opt_type](kwargs)
if opt.description == '':
opt.description = opt_name
+ if opt_name in self.cmd_line_options:
+ opt.set_value(opt.parse_string(self.cmd_line_options[opt_name]))
self.options[opt_name] = opt
diff --git a/readme.txt b/readme.txt
index e9ba51c..fa0db27 100644
--- a/readme.txt
+++ b/readme.txt
@@ -4,8 +4,8 @@ build system.
Dependencies
-Python 3.3: http://python.org
-Ninja: http://martine.github.com/ninja/
+Python http://python.org (version 3.3 or newer)
+Ninja http://martine.github.com/ninja/
Installing from source