diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2020-02-04 21:27:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-04 23:27:59 +0200 |
commit | a3e2aa2d66202c6fec84222aba39437b3c3ca2d2 (patch) | |
tree | 786130af63cd78b8e428cb0caf5b902d299cfd51 | |
parent | 15eb0014acf256f4b3b3ffaf269d681e287f9c92 (diff) | |
download | meson-a3e2aa2d66202c6fec84222aba39437b3c3ca2d2.zip meson-a3e2aa2d66202c6fec84222aba39437b3c3ca2d2.tar.gz meson-a3e2aa2d66202c6fec84222aba39437b3c3ca2d2.tar.bz2 |
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
-rw-r--r-- | mesonbuild/coredata.py | 6 | ||||
-rwxr-xr-x | run_unittests.py | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 44eaa02..cdee20d 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.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) diff --git a/run_unittests.py b/run_unittests.py index cf40955..d0cc68d 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -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: |