aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2019-05-12 12:38:11 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2019-05-15 14:21:47 +0300
commit4030e7cb7ad54dd2df0686f41459fc6293c8284f (patch)
treee7366f78785419ad7d301fb68bc4b508fba9079e /mesonbuild/compilers
parent7b8ef78bc0002d0327626c6218b793f87c2a5eb8 (diff)
downloadmeson-4030e7cb7ad54dd2df0686f41459fc6293c8284f.zip
meson-4030e7cb7ad54dd2df0686f41459fc6293c8284f.tar.gz
meson-4030e7cb7ad54dd2df0686f41459fc6293c8284f.tar.bz2
UserOption no longer has a name field.
This avoids the duplication where the option is stored in a dict at its name, and also contains its own name. In general, the maxim in programming is things shouldn't know their own name, so removed the name field just leaving the option's position in the dictionary as its name.
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r--mesonbuild/compilers/c.py19
-rw-r--r--mesonbuild/compilers/compilers.py33
-rw-r--r--mesonbuild/compilers/cpp.py44
3 files changed, 39 insertions, 57 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 0cfcbc3..5d78ba6 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -96,7 +96,7 @@ class ClangCCompiler(ClangCompiler, CCompiler):
if version_compare(self.version, v):
c_stds += ['c17']
g_stds += ['gnu17']
- opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
+ opts.update({'c_std': coredata.UserComboOption('C language standard to use',
['none'] + c_stds + g_stds,
'none')})
return opts
@@ -130,7 +130,7 @@ class ArmclangCCompiler(ArmclangCompiler, CCompiler):
def get_options(self):
opts = CCompiler.get_options(self)
- opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
+ opts.update({'c_std': coredata.UserComboOption('C language standard to use',
['none', 'c90', 'c99', 'c11',
'gnu90', 'gnu99', 'gnu11'],
'none')})
@@ -165,12 +165,12 @@ class GnuCCompiler(GnuCompiler, CCompiler):
if version_compare(self.version, v):
c_stds += ['c17', 'c18']
g_stds += ['gnu17', 'gnu18']
- opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
+ opts.update({'c_std': coredata.UserComboOption('C language standard to use',
['none'] + c_stds + g_stds,
'none')})
if self.compiler_type.is_windows_compiler:
opts.update({
- 'c_winlibs': coredata.UserArrayOption('c_winlibs', 'Standard Win libraries to link against',
+ 'c_winlibs': coredata.UserArrayOption('Standard Win libraries to link against',
gnu_winlibs), })
return opts
@@ -204,7 +204,7 @@ class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler):
# It does support some various ISO standards and c/gnu 90, 9x, 1x in addition to those which GNU CC supports.
def get_options(self):
opts = CCompiler.get_options(self)
- opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
+ opts.update({'c_std': coredata.UserComboOption('C language standard to use',
['none', 'c89', 'c90', 'c9x', 'c99', 'c1x', 'c11',
'gnu89', 'gnu90', 'gnu9x', 'gnu99', 'gnu1x', 'gnu11',
'iso9899:2011', 'iso9899:1990', 'iso9899:199409', 'iso9899:1999'],
@@ -239,7 +239,7 @@ class IntelCCompiler(IntelGnuLikeCompiler, CCompiler):
g_stds = ['gnu89', 'gnu99']
if version_compare(self.version, '>=16.0.0'):
c_stds += ['c11']
- opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
+ opts.update({'c_std': coredata.UserComboOption('C language standard to use',
['none'] + c_stds + g_stds,
'none')})
return opts
@@ -258,8 +258,7 @@ class VisualStudioLikeCCompilerMixin:
def get_options(self):
opts = super().get_options()
- opts.update({'c_winlibs': coredata.UserArrayOption('c_winlibs',
- 'Windows libs to link against.',
+ opts.update({'c_winlibs': coredata.UserArrayOption('Windows libs to link against.',
msvc_winlibs)})
return opts
@@ -317,7 +316,7 @@ class ArmCCompiler(ArmCompiler, CCompiler):
def get_options(self):
opts = CCompiler.get_options(self)
- opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
+ opts.update({'c_std': coredata.UserComboOption('C language standard to use',
['none', 'c90', 'c99'],
'none')})
return opts
@@ -340,7 +339,7 @@ class CcrxCCompiler(CcrxCompiler, CCompiler):
def get_options(self):
opts = CCompiler.get_options(self)
- opts.update({'c_std': coredata.UserComboOption('c_std', 'C language standard to use',
+ opts.update({'c_std': coredata.UserComboOption('C language standard to use',
['none', 'c89', 'c99'],
'none')})
return opts
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index dacf75d..3ad80fe 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -381,35 +381,30 @@ msvc_debug_args = {False: [],
ccrx_debug_args = {False: [],
True: ['-debug']}
-base_options = {'b_pch': coredata.UserBooleanOption('b_pch', 'Use precompiled headers', True),
- 'b_lto': coredata.UserBooleanOption('b_lto', 'Use link time optimization', False),
- 'b_sanitize': coredata.UserComboOption('b_sanitize',
- 'Code sanitizer to use',
+base_options = {'b_pch': coredata.UserBooleanOption('Use precompiled headers', True),
+ 'b_lto': coredata.UserBooleanOption('Use link time optimization', False),
+ 'b_sanitize': coredata.UserComboOption('Code sanitizer to use',
['none', 'address', 'thread', 'undefined', 'memory', 'address,undefined'],
'none'),
- 'b_lundef': coredata.UserBooleanOption('b_lundef', 'Use -Wl,--no-undefined when linking', True),
- 'b_asneeded': coredata.UserBooleanOption('b_asneeded', 'Use -Wl,--as-needed when linking', True),
- 'b_pgo': coredata.UserComboOption('b_pgo', 'Use profile guided optimization',
+ 'b_lundef': coredata.UserBooleanOption('Use -Wl,--no-undefined when linking', True),
+ 'b_asneeded': coredata.UserBooleanOption('Use -Wl,--as-needed when linking', True),
+ 'b_pgo': coredata.UserComboOption('Use profile guided optimization',
['off', 'generate', 'use'],
'off'),
- 'b_coverage': coredata.UserBooleanOption('b_coverage',
- 'Enable coverage tracking.',
+ 'b_coverage': coredata.UserBooleanOption('Enable coverage tracking.',
False),
- 'b_colorout': coredata.UserComboOption('b_colorout', 'Use colored output',
+ 'b_colorout': coredata.UserComboOption('Use colored output',
['auto', 'always', 'never'],
'always'),
- 'b_ndebug': coredata.UserComboOption('b_ndebug', 'Disable asserts',
+ 'b_ndebug': coredata.UserComboOption('Disable asserts',
['true', 'false', 'if-release'], 'false'),
- 'b_staticpic': coredata.UserBooleanOption('b_staticpic',
- 'Build static libraries as position independent',
+ 'b_staticpic': coredata.UserBooleanOption('Build static libraries as position independent',
True),
- 'b_pie': coredata.UserBooleanOption('b_pie',
- 'Build executables as position independent',
+ 'b_pie': coredata.UserBooleanOption('Build executables as position independent',
False),
- 'b_bitcode': coredata.UserBooleanOption('b_bitcode',
- 'Generate and embed bitcode (only macOS and iOS)',
+ 'b_bitcode': coredata.UserBooleanOption('Generate and embed bitcode (only macOS and iOS)',
False),
- 'b_vscrt': coredata.UserComboOption('b_vscrt', 'VS run-time library type to use.',
+ 'b_vscrt': coredata.UserComboOption('VS run-time library type to use.',
['none', 'md', 'mdd', 'mt', 'mtd', 'from_buildtype'],
'from_buildtype'),
}
@@ -1044,11 +1039,9 @@ class Compiler:
description = 'Extra arguments passed to the {}'.format(self.get_display_language())
opts.update({
self.language + '_args': coredata.UserArrayOption(
- self.language + '_args',
description + ' compiler',
[], shlex_split=True, user_input=True, allow_dups=True),
self.language + '_link_args': coredata.UserArrayOption(
- self.language + '_link_args',
description + ' linker',
[], shlex_split=True, user_input=True, allow_dups=True),
})
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 9fae22c..253525a 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -158,11 +158,10 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
def get_options(self):
opts = CPPCompiler.get_options(self)
- opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
- 'C++ exception handling type.',
+ opts.update({'cpp_eh': coredata.UserComboOption('C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default'),
- 'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
+ 'cpp_std': coredata.UserComboOption('C++ language standard to use',
['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z', 'c++2a',
'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a'],
'none')})
@@ -201,7 +200,7 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler):
'C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default'),
- 'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
+ 'cpp_std': coredata.UserComboOption('C++ language standard to use',
['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17',
'gnu++98', 'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17'],
'none')})
@@ -233,20 +232,18 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
def get_options(self):
opts = CPPCompiler.get_options(self)
- opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
- 'C++ exception handling type.',
+ opts.update({'cpp_eh': coredata.UserComboOption('C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default'),
- 'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
+ 'cpp_std': coredata.UserComboOption('C++ language standard to use',
['none', 'c++98', 'c++03', 'c++11', 'c++14', 'c++17', 'c++1z', 'c++2a',
'gnu++03', 'gnu++11', 'gnu++14', 'gnu++17', 'gnu++1z', 'gnu++2a'],
'none'),
- 'cpp_debugstl': coredata.UserBooleanOption('cpp_debugstl',
- 'STL debug mode',
+ 'cpp_debugstl': coredata.UserBooleanOption('STL debug mode',
False)})
if self.compiler_type.is_windows_compiler:
opts.update({
- 'cpp_winlibs': coredata.UserArrayOption('cpp_winlibs', 'Standard Win libraries to link against',
+ 'cpp_winlibs': coredata.UserArrayOption('Standard Win libraries to link against',
gnu_winlibs), })
return opts
@@ -288,16 +285,14 @@ class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler):
# It does not support c++/gnu++ 17 and 1z, but still does support 0x, 1y, and gnu++98.
def get_options(self):
opts = CPPCompiler.get_options(self)
- opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
- 'C++ exception handling type.',
+ opts.update({'cpp_eh': coredata.UserComboOption('C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default'),
- 'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
+ 'cpp_std': coredata.UserComboOption('C++ language standard to use',
['none', 'c++98', 'c++03', 'c++0x', 'c++11', 'c++14', 'c++1y',
'gnu++98', 'gnu++03', 'gnu++0x', 'gnu++11', 'gnu++14', 'gnu++1y'],
'none'),
- 'cpp_debugstl': coredata.UserBooleanOption('cpp_debugstl',
- 'STL debug mode',
+ 'cpp_debugstl': coredata.UserBooleanOption('STL debug mode',
False)})
return opts
@@ -338,15 +333,13 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler):
c_stds += ['c++17']
if version_compare(self.version, '>=17.0.0'):
g_stds += ['gnu++14']
- opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
- 'C++ exception handling type.',
+ opts.update({'cpp_eh': coredata.UserComboOption('C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default'),
- 'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
+ 'cpp_std': coredata.UserComboOption('C++ language standard to use',
['none'] + c_stds + g_stds,
'none'),
- 'cpp_debugstl': coredata.UserBooleanOption('cpp_debugstl',
- 'STL debug mode',
+ 'cpp_debugstl': coredata.UserBooleanOption('STL debug mode',
False)})
return opts
@@ -387,16 +380,13 @@ class VisualStudioLikeCPPCompilerMixin:
return options['cpp_winlibs'].value[:]
def _get_options_impl(self, opts, cpp_stds: typing.List[str]):
- opts.update({'cpp_eh': coredata.UserComboOption('cpp_eh',
- 'C++ exception handling type.',
+ opts.update({'cpp_eh': coredata.UserComboOption('C++ exception handling type.',
['none', 'default', 'a', 's', 'sc'],
'default'),
- 'cpp_std': coredata.UserComboOption('cpp_std',
- 'C++ language standard to use',
+ 'cpp_std': coredata.UserComboOption('C++ language standard to use',
cpp_stds,
'none'),
- 'cpp_winlibs': coredata.UserArrayOption('cpp_winlibs',
- 'Windows libs to link against.',
+ 'cpp_winlibs': coredata.UserArrayOption('Windows libs to link against.',
msvc_winlibs)})
return opts
@@ -513,7 +503,7 @@ class ArmCPPCompiler(ArmCompiler, CPPCompiler):
def get_options(self):
opts = CPPCompiler.get_options(self)
- opts.update({'cpp_std': coredata.UserComboOption('cpp_std', 'C++ language standard to use',
+ opts.update({'cpp_std': coredata.UserComboOption('C++ language standard to use',
['none', 'c++03', 'c++11'],
'none')})
return opts