diff options
-rw-r--r-- | mesonbuild/interpreter.py | 19 | ||||
-rw-r--r-- | test cases/common/175 yield/meson.build | 3 | ||||
-rw-r--r-- | test cases/common/175 yield/meson_options.txt | 1 | ||||
-rw-r--r-- | test cases/common/175 yield/subprojects/sub/meson.build | 1 | ||||
-rw-r--r-- | test cases/common/175 yield/subprojects/sub/meson_options.txt | 1 |
5 files changed, 20 insertions, 5 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 diff --git a/test cases/common/175 yield/meson.build b/test cases/common/175 yield/meson.build index ba3e426..9b11569 100644 --- a/test cases/common/175 yield/meson.build +++ b/test cases/common/175 yield/meson.build @@ -3,4 +3,5 @@ project('yield_options', 'c') subproject('sub') assert(get_option('unshared_option') == 'one', 'Unshared option has wrong value in superproject.') -assert(get_option('shared_option') == 'two', 'Unshared option has wrong value in superproject..') +assert(get_option('shared_option') == 'two', 'Shared option has wrong value in superproject..') +assert(get_option('wrongtype_option') == 'three', 'Wrongtype option has wrong value in superproject..') diff --git a/test cases/common/175 yield/meson_options.txt b/test cases/common/175 yield/meson_options.txt index 36bad4b..9f58fbb 100644 --- a/test cases/common/175 yield/meson_options.txt +++ b/test cases/common/175 yield/meson_options.txt @@ -1,2 +1,3 @@ option('unshared_option', type : 'string', value : 'one') option('shared_option', type : 'string', value : 'two') +option('wrongtype_option', type : 'string', value : 'three') diff --git a/test cases/common/175 yield/subprojects/sub/meson.build b/test cases/common/175 yield/subprojects/sub/meson.build index 3a506e0..832c13c 100644 --- a/test cases/common/175 yield/subprojects/sub/meson.build +++ b/test cases/common/175 yield/subprojects/sub/meson.build @@ -2,3 +2,4 @@ project('subbie', 'c') assert(get_option('unshared_option') == 'three', 'Unshared option has wrong value in subproject.') assert(get_option('shared_option') == 'two', 'Shared option has wrong value in subproject.') +assert(get_option('wrongtype_option') == true, 'Wrongtype option has wrong value in subproject.') diff --git a/test cases/common/175 yield/subprojects/sub/meson_options.txt b/test cases/common/175 yield/subprojects/sub/meson_options.txt index a96c307..101122e 100644 --- a/test cases/common/175 yield/subprojects/sub/meson_options.txt +++ b/test cases/common/175 yield/subprojects/sub/meson_options.txt @@ -1,2 +1,3 @@ option('unshared_option', type : 'string', value : 'three', yield : false) option('shared_option', type : 'string', value : 'four', yield : true) +option('wrongtype_option', type : 'boolean', value : true, yield : true) |