Skip to content

Refactor and fix typing in coredata #11492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mesonbuild/compilers/c.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
OptionKey('std', machine=self.for_machine, lang=self.language): coredata.UserComboOption(
'C language standard to use',
['none'],
'none',
choices=['none'],
)
})
return opts
Expand Down
30 changes: 16 additions & 14 deletions mesonbuild/compilers/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,31 +283,31 @@ class CompileCheckMode(enum.Enum):
base_options: 'KeyedOptionDictType' = {
OptionKey('b_pch'): coredata.UserBooleanOption('Use precompiled headers', True),
OptionKey('b_lto'): coredata.UserBooleanOption('Use link time optimization', False),
OptionKey('b_lto_threads'): coredata.UserIntegerOption('Use multiple threads for Link Time Optimization', (None, None, 0)),
OptionKey('b_lto_threads'): coredata.UserIntegerOption('Use multiple threads for Link Time Optimization', 0),
OptionKey('b_lto_mode'): coredata.UserComboOption('Select between different LTO modes.',
['default', 'thin'],
'default'),
'default',
choices=['default', 'thin']),
OptionKey('b_thinlto_cache'): coredata.UserBooleanOption('Use LLVM ThinLTO caching for faster incremental builds', False),
OptionKey('b_thinlto_cache_dir'): coredata.UserStringOption('Directory to store ThinLTO cache objects', ''),
OptionKey('b_sanitize'): coredata.UserComboOption('Code sanitizer to use',
['none', 'address', 'thread', 'undefined', 'memory', 'leak', 'address,undefined'],
'none'),
'none',
choices=['none', 'address', 'thread', 'undefined', 'memory', 'leak', 'address,undefined']),
OptionKey('b_lundef'): coredata.UserBooleanOption('Use -Wl,--no-undefined when linking', True),
OptionKey('b_asneeded'): coredata.UserBooleanOption('Use -Wl,--as-needed when linking', True),
OptionKey('b_pgo'): coredata.UserComboOption('Use profile guided optimization',
['off', 'generate', 'use'],
'off'),
'off',
choices=['off', 'generate', 'use']),
OptionKey('b_coverage'): coredata.UserBooleanOption('Enable coverage tracking.', False),
OptionKey('b_colorout'): coredata.UserComboOption('Use colored output',
['auto', 'always', 'never'],
'always'),
OptionKey('b_ndebug'): coredata.UserComboOption('Disable asserts', ['true', 'false', 'if-release'], 'false'),
'always',
choices=['auto', 'always', 'never']),
OptionKey('b_ndebug'): coredata.UserComboOption('Disable asserts', 'false', choices=['true', 'false', 'if-release']),
OptionKey('b_staticpic'): coredata.UserBooleanOption('Build static libraries as position independent', True),
OptionKey('b_pie'): coredata.UserBooleanOption('Build executables as position independent', False),
OptionKey('b_bitcode'): coredata.UserBooleanOption('Generate and embed bitcode (only macOS/iOS/tvOS)', False),
OptionKey('b_vscrt'): coredata.UserComboOption('VS run-time library type to use.',
['none', 'md', 'mdd', 'mt', 'mtd', 'from_buildtype', 'static_from_buildtype'],
'from_buildtype'),
'from_buildtype',
choices=['none', 'md', 'mdd', 'mt', 'mtd', 'from_buildtype', 'static_from_buildtype']),
}

def option_enabled(boptions: T.Set[OptionKey], options: 'KeyedOptionDictType',
Expand Down Expand Up @@ -1364,11 +1364,13 @@ def get_global_options(lang: str,

cargs = coredata.UserArrayOption(
description + ' compiler',
comp_options, split_args=True, user_input=True, allow_dups=True)
[], split_args=True, user_input=True, allow_dups=True)
cargs.set_value(comp_options)

largs = coredata.UserArrayOption(
description + ' linker',
link_options, split_args=True, user_input=True, allow_dups=True)
[], split_args=True, user_input=True, allow_dups=True)
largs.set_value(link_options)

