diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-03-07 00:34:05 +0530 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-03-11 07:11:59 -0400 |
commit | c7aa4c8861eb6c1d3534b3b0e94e901b7b2d0206 (patch) | |
tree | 3979ef7df1f5addad9da44f143c936a2bc31ba02 /mesonbuild | |
parent | bc135f6c4dd56c925438d9c84f3bb6794f7ecaa3 (diff) | |
download | meson-c7aa4c8861eb6c1d3534b3b0e94e901b7b2d0206.zip meson-c7aa4c8861eb6c1d3534b3b0e94e901b7b2d0206.tar.gz meson-c7aa4c8861eb6c1d3534b3b0e94e901b7b2d0206.tar.bz2 |
coredata: Set default options as cmdline args that override each other
The previous code was assuming that options do not depend on each
other, and that you can set defaults using `dict.setdefault()`. This
is not true for `buildtype` + `optimization`/`debug`, so we add
defaults + overrides in the right order and use the options parsing
code later to compute the values.
Includes a test.
Closes https://github.com/mesonbuild/meson/issues/6752
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/coredata.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index fdd8cab..a0df24d 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -718,13 +718,8 @@ class CoreData: self.copy_build_options_from_regular_ones() def set_default_options(self, default_options, subproject, env): - # Set defaults first from conf files (cross or native), then - # override them as nec as necessary. - for k, v in env.paths.host: - if v is not None: - env.cmd_line_options.setdefault(k, v) - - # Set default options as if they were passed to the command line. + cmd_line_options = OrderedDict() + # Set project default_options as if they were passed to the cmdline. # Subprojects can only define default for user options and not yielding # builtin option. from . import optinterpreter @@ -734,7 +729,17 @@ class CoreData: and optinterpreter.is_invalid_name(k, log=False): continue k = subproject + ':' + k - env.cmd_line_options.setdefault(k, v) + cmd_line_options[k] = v + + # Override project default_options using conf files (cross or native) + for k, v in env.paths.host: + if v is not None: + cmd_line_options[k] = v + + # Override all the above defaults using the command-line arguments + # actually passed to us + cmd_line_options.update(env.cmd_line_options) + env.cmd_line_options = cmd_line_options # Create a subset of cmd_line_options, keeping only options for this # subproject. Also take builtin options if it's the main project. |