Fix prefix dependent option defaults (#6552)

* Extend test_prefix_dependent_defaults unit test to cover default case

Extend test_prefix_dependent_defaults unit test to cover the default
case, when the default prefix is '/usr/local'. (On Windows, the default
prefix is 'c:/')

* Restore adjusting option defaults depending on the default prefix

Restore adjusting option defaults, depending on the default prefix.
Droppped in d778a371
pull/6587/head
Jon Turney 5 years ago committed by GitHub
parent 15eb0014ac
commit a3e2aa2d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      mesonbuild/coredata.py
  2. 8
      run_unittests.py

@ -501,7 +501,7 @@ class CoreData:
# Create builtin options with default values
self.builtins = {}
for key, opt in builtin_options.items():
self.builtins[key] = opt.init_option()
self.builtins[key] = opt.init_option(key, default_prefix())
self.builtins_per_machine = PerMachine({}, {})
for for_machine in iter(MachineChoice):
for key, opt in builtin_options_per_machine.items():
@ -959,9 +959,9 @@ class BuiltinOption(T.Generic[_T, _U]):
self.choices = choices
self.yielding = yielding
def init_option(self) -> _U:
def init_option(self, name: str = 'prefix', prefix: str = '') -> _U:
"""Create an instance of opt_type and return it."""
keywords = {'yielding': self.yielding, 'value': self.default}
keywords = {'yielding': self.yielding, 'value': self.prefixed_default(name, prefix)}
if self.choices:
keywords['choices'] = self.choices
return self.opt_type(self.description, **keywords)

@ -1857,8 +1857,14 @@ class AllPlatformTests(BasePlatformTests):
# N.B. We don't check 'libdir' as it's platform dependent, see
# default_libdir():
}
if mesonbuild.mesonlib.default_prefix() == '/usr/local':
expected[None] = expected['/usr/local']
for prefix in expected:
args = ['--prefix', prefix]
args = []
if prefix:
args += ['--prefix', prefix]
self.init(testdir, extra_args=args, default_args=False)
opts = self.introspect('--buildoptions')
for opt in opts:

Loading…
Cancel
Save