coredata: move MutableKeyedOptionDict to options
This commit is contained in:
parent
00864ca481
commit
390ea4624c
|
@ -37,7 +37,7 @@ from .compilers import (
|
||||||
)
|
)
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ..coredata import MutableKeyedOptionDictType
|
from ..options import MutableKeyedOptionDictType
|
||||||
from ..dependencies import Dependency
|
from ..dependencies import Dependency
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
|
|
|
@ -26,7 +26,7 @@ from ..arglist import CompilerArgs
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from .. import coredata
|
from .. import coredata
|
||||||
from ..build import BuildTarget, DFeatures
|
from ..build import BuildTarget, DFeatures
|
||||||
from ..coredata import MutableKeyedOptionDictType
|
from ..options import MutableKeyedOptionDictType
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
from ..linkers import RSPFileSyntax
|
from ..linkers import RSPFileSyntax
|
||||||
|
|
|
@ -34,7 +34,7 @@ from .mixins.metrowerks import MetrowerksCompiler
|
||||||
from .mixins.metrowerks import mwccarm_instruction_set_args, mwcceppc_instruction_set_args
|
from .mixins.metrowerks import mwccarm_instruction_set_args, mwcceppc_instruction_set_args
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ..coredata import MutableKeyedOptionDictType
|
from ..options import MutableKeyedOptionDictType
|
||||||
from ..dependencies import Dependency
|
from ..dependencies import Dependency
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Copyright 2012-2017 The Meson development team
|
# Copyright 2012-2017 The Meson development team
|
||||||
# Copyright © 2023-2024 Intel Corporation
|
# Copyright © 2023-2025 Intel Corporation
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ from .compilers import Compiler, CompileCheckMode
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ..build import BuildTarget
|
from ..build import BuildTarget
|
||||||
from ..coredata import MutableKeyedOptionDictType
|
from ..options import MutableKeyedOptionDictType
|
||||||
from ..dependencies import Dependency
|
from ..dependencies import Dependency
|
||||||
from ..environment import Environment # noqa: F401
|
from ..environment import Environment # noqa: F401
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Copyright © 2021-2024 Intel Corporation
|
# Copyright © 2021-2025 Intel Corporation
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
"""Abstraction for Cython language compilers."""
|
"""Abstraction for Cython language compilers."""
|
||||||
|
@ -11,7 +11,7 @@ from ..mesonlib import EnvironmentException, version_compare
|
||||||
from .compilers import Compiler
|
from .compilers import Compiler
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ..coredata import MutableKeyedOptionDictType
|
from ..options import MutableKeyedOptionDictType
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
from ..build import BuildTarget
|
from ..build import BuildTarget
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ from mesonbuild.mesonlib import (
|
||||||
)
|
)
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ..coredata import MutableKeyedOptionDictType
|
from ..options import MutableKeyedOptionDictType
|
||||||
from ..dependencies import Dependency
|
from ..dependencies import Dependency
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
|
|
|
@ -18,7 +18,7 @@ from ..compilers import CompileCheckMode
|
||||||
from .gnu import GnuLikeCompiler
|
from .gnu import GnuLikeCompiler
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ...coredata import MutableKeyedOptionDictType
|
from ...options import MutableKeyedOptionDictType
|
||||||
from ...environment import Environment
|
from ...environment import Environment
|
||||||
from ...dependencies import Dependency # noqa: F401
|
from ...dependencies import Dependency # noqa: F401
|
||||||
from ..compilers import Compiler
|
from ..compilers import Compiler
|
||||||
|
|
|
@ -15,7 +15,6 @@ from ...mesonlib import LibType
|
||||||
from mesonbuild.compilers.compilers import CompileCheckMode
|
from mesonbuild.compilers.compilers import CompileCheckMode
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ... import coredata
|
|
||||||
from ...environment import Environment
|
from ...environment import Environment
|
||||||
from ...compilers.compilers import Compiler
|
from ...compilers.compilers import Compiler
|
||||||
from ...dependencies import Dependency
|
from ...dependencies import Dependency
|
||||||
|
@ -57,7 +56,7 @@ class EmscriptenMixin(Compiler):
|
||||||
args.append(f'-sPTHREAD_POOL_SIZE={count}')
|
args.append(f'-sPTHREAD_POOL_SIZE={count}')
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def get_options(self) -> coredata.MutableKeyedOptionDictType:
|
def get_options(self) -> options.MutableKeyedOptionDictType:
|
||||||
opts = super().get_options()
|
opts = super().get_options()
|
||||||
|
|
||||||
key = OptionKey(f'{self.language}_thread_count', machine=self.for_machine)
|
key = OptionKey(f'{self.language}_thread_count', machine=self.for_machine)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Copyright 2019-2022 The meson development team
|
# Copyright 2019-2022 The meson development team
|
||||||
# Copyright © 2023 Intel Corporation
|
# Copyright © 2023-2025 Intel Corporation
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from mesonbuild.compilers.compilers import CompileCheckMode
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ..._typing import ImmutableListProtocol
|
from ..._typing import ImmutableListProtocol
|
||||||
from ...coredata import MutableKeyedOptionDictType
|
from ...options import MutableKeyedOptionDictType
|
||||||
from ...environment import Environment
|
from ...environment import Environment
|
||||||
from ..compilers import Compiler
|
from ..compilers import Compiler
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -15,12 +15,12 @@ from .mixins.clike import CLikeCompiler
|
||||||
from .mixins.gnu import GnuCompiler, GnuCStds, gnu_common_warning_args, gnu_objc_warning_args
|
from .mixins.gnu import GnuCompiler, GnuCStds, gnu_common_warning_args, gnu_objc_warning_args
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from .. import coredata
|
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
from ..linkers.linkers import DynamicLinker
|
from ..linkers.linkers import DynamicLinker
|
||||||
from ..mesonlib import MachineChoice
|
from ..mesonlib import MachineChoice
|
||||||
from ..build import BuildTarget
|
from ..build import BuildTarget
|
||||||
|
from ..options import MutableKeyedOptionDictType
|
||||||
|
|
||||||
|
|
||||||
class ObjCCompiler(CLikeCompiler, Compiler):
|
class ObjCCompiler(CLikeCompiler, Compiler):
|
||||||
|
@ -36,7 +36,7 @@ class ObjCCompiler(CLikeCompiler, Compiler):
|
||||||
linker=linker)
|
linker=linker)
|
||||||
CLikeCompiler.__init__(self)
|
CLikeCompiler.__init__(self)
|
||||||
|
|
||||||
def get_options(self) -> coredata.MutableKeyedOptionDictType:
|
def get_options(self) -> MutableKeyedOptionDictType:
|
||||||
opts = super().get_options()
|
opts = super().get_options()
|
||||||
key = self.form_compileropt_key('std')
|
key = self.form_compileropt_key('std')
|
||||||
opts.update({
|
opts.update({
|
||||||
|
|
|
@ -15,12 +15,12 @@ from .mixins.clang import ClangCompiler, ClangCPPStds
|
||||||
from .mixins.clike import CLikeCompiler
|
from .mixins.clike import CLikeCompiler
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from .. import coredata
|
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
from ..linkers.linkers import DynamicLinker
|
from ..linkers.linkers import DynamicLinker
|
||||||
from ..mesonlib import MachineChoice
|
from ..mesonlib import MachineChoice
|
||||||
from ..build import BuildTarget
|
from ..build import BuildTarget
|
||||||
|
from ..options import MutableKeyedOptionDictType
|
||||||
|
|
||||||
|
|
||||||
class ObjCPPCompiler(CLikeCompiler, Compiler):
|
class ObjCPPCompiler(CLikeCompiler, Compiler):
|
||||||
|
@ -54,7 +54,7 @@ class ObjCPPCompiler(CLikeCompiler, Compiler):
|
||||||
code = '#import<stdio.h>\nclass MyClass;int main(void) { return 0; }\n'
|
code = '#import<stdio.h>\nclass MyClass;int main(void) { return 0; }\n'
|
||||||
return self._sanity_check_impl(work_dir, environment, 'sanitycheckobjcpp.mm', code)
|
return self._sanity_check_impl(work_dir, environment, 'sanitycheckobjcpp.mm', code)
|
||||||
|
|
||||||
def get_options(self) -> coredata.MutableKeyedOptionDictType:
|
def get_options(self) -> MutableKeyedOptionDictType:
|
||||||
opts = super().get_options()
|
opts = super().get_options()
|
||||||
key = self.form_compileropt_key('std')
|
key = self.form_compileropt_key('std')
|
||||||
opts.update({
|
opts.update({
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# Copyright 2012-2022 The Meson development team
|
# Copyright 2012-2022 The Meson development team
|
||||||
# Copyright © 2023-2024 Intel Corporation
|
# Copyright © 2023-2025 Intel Corporation
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ from ..options import OptionKey
|
||||||
from .compilers import Compiler, CompileCheckMode, clike_debug_args
|
from .compilers import Compiler, CompileCheckMode, clike_debug_args
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from ..coredata import MutableKeyedOptionDictType
|
from ..options import MutableKeyedOptionDictType
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
from ..environment import Environment # noqa: F401
|
from ..environment import Environment # noqa: F401
|
||||||
from ..linkers.linkers import DynamicLinker
|
from ..linkers.linkers import DynamicLinker
|
||||||
|
|
|
@ -14,7 +14,7 @@ from .compilers import Compiler, clike_debug_args
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from .. import build
|
from .. import build
|
||||||
from ..coredata import MutableKeyedOptionDictType
|
from ..options import MutableKeyedOptionDictType
|
||||||
from ..dependencies import Dependency
|
from ..dependencies import Dependency
|
||||||
from ..envconfig import MachineInfo
|
from ..envconfig import MachineInfo
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
|
|
|
@ -43,7 +43,7 @@ if T.TYPE_CHECKING:
|
||||||
from .mesonlib import FileOrString
|
from .mesonlib import FileOrString
|
||||||
from .cmake.traceparser import CMakeCacheEntry
|
from .cmake.traceparser import CMakeCacheEntry
|
||||||
from .interpreterbase import SubProject
|
from .interpreterbase import SubProject
|
||||||
from .options import ElementaryOptionValues
|
from .options import ElementaryOptionValues, MutableKeyedOptionDictType
|
||||||
from .build import BuildTarget
|
from .build import BuildTarget
|
||||||
|
|
||||||
class SharedCMDOptions(Protocol):
|
class SharedCMDOptions(Protocol):
|
||||||
|
@ -62,7 +62,6 @@ if T.TYPE_CHECKING:
|
||||||
native_file: T.List[str]
|
native_file: T.List[str]
|
||||||
|
|
||||||
OptionDictType = T.Dict[str, options.AnyOptionType]
|
OptionDictType = T.Dict[str, options.AnyOptionType]
|
||||||
MutableKeyedOptionDictType = T.Dict['OptionKey', options.AnyOptionType]
|
|
||||||
CompilerCheckCacheKey = T.Tuple[T.Tuple[str, ...], str, FileOrString, T.Tuple[str, ...], CompileCheckMode]
|
CompilerCheckCacheKey = T.Tuple[T.Tuple[str, ...], str, FileOrString, T.Tuple[str, ...], CompileCheckMode]
|
||||||
# code, args
|
# code, args
|
||||||
RunCheckCacheKey = T.Tuple[str, T.Tuple[str, ...]]
|
RunCheckCacheKey = T.Tuple[str, T.Tuple[str, ...]]
|
||||||
|
|
|
@ -190,9 +190,10 @@ class Conf:
|
||||||
items = [l[i] if l[i] else ' ' * four_column[i] for i in range(4)]
|
items = [l[i] if l[i] else ' ' * four_column[i] for i in range(4)]
|
||||||
mlog.log(*items)
|
mlog.log(*items)
|
||||||
|
|
||||||
def split_options_per_subproject(self, options: T.Union[coredata.MutableKeyedOptionDictType, options.OptionStore]) -> T.Dict[str, 'coredata.MutableKeyedOptionDictType']:
|
def split_options_per_subproject(self, opts: T.Union[options.MutableKeyedOptionDictType, options.OptionStore]
|
||||||
result: T.Dict[str, 'coredata.MutableKeyedOptionDictType'] = {}
|
) -> T.Dict[str, options.MutableKeyedOptionDictType]:
|
||||||
for k, o in options.items():
|
result: T.Dict[str, options.MutableKeyedOptionDictType] = {}
|
||||||
|
for k, o in opts.items():
|
||||||
if k.subproject:
|
if k.subproject:
|
||||||
self.all_subprojects.add(k.subproject)
|
self.all_subprojects.add(k.subproject)
|
||||||
result.setdefault(k.subproject, {})[k] = o
|
result.setdefault(k.subproject, {})[k] = o
|
||||||
|
@ -228,7 +229,7 @@ class Conf:
|
||||||
self._add_line(mlog.normal_yellow(section + ':'), '', '', '')
|
self._add_line(mlog.normal_yellow(section + ':'), '', '', '')
|
||||||
self.print_margin = 2
|
self.print_margin = 2
|
||||||
|
|
||||||
def print_options(self, title: str, opts: T.Union[coredata.MutableKeyedOptionDictType, options.OptionStore]) -> None:
|
def print_options(self, title: str, opts: T.Union[options.MutableKeyedOptionDictType, options.OptionStore]) -> None:
|
||||||
if not opts:
|
if not opts:
|
||||||
return
|
return
|
||||||
if title:
|
if title:
|
||||||
|
@ -264,10 +265,10 @@ class Conf:
|
||||||
test_option_names = {OptionKey('errorlogs'),
|
test_option_names = {OptionKey('errorlogs'),
|
||||||
OptionKey('stdsplit')}
|
OptionKey('stdsplit')}
|
||||||
|
|
||||||
dir_options: 'coredata.MutableKeyedOptionDictType' = {}
|
dir_options: options.MutableKeyedOptionDictType = {}
|
||||||
test_options: 'coredata.MutableKeyedOptionDictType' = {}
|
test_options: options.MutableKeyedOptionDictType = {}
|
||||||
core_options: 'coredata.MutableKeyedOptionDictType' = {}
|
core_options: options.MutableKeyedOptionDictType = {}
|
||||||
module_options: T.Dict[str, 'coredata.MutableKeyedOptionDictType'] = collections.defaultdict(dict)
|
module_options: T.Dict[str, options.MutableKeyedOptionDictType] = collections.defaultdict(dict)
|
||||||
for k, v in self.coredata.optstore.options.items():
|
for k, v in self.coredata.optstore.options.items():
|
||||||
if k in dir_option_names:
|
if k in dir_option_names:
|
||||||
dir_options[k] = v
|
dir_options[k] = v
|
||||||
|
|
|
@ -290,9 +290,9 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s
|
||||||
test_option_names = {OptionKey('errorlogs'),
|
test_option_names = {OptionKey('errorlogs'),
|
||||||
OptionKey('stdsplit')}
|
OptionKey('stdsplit')}
|
||||||
|
|
||||||
dir_options: 'cdata.MutableKeyedOptionDictType' = {}
|
dir_options: options.MutableKeyedOptionDictType = {}
|
||||||
test_options: 'cdata.MutableKeyedOptionDictType' = {}
|
test_options: options.MutableKeyedOptionDictType = {}
|
||||||
core_options: 'cdata.MutableKeyedOptionDictType' = {}
|
core_options: options.MutableKeyedOptionDictType = {}
|
||||||
for k, v in coredata.optstore.items():
|
for k, v in coredata.optstore.items():
|
||||||
if k in dir_option_names:
|
if k in dir_option_names:
|
||||||
dir_options[k] = v
|
dir_options[k] = v
|
||||||
|
@ -304,7 +304,7 @@ def list_buildoptions(coredata: cdata.CoreData, subprojects: T.Optional[T.List[s
|
||||||
for s in subprojects:
|
for s in subprojects:
|
||||||
core_options[k.evolve(subproject=s)] = v
|
core_options[k.evolve(subproject=s)] = v
|
||||||
|
|
||||||
def add_keys(opts: T.Union[cdata.MutableKeyedOptionDictType, options.OptionStore], section: str) -> None:
|
def add_keys(opts: T.Union[options.MutableKeyedOptionDictType, options.OptionStore], section: str) -> None:
|
||||||
for key, opt in sorted(opts.items()):
|
for key, opt in sorted(opts.items()):
|
||||||
optdict = {'name': str(key), 'value': opt.value, 'section': section,
|
optdict = {'name': str(key), 'value': opt.value, 'section': section,
|
||||||
'machine': key.machine.get_lower_case_name() if coredata.optstore.is_per_machine_option(key) else 'any'}
|
'machine': key.machine.get_lower_case_name() if coredata.optstore.is_per_machine_option(key) else 'any'}
|
||||||
|
|
|
@ -15,7 +15,6 @@ from .interpreterbase import FeatureNew, FeatureDeprecated, typed_pos_args, type
|
||||||
from .interpreter.type_checking import NoneType, in_set_validator
|
from .interpreter.type_checking import NoneType, in_set_validator
|
||||||
|
|
||||||
if T.TYPE_CHECKING:
|
if T.TYPE_CHECKING:
|
||||||
from . import coredata
|
|
||||||
from .interpreterbase import TYPE_var, TYPE_kwargs
|
from .interpreterbase import TYPE_var, TYPE_kwargs
|
||||||
from .interpreterbase import SubProject
|
from .interpreterbase import SubProject
|
||||||
from typing_extensions import TypedDict, Literal
|
from typing_extensions import TypedDict, Literal
|
||||||
|
@ -67,7 +66,7 @@ optname_regex = re.compile('[^a-zA-Z0-9_-]')
|
||||||
|
|
||||||
class OptionInterpreter:
|
class OptionInterpreter:
|
||||||
def __init__(self, optionstore: 'OptionStore', subproject: 'SubProject') -> None:
|
def __init__(self, optionstore: 'OptionStore', subproject: 'SubProject') -> None:
|
||||||
self.options: 'coredata.MutableKeyedOptionDictType' = {}
|
self.options: options.MutableKeyedOptionDictType = {}
|
||||||
self.subproject = subproject
|
self.subproject = subproject
|
||||||
self.option_types: T.Dict[str, T.Callable[..., options.AnyOptionType]] = {
|
self.option_types: T.Dict[str, T.Callable[..., options.AnyOptionType]] = {
|
||||||
'string': self.string_parser,
|
'string': self.string_parser,
|
||||||
|
|
|
@ -41,6 +41,7 @@ if T.TYPE_CHECKING:
|
||||||
'UserIntegerOption', 'UserStdOption', 'UserStringArrayOption',
|
'UserIntegerOption', 'UserStdOption', 'UserStringArrayOption',
|
||||||
'UserStringOption', 'UserUmaskOption']
|
'UserStringOption', 'UserUmaskOption']
|
||||||
ElementaryOptionValues: TypeAlias = T.Union[str, int, bool, T.List[str]]
|
ElementaryOptionValues: TypeAlias = T.Union[str, int, bool, T.List[str]]
|
||||||
|
MutableKeyedOptionDictType: TypeAlias = T.Dict['OptionKey', AnyOptionType]
|
||||||
|
|
||||||
_OptionKeyTuple: TypeAlias = T.Tuple[T.Optional[str], MachineChoice, str]
|
_OptionKeyTuple: TypeAlias = T.Tuple[T.Optional[str], MachineChoice, str]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue