aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2018-05-13 10:36:58 -0400
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-06-06 20:02:37 +0000
commit75e501ceb8888562b2749d20ba2c43374e5c9671 (patch)
tree48418eb4a15442f262fbe2a35477b14cf8c0e0ca /mesonbuild/interpreter.py
parent8afbfe227bb4f8848865f95980d51caf569eeff9 (diff)
downloadmeson-75e501ceb8888562b2749d20ba2c43374e5c9671.zip
meson-75e501ceb8888562b2749d20ba2c43374e5c9671.tar.gz
meson-75e501ceb8888562b2749d20ba2c43374e5c9671.tar.bz2
coredata: Stop setting default option values as argparse attribute
All options are now the projectoptions list, regardless of how they got defined in the command line. This also delays setting builtin option values until the main project() default options are parsed to simplify the code. This is possible because we already delayed setting the backend after parsing main project() in a previous commit.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 320e543..ffe942f 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2218,18 +2218,8 @@ to directly access options of other subprojects.''')
if coredata.is_builtin_option(key):
if self.subproject != '':
continue # Only the master project is allowed to set global options.
- # If this was set on the command line, do not override.
- if not self.environment.had_argument_for(key):
- self.coredata.set_builtin_option(key, value)
- # If we are setting the prefix, then other options which
- # have prefix-dependent defaults need their value updating,
- # if they haven't been explicitly set (i.e. have their
- # default value)
- if key == 'prefix':
- for option in coredata.builtin_dir_noprefix_options:
- if not (self.environment.had_argument_for(option) or
- any([k.startswith(option + '=') for k in default_options])):
- self.coredata.set_builtin_option(option, coredata.get_builtin_option_default(option, value))
+ newoptions = [option] + self.environment.cmd_line_options.projectoptions
+ self.environment.cmd_line_options.projectoptions = newoptions
else:
# Option values set with subproject() default_options override those
# set in project() default_options.
@@ -2256,6 +2246,14 @@ to directly access options of other subprojects.''')
newoptions = [defopt] + self.environment.cmd_line_options.projectoptions
self.environment.cmd_line_options.projectoptions = newoptions
+ def set_builtin_options(self):
+ # Create a dict containing only builtin options, then use
+ # coredata.set_options() because it already has code to set the prefix
+ # option first to sanitize all other options.
+ options = coredata.create_options_dict(self.environment.cmd_line_options.projectoptions)
+ options = {k: v for k, v in options.items() if coredata.is_builtin_option(k)}
+ self.coredata.set_options(options)
+
def set_backend(self):
# The backend is already set when parsing subprojects
if self.backend is not None:
@@ -2301,6 +2299,7 @@ to directly access options of other subprojects.''')
self.parse_default_options(default_options)
if not self.is_subproject():
self.build.project_name = proj_name
+ self.set_builtin_options()
if os.path.exists(self.option_file):
oi = optinterpreter.OptionInterpreter(self.subproject,
self.build.environment.cmd_line_options.projectoptions,