aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-07-27 18:35:20 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2018-08-14 23:06:55 +0300
commit219dec39c09789f2b296e5af00305fe05fa3362b (patch)
tree530052f1009e5757dc3e6ad88f91255f96ce989b /mesonbuild/interpreter.py
parent28754ea621930a812f6c885d3c64cd90d95b4ce8 (diff)
downloadmeson-219dec39c09789f2b296e5af00305fe05fa3362b.zip
meson-219dec39c09789f2b296e5af00305fe05fa3362b.tar.gz
meson-219dec39c09789f2b296e5af00305fe05fa3362b.tar.bz2
Fix yielding when subproject option type is different
Earlier, we would replace the subproject option with the parent project's option, which is incorrect if the types are not the same. Now we retain the subproject's option and print a warning. It's not advisable to issue an error in this case because subproject option yielding is involuntary for the parent project (option names can match because of coincidences).
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 1cf20f8..707cf9e 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2279,7 +2279,7 @@ external dependencies (including libraries) must go to "dependencies".''')
return self.subprojects[dirname]
def get_option_internal(self, optname):
- undecorated_optname = optname
+ raw_optname = optname
try:
return self.coredata.base_options[optname]
except KeyError:
@@ -2296,9 +2296,20 @@ external dependencies (including libraries) must go to "dependencies".''')
optname = self.subproject + ':' + optname
try:
opt = self.coredata.user_options[optname]
- if opt.yielding and ':' in optname:
- # If option not present in superproject, keep the original.
- opt = self.coredata.user_options.get(undecorated_optname, opt)
+ if opt.yielding and ':' in optname and raw_optname in self.coredata.user_options:
+ popt = self.coredata.user_options[raw_optname]
+ if type(opt) is type(popt):
+ opt = popt
+ else:
+ # Get class name, then option type as a string
+ opt_type = opt.__class__.__name__[4:][:-6].lower()
+ popt_type = popt.__class__.__name__[4:][:-6].lower()
+ # This is not a hard error to avoid dependency hell, the workaround
+ # when this happens is to simply set the subproject's option directly.
+ mlog.warning('Option {0!r} of type {1!r} in subproject {2!r} cannot yield '
+ 'to parent option of type {3!r}, ignoring parent value. '
+ 'Use -D{2}:{0}=value to set the value for this option manually'
+ '.'.format(raw_optname, opt_type, self.subproject, popt_type))
return opt
except KeyError:
pass