summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-08-29 09:26:59 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2025-02-05 17:45:38 +0200
commitcd5bc11bb34054131e90a79d764383d55fefa330 (patch)
treebe518b7c50bd52230431e77e4f2ed7722a3b654b /mesonbuild/compilers/compilers.py
parentb32e4e87b1c88eb235389c4f60f540154d720970 (diff)
downloadmeson-cd5bc11bb34054131e90a79d764383d55fefa330.tar.gz
options: Get rid of the invalid _U type, and use UserOption[_T]
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 424bcc19b..011dacfb7 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2012-2022 The Meson development team
-# Copyright © 2023-2024 Intel Corporation
+# Copyright © 2023-2025 Intel Corporation
from __future__ import annotations
@@ -20,9 +20,7 @@ from ..mesonlib import (
EnvironmentException, MesonException,
Popen_safe_logged, LibType, TemporaryDirectoryWinProof,
)
-
from ..options import OptionKey
-
from ..arglist import CompilerArgs
if T.TYPE_CHECKING:
@@ -37,9 +35,10 @@ if T.TYPE_CHECKING:
from ..dependencies import Dependency
CompilerType = T.TypeVar('CompilerType', bound='Compiler')
- _T = T.TypeVar('_T')
UserOptionType = T.TypeVar('UserOptionType', bound=options.UserOption)
+_T = T.TypeVar('_T')
+
"""This file contains the data files of all compilers Meson knows
about. To support a new compiler, add its information below.
Also add corresponding autodetection code in detect.py."""
@@ -216,19 +215,21 @@ clike_debug_args: T.Dict[bool, T.List[str]] = {
MSCRT_VALS = ['none', 'md', 'mdd', 'mt', 'mtd']
+
@dataclass
-class BaseOption(T.Generic[options._T, options._U]):
- opt_type: T.Type[options._U]
+class BaseOption(T.Generic[_T]):
+ opt_type: T.Type[options.UserOption[_T]]
description: str
default: T.Any = None
choices: T.Any = None
- def init_option(self, name: OptionKey) -> options._U:
+ def init_option(self, name: OptionKey) -> options.UserOption[_T]:
keywords = {'value': self.default}
if self.choices:
keywords['choices'] = self.choices
return self.opt_type(name.name, self.description, **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),