summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-08-29 09:47:39 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2025-02-05 17:45:38 +0200
commit0e11b90d6f2f9c3e18cb8ff84b1622640666e826 (patch)
tree56772aa8d0b622d6456eb5c58441063d6a6f4c36 /mesonbuild/compilers/compilers.py
parentfe9f8de1ab52af0a6f4c3a1ce054ee3e2eb7a74c (diff)
downloadmeson-0e11b90d6f2f9c3e18cb8ff84b1622640666e826.tar.gz
options: use dataclasses for UserOption
This reduces code, makes this clearer, and will be a nice step toward the goal of getting everything typesafe. For `UserIntegerOption` this makes a fairly nice, but substantial change in that the old method used a tuple of `(min, value, max)` to pass to the initializer, while all other types just passed `value`. The new `UserIntegerOption` does the same, with keyword arguments for the min and max values.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 12bcd1e4c..1432afb85 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -224,16 +224,16 @@ class BaseOption(T.Generic[_T]):
choices: T.Any = None
def init_option(self, name: OptionKey) -> options.UserOption[_T]:
- keywords = {'value': self.default}
+ keywords = {}
if self.choices:
keywords['choices'] = self.choices
- return self.opt_type(name.name, self.description, **keywords)
+ return self.opt_type(name.name, self.description, self.default, **keywords)
BASE_OPTIONS: T.Mapping[OptionKey, BaseOption] = {
OptionKey('b_pch'): BaseOption(options.UserBooleanOption, 'Use precompiled headers', True),
OptionKey('b_lto'): BaseOption(options.UserBooleanOption, 'Use link time optimization', False),
- OptionKey('b_lto_threads'): BaseOption(options.UserIntegerOption, 'Use multiple threads for Link Time Optimization', (None, None, 0)),
+ OptionKey('b_lto_threads'): BaseOption(options.UserIntegerOption, 'Use multiple threads for Link Time Optimization', 0),
OptionKey('b_lto_mode'): BaseOption(options.UserComboOption, 'Select between different LTO modes.', 'default',
choices=['default', 'thin']),
OptionKey('b_thinlto_cache'): BaseOption(options.UserBooleanOption, 'Use LLVM ThinLTO caching for faster incremental builds', False),