if comp.INVOKES_LINKER and comp_key == envkey:
# If the compiler acts as a linker driver, and we're using the
Expand Down
14 changes: 7 additions & 7 deletions mesonbuild/compilers/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
key: coredata.UserComboOption(
'C++ language standard to use',
['none'],
'none',
choices=['none'],
),
})
return opts
Expand Down Expand Up @@ -205,8 +205,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
key.evolve('eh'): coredata.UserComboOption(
'C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default',
choices=['none', 'default', 'a', 's', 'sc'],
),
key.evolve('rtti'): coredata.UserBooleanOption('Enable RTTI', True),
})
Expand Down Expand Up @@ -328,8 +328,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
key.evolve('eh'): coredata.UserComboOption(
'C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default',
choices=['none', 'default', 'a', 's', 'sc'],
),
})
opts[key].choices = [
Expand Down Expand Up @@ -377,8 +377,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
key.evolve('eh'): coredata.UserComboOption(
'C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default',
choices=['none', 'default', 'a', 's', 'sc'],
),
key.evolve('rtti'): coredata.UserBooleanOption('Enable RTTI', True),
key.evolve('debugstl'): coredata.UserBooleanOption(
Expand Down Expand Up @@ -501,8 +501,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
key.evolve('eh'): coredata.UserComboOption(
'C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default',
choices=['none', 'default', 'a', 's', 'sc'],
),
key.evolve('debugstl'): coredata.UserBooleanOption(
'STL debug mode',
Expand Down Expand Up @@ -577,8 +577,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
key.evolve('eh'): coredata.UserComboOption(
'C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default',
choices=['none', 'default', 'a', 's', 'sc'],
),
key.evolve('rtti'): coredata.UserBooleanOption('Enable RTTI', True),
key.evolve('debugstl'): coredata.UserBooleanOption('STL debug mode', False),
Expand Down Expand Up @@ -641,8 +641,8 @@ def _get_options_impl(self, opts: 'MutableKeyedOptionDictType', cpp_stds: T.List
opts.update({
key.evolve('eh'): coredata.UserComboOption(
'C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default',
choices=['none', 'default', 'a', 's', 'sc'],
),
key.evolve('rtti'): coredata.UserBooleanOption('Enable RTTI', True),
key.evolve('winlibs'): coredata.UserArrayOption(
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/compilers/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def get_options(self) -> 'MutableKeyedOptionDictType':

opts.update({
std_key: coredata.UserComboOption('C++ language standard to use with CUDA',
cpp_stds, 'none'),
'none', choices=cpp_stds),
ccbindir_key: coredata.UserStringOption('CUDA non-default toolchain directory to use (-ccbin)',
''),
})
Expand Down
4 changes: 2 additions & 2 deletions mesonbuild/compilers/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
OptionKey('version', machine=self.for_machine, lang=self.language): coredata.UserComboOption(
'Python version to target',
['2', '3'],
'3',
choices=['2', '3'],
),
OptionKey('language', machine=self.for_machine, lang=self.language): coredata.UserComboOption(
'Output C or C++ files',
['c', 'cpp'],
'c',
choices=['c', 'cpp'],
)
})
return opts
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/compilers/fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
opts.update({
key: coredata.UserComboOption(
'Fortran language standard to use',
['none'],
'none',
choices=['none'],
),
})
return opts
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/compilers/mixins/emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def get_options(self) -> 'coredata.MutableKeyedOptionDictType':
opts.update({
key: coredata.UserIntegerOption(
'Number of threads to use in web assembly, set to 0 to disable',
(0, None, 4), # Default was picked at random
4, # picked at random
min_value=0,
),
})

Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/compilers/objc.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def get_options(self) -> 'coredata.MutableKeyedOptionDictType':
opts.update({
OptionKey('std', machine=self.for_machine, lang='c'): coredata.UserComboOption(
'C language standard to use',
['none', 'c89', 'c99', 'c11', 'c17', 'gnu89', 'gnu99', 'gnu11', 'gnu17'],
'none',
choices=['none', 'c89', 'c99', 'c11', 'c17', 'gnu89', 'gnu99', 'gnu11', 'gnu17'],
)
})
return opts
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/compilers/objcpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def get_options(self) -> 'coredata.MutableKeyedOptionDictType':
opts.update({
OptionKey('std', machine=self.for_machine, lang='cpp'): coredata.UserComboOption(
'C++ language standard to use',
['none', 'c++98', 'c++11', 'c++14', 'c++17', 'gnu++98', 'gnu++11', 'gnu++14', 'gnu++17'],
'none',
choices=['none', 'c++98', 'c++11', 'c++14', 'c++17', 'gnu++98', 'gnu++11', 'gnu++14', 'gnu++17'],
)
})
return opts
Expand Down
2 changes: 1 addition & 1 deletion mesonbuild/compilers/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def get_options(self) -> 'MutableKeyedOptionDictType':
return {
key: coredata.UserComboOption(
'Rust edition to use',
['none', '2015', '2018', '2021'],
'none',
choices=['none', '2015', '2018', '2021'],
),
}

Expand Down
Loading