diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-03-20 22:04:24 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-03-20 22:04:24 +0200 |
commit | d87eb7d2905eaa9ed7bac60945821c7b039298d8 (patch) | |
tree | 65dd79f54b021f800f258410aca28bb151e0aa48 | |
parent | 9071c8fc454f5f56060bb979fa3ea01cc61e6ffb (diff) | |
parent | a405f7a4994d7823b0e4429438e78a6b3dadecdc (diff) | |
download | meson-d87eb7d2905eaa9ed7bac60945821c7b039298d8.zip meson-d87eb7d2905eaa9ed7bac60945821c7b039298d8.tar.gz meson-d87eb7d2905eaa9ed7bac60945821c7b039298d8.tar.bz2 |
Merge branch 'base_options'.
-rw-r--r-- | mesonbuild/backend/backends.py | 9 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 42 | ||||
-rw-r--r-- | mesonbuild/compilers.py | 135 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 4 | ||||
-rw-r--r-- | mesonbuild/environment.py | 16 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 14 | ||||
-rw-r--r-- | mesonbuild/mconf.py | 16 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 4 | ||||
-rw-r--r-- | mesonbuild/mgui.py | 24 | ||||
-rw-r--r-- | mesonbuild/mintro.py | 25 | ||||
-rw-r--r-- | mesonbuild/optinterpreter.py | 9 |
11 files changed, 218 insertions, 80 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 3a24f30..8d0b0f6 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -203,8 +203,11 @@ class Backend(): if c.can_compile(s): return cpp for c in self.build.compilers: - if c.get_language() != 'vala': - return c + if c.get_language() == 'vala': + continue + for s in src: + if c.can_compile(s): + return c raise RuntimeError('Unreachable code') def determine_ext_objs(self, extobj, proj_dir_to_build_root='', include_dir_names=True): @@ -256,7 +259,7 @@ class Backend(): commands += self.environment.coredata.external_args[compiler.get_language()] commands += target.get_extra_args(compiler.get_language()) commands += compiler.get_buildtype_args(self.environment.coredata.get_builtin_option('buildtype')) - if self.environment.coredata.get_builtin_option('coverage'): + if self.environment.coredata.base_options.get('b_coverage', False): commands += compiler.get_coverage_args() if self.environment.coredata.get_builtin_option('werror'): commands += compiler.get_werror_args() diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index c4ed9de..8e8fa42 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -17,6 +17,7 @@ from .. import environment, mesonlib from .. import build from .. import mlog from .. import dependencies +from .. import compilers from ..mesonlib import File from .backends import InstallData from ..build import InvalidArguments @@ -181,7 +182,7 @@ int dummy; self.generate_tests(outfile) outfile.write('# Install rules\n\n') self.generate_install(outfile) - if self.environment.coredata.get_builtin_option('coverage'): + if self.environment.coredata.base_options.get('b_coverage', False): outfile.write('# Coverage rules\n\n') self.generate_coverage_rules(outfile) outfile.write('# Suffix\n\n') @@ -246,7 +247,7 @@ int dummy; self.generate_custom_generator_rules(target, outfile) outname = self.get_target_filename(target) obj_list = [] - use_pch = self.environment.coredata.get_builtin_option('use_pch') + use_pch = self.environment.coredata.base_options.get('b_pch', False) is_unity = self.environment.coredata.get_builtin_option('unity') if use_pch and target.has_pch(): pch_objects = self.generate_pch(target, outfile) @@ -293,20 +294,20 @@ int dummy; header_deps=header_deps)) src_list = [] for src in gen_src_deps: - src_list.append(src) - if is_unity: - unity_src.append(os.path.join(self.environment.get_build_dir(), src)) + src_list.append(src) + if is_unity: + unity_src.append(os.path.join(self.environment.get_build_dir(), src)) + header_deps.append(src) + else: + # Generated targets are ordered deps because the must exist + # before the sources compiling them are used. After the first + # compile we get precise dependency info from dep files. + # This should work in all cases. If it does not, then just + # move them from orderdeps to proper deps. + if self.environment.is_header(src): header_deps.append(src) else: - # Generated targets are ordered deps because the must exist - # before the sources compiling them are used. After the first - # compile we get precise dependency info from dep files. - # This should work in all cases. If it does not, then just - # move them from orderdeps to proper deps. - if self.environment.is_header(src): - header_deps.append(src) - else: - obj_list.append(self.generate_single_compile(target, outfile, src, True, [], header_deps)) + obj_list.append(self.generate_single_compile(target, outfile, src, True, [], header_deps)) for src in target.get_sources(): if src.endswith('.vala'): continue @@ -1430,6 +1431,8 @@ rule FORTRAN_DEP_HACK commands = [] # The first thing is implicit include directories: source, build and private. commands += compiler.get_include_args(self.get_target_private_dir(target), False) + commands += compilers.get_base_compile_args(self.environment.coredata.base_options, + compiler) curdir = target.get_subdir() tmppath = os.path.normpath(os.path.join(self.build_to_src, curdir)) commands += compiler.get_include_args(tmppath, False) @@ -1484,7 +1487,7 @@ rule FORTRAN_DEP_HACK rel_obj = os.path.join(self.get_target_private_dir(target), obj_basename) rel_obj += '.' + self.environment.get_object_suffix() dep_file = compiler.depfile_for_object(rel_obj) - if self.environment.coredata.get_builtin_option('use_pch'): + if self.environment.coredata.base_options.get('b_pch', False): pchlist = target.get_pch(compiler.language) else: pchlist = [] @@ -1503,7 +1506,7 @@ rule FORTRAN_DEP_HACK custom_target_include_dirs.append(idir) for i in custom_target_include_dirs: commands+= compiler.get_include_args(i, False) - if self.environment.coredata.get_builtin_option('use_pch'): + if self.environment.coredata.base_options.get('b_pch', False): commands += self.get_pch_include_args(compiler, target) crstr = '' if target.is_cross: @@ -1637,6 +1640,9 @@ rule FORTRAN_DEP_HACK abspath = os.path.join(self.environment.get_build_dir(), target.subdir) commands = [] commands += linker.get_linker_always_args() + if not isinstance(target, build.StaticLibrary): + commands += compilers.get_base_link_args(self.environment.coredata.base_options, + linker) commands += linker.get_buildtype_linker_args(self.environment.coredata.get_builtin_option('buildtype')) commands += linker.get_option_link_args(self.environment.coredata.compiler_options) if not(isinstance(target, build.StaticLibrary)): @@ -1678,7 +1684,7 @@ rule FORTRAN_DEP_HACK commands += dep.get_link_args() commands += linker.build_rpath_args(self.environment.get_build_dir(),\ self.determine_rpath_dirs(target), target.install_rpath) - if self.environment.coredata.get_builtin_option('coverage'): + if self.environment.coredata.base_options.get('b_coverage', False): commands += linker.get_coverage_link_args() custom_target_libraries = self.get_custom_target_provided_libraries(target) commands += extra_args @@ -1793,7 +1799,7 @@ rule FORTRAN_DEP_HACK elem = NinjaBuildElement(self.all_outputs, 'clean', 'CUSTOM_COMMAND', 'PHONY') elem.add_item('COMMAND', [ninja_command, '-t', 'clean']) elem.add_item('description', 'Cleaning') - if self.environment.coredata.get_builtin_option('coverage'): + if self.environment.coredata.base_options.get('b_coverage', False): self.generate_gcov_clean(outfile) elem.add_dep('clean-gcda') elem.add_dep('clean-gcno') diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index cc554c4..ba5c269 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -66,6 +66,7 @@ msvc_buildtype_args = {'plain' : [], gnulike_buildtype_linker_args = {} + if mesonlib.is_osx(): gnulike_buildtype_linker_args.update({'plain' : [], 'debug' : [], @@ -111,6 +112,96 @@ msvc_winlibs = ['kernel32.lib', 'user32.lib', 'gdi32.lib', 'winspool.lib', 'shell32.lib', 'ole32.lib', 'oleaut32.lib', 'uuid.lib', 'comdlg32.lib', 'advapi32.lib'] + +base_options = { + 'b_pch': coredata.UserBooleanOption('b_lto', 'Use precompiled headers', False), + 'b_lto': coredata.UserBooleanOption('b_lto', 'Use link time optimization', False), + 'b_sanitize': coredata.UserComboOption('b_sanitize', + 'Code sanitizer to use', + ['none', 'address', 'thread', 'undefined', 'memory'], + 'none'), + 'b_lundef': coredata.UserBooleanOption('b_lundef', 'Use -Wl,--no-undefined when linking', True), + 'b_pgo': coredata.UserComboOption('b_pgo', 'Use profile guide optimization', + ['off', 'generate', 'use'], + 'off'), + 'b_coverage': coredata.UserBooleanOption('b_coverage', + 'Enable coverage tracking.', + True), + } + +def sanitizer_compile_args(value): + if value == 'none': + return [] + args = ['-fsanitize=' + value] + if value == 'address': + args.append('-fno-omit-frame-pointer') + return args + +def sanitizer_link_args(value): + if value == 'none': + return [] + args = ['-fsanitize=' + value] + return args + +def get_base_compile_args(options, compiler): + args = [] + # FIXME, gcc/clang specific. + try: + if options['b_lto'].value: + args.append('-flto') + except KeyError: + pass + try: + args += sanitizer_compile_args(options['b_sanitize'].value) + except KeyError: + pass + try: + pgo_val = options['b_pgo'].value + if pgo_val == 'generate': + args.append('-fprofile-generate') + elif pgo_val == 'use': + args.append('-fprofile-use') + except KeyError: + pass + try: + if options['b_coverage'].value: + args += compiler.get_coverage_args() + except KeyError: + pass + return args + +def get_base_link_args(options, linker): + args = [] + # FIXME, gcc/clang specific. + try: + if options['b_lto'].value: + args.append('-flto') + except KeyError: + pass + try: + args += sanitizer_link_args(options['b_sanitize'].value) + except KeyError: + pass + try: + pgo_val = options['b_pgo'].value + if pgo_val == 'generate': + args.append('-fprofile-generate') + elif pgo_val == 'use': + args.append('-fprofile-use') + except KeyError: + pass + try: + if options['b_lundef'].value: + args.append('-Wl,--no-undefined') + except KeyError: + pass + try: + if options['b_coverage'].value: + args += linker.get_coverage_link_args() + except KeyError: + pass + return args + def build_unix_rpath_args(build_dir, rpath_paths, install_rpath): if len(rpath_paths) == 0 and len(install_rpath) == 0: return [] @@ -147,6 +238,7 @@ class Compiler(): else: raise TypeError('Unknown argument to Compiler') self.version = version + self.base_options = [] def get_always_args(self): return [] @@ -1106,6 +1198,7 @@ class VisualStudioCCompiler(CCompiler): self.warn_args = {'1': ['/W2'], '2': ['/W3'], '3': ['/w4']} + self.base_options = ['b_pch'] # FIXME add lto, pgo and the like def get_always_args(self): return self.always_args @@ -1250,6 +1343,7 @@ class VisualStudioCPPCompiler(VisualStudioCCompiler): VisualStudioCCompiler.__init__(self, exelist, version, is_cross, exe_wrap) self.language = 'cpp' self.default_suffix = 'cpp' + self.base_options = ['b_pch'] # FIXME add lto, pgo and the like def can_compile(self, filename): suffix = filename.split('.')[-1] @@ -1299,6 +1393,11 @@ GCC_STANDARD = 0 GCC_OSX = 1 GCC_MINGW = 2 +CLANG_STANDARD = 0 +CLANG_OSX = 1 +CLANG_WIN = 2 +# Possibly clang-cl? + def get_gcc_soname_args(gcc_type, shlib_name, path, soversion): if soversion is None: sostr = '' @@ -1321,6 +1420,9 @@ class GnuCCompiler(CCompiler): self.warn_args = {'1': ['-Wall', '-Winvalid-pch'], '2': ['-Wall', '-Wextra', '-Winvalid-pch'], '3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']} + self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize'] + if self.gcc_type != GCC_OSX: + self.base_options.append('b_lundef') def get_pic_args(self): if self.gcc_type == GCC_MINGW: @@ -1383,6 +1485,9 @@ class GnuObjCCompiler(ObjCCompiler): self.warn_args = {'1': ['-Wall', '-Winvalid-pch'], '2': ['-Wall', '-Wextra', '-Winvalid-pch'], '3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']} + self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize'] + if self.gcc_type != GCC_OSX: + self.base_options.append('b_lundef') def get_buildtype_args(self, buildtype): return gnulike_buildtype_args[buildtype] @@ -1408,6 +1513,9 @@ class GnuObjCPPCompiler(ObjCPPCompiler): self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'], '2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'], '3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']} + self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize'] + if self.gcc_type != GCC_OSX: + self.base_options.append('b_lundef') def get_buildtype_args(self, buildtype): return gnulike_buildtype_args[buildtype] @@ -1422,22 +1530,34 @@ class GnuObjCPPCompiler(ObjCPPCompiler): return get_gcc_soname_args(self.gcc_type, shlib_name, path, soversion) class ClangObjCCompiler(GnuObjCCompiler): - def __init__(self, exelist, version, is_cross, exe_wrapper=None): + def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None): super().__init__(exelist, version, is_cross, exe_wrapper) self.id = 'clang' + self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize'] + self.clang_type = cltype + if self.clang_type != CLANG_OSX: + self.base_options.append('b_lundef') class ClangObjCPPCompiler(GnuObjCPPCompiler): - def __init__(self, exelist, version, is_cross, exe_wrapper=None): + def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None): super().__init__(exelist, version, is_cross, exe_wrapper) self.id = 'clang' + self.clang_type = cltype + self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize'] + if self.clang_type != CLANG_OSX: + self.base_options.append('b_lundef') class ClangCCompiler(CCompiler): - def __init__(self, exelist, version, is_cross, exe_wrapper=None): + def __init__(self, exelist, version, clang_type, is_cross, exe_wrapper=None): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) self.id = 'clang' + self.clang_type = clang_type self.warn_args = {'1': ['-Wall', '-Winvalid-pch'], '2': ['-Wall', '-Wextra', '-Winvalid-pch'], '3' : ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch']} + self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize'] + if self.clang_type != CLANG_OSX: + self.base_options.append('b_lundef') def get_buildtype_args(self, buildtype): return gnulike_buildtype_args[buildtype] @@ -1483,6 +1603,9 @@ class GnuCPPCompiler(CPPCompiler): self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'], '2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'], '3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']} + self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize'] + if self.gcc_type != GCC_OSX: + self.base_options.append('b_lundef') def get_always_args(self): return ['-pipe'] @@ -1523,12 +1646,16 @@ class GnuCPPCompiler(CPPCompiler): return [] class ClangCPPCompiler(CPPCompiler): - def __init__(self, exelist, version, is_cross, exe_wrapper=None): + def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None): CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) self.id = 'clang' self.warn_args = {'1': ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'], '2': ['-Wall', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor'], '3': ['-Wall', '-Wpedantic', '-Wextra', '-Winvalid-pch', '-Wnon-virtual-dtor']} + self.clang_type = cltype + self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize'] + if self.clang_type != CLANG_OSX: + self.base_options.append('b_lundef') def get_buildtype_args(self, buildtype): return gnulike_buildtype_args[buildtype] diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 9e927e3..d085532 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -24,7 +24,6 @@ libtypelist = ['shared', 'static'] builtin_options = {'buildtype': True, 'strip': True, 'coverage': True, - 'pch': True, 'unity': True, 'prefix': True, 'libdir' : True, @@ -145,6 +144,7 @@ class CoreData(): self.init_builtins(options) self.user_options = {} self.compiler_options = {} + self.base_options = {} self.external_args = {} # These are set from "the outside" with e.g. mesonconf self.external_link_args = {} if options.cross_file is not None: @@ -169,9 +169,7 @@ class CoreData(): self.builtin_options['backend'] = UserStringOption('backend', 'Backend to use', options.backend) self.builtin_options['buildtype'] = UserComboOption('buildtype', 'Build type', build_types, options.buildtype) self.builtin_options['strip'] = UserBooleanOption('strip', 'Strip on install', options.strip) - self.builtin_options['use_pch'] = UserBooleanOption('use_pch', 'Use precompiled headers', options.use_pch) self.builtin_options['unity'] = UserBooleanOption('unity', 'Unity build', options.unity) - self.builtin_options['coverage'] = UserBooleanOption('coverage', 'Enable coverage', options.coverage) self.builtin_options['warning_level'] = UserComboOption('warning_level', 'Warning level', warning_levels, options.warning_level) self.builtin_options['werror'] = UserBooleanOption('werror', 'Warnings are errors', options.werror) self.builtin_options['layout'] = UserComboOption('layout', 'Build dir layout', layouts, options.layout) diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 61954af..c381ab5 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -222,7 +222,11 @@ class Environment(): gtype = GCC_STANDARD return GnuCCompiler(ccache + [compiler], version, gtype, is_cross, exe_wrap) if 'clang' in out: - return ClangCCompiler(ccache + [compiler], version, is_cross, exe_wrap) + if 'Apple' in out: + cltype = CLANG_OSX + else: + cltype = CLANG_STANDARD + return ClangCCompiler(ccache + [compiler], version, cltype, is_cross, exe_wrap) if 'Microsoft' in out or 'Microsoft' in err: # Visual Studio prints version number to stderr but # everything else to stdout. Why? Lord only knows. @@ -346,7 +350,11 @@ class Environment(): gtype = GCC_STANDARD return GnuCPPCompiler(ccache + [compiler], version, gtype, is_cross, exe_wrap) if 'clang' in out: - return ClangCPPCompiler(ccache + [compiler], version, is_cross, exe_wrap) + if 'Apple' in out: + cltype = CLANG_OSX + else: + cltype = CLANG_STANDARD + return ClangCPPCompiler(ccache + [compiler], version, cltype, is_cross, exe_wrap) if 'Microsoft' in out or 'Microsoft' in err: version = re.search(Environment.version_regex, err).group() return VisualStudioCPPCompiler([compiler], version, is_cross, exe_wrap) @@ -377,7 +385,7 @@ class Environment(): 'Free Software Foundation' in out: return GnuObjCCompiler(exelist, version, is_cross, exe_wrap) if out.startswith('Apple LLVM'): - return ClangObjCCompiler(exelist, version, is_cross, exe_wrap) + return ClangObjCCompiler(exelist, version, CLANG_OSX, is_cross, exe_wrap) if 'apple' in out and 'Free Software Foundation' in out: return GnuObjCCompiler(exelist, version, is_cross, exe_wrap) raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') @@ -407,7 +415,7 @@ class Environment(): 'Free Software Foundation' in out: return GnuObjCPPCompiler(exelist, version, is_cross, exe_wrap) if out.startswith('Apple LLVM'): - return ClangObjCPPCompiler(exelist, version, is_cross, exe_wrap) + return ClangObjCPPCompiler(exelist, version, CLANG_OSX, is_cross, exe_wrap) if 'apple' in out and 'Free Software Foundation' in out: return GnuObjCPPCompiler(exelist, version, is_cross, exe_wrap) raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 04bfa07..ef6f3c1 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -19,6 +19,7 @@ from . import dependencies from . import mlog from . import build from . import optinterpreter +from . import compilers from .wrap import wrap from . import mesonlib @@ -1527,8 +1528,21 @@ class Interpreter(): self.build.add_cross_compiler(cross_comp) if self.environment.is_cross_build() and not need_cross_compiler: self.build.add_cross_compiler(comp) + self.add_base_options(comp) return success + def add_base_options(self, compiler): + proj_opt = self.environment.cmd_line_options.projectoptions + for optname in compiler.base_options: + if optname in self.coredata.base_options: + continue + oobj = compilers.base_options[optname] + for po in proj_opt: + if po.startswith(optname + '='): + oobj.set_value(po.split('=', 1)[1]) + break + self.coredata.base_options[optname] = oobj + def func_find_program(self, node, args, kwargs): self.validate_arguments(args, 1, [str]) required = kwargs.get('required', True) diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 72b3fbe..c8ea494 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -94,6 +94,9 @@ class Conf: elif k in self.coredata.compiler_options: tgt = self.coredata.compiler_options[k] tgt.set_value(v) + elif k in self.coredata.base_options: + tgt = self.coredata.base_options[k] + tgt.set_value(v) elif k.endswith('linkargs'): lang = k[:-8] if not lang in self.coredata.external_link_args: @@ -125,12 +128,21 @@ class Conf: carr.append(['warning_level', 'Warning level', self.coredata.get_builtin_option('warning_level'), warning_levels]) carr.append(['werror', 'Treat warnings as errors', self.coredata.get_builtin_option('werror'), booleans]) carr.append(['strip', 'Strip on install', self.coredata.get_builtin_option('strip'), booleans]) - carr.append(['coverage', 'Coverage report', self.coredata.get_builtin_option('coverage'), booleans]) - carr.append(['use_pch', 'Precompiled headers', self.coredata.get_builtin_option('use_pch'), booleans]) carr.append(['unity', 'Unity build', self.coredata.get_builtin_option('unity'), booleans]) carr.append(['default_library', 'Default library type', self.coredata.get_builtin_option('default_library'), libtypelist]) self.print_aligned(carr) print('') + print('Base options:') + okeys = sorted(self.coredata.base_options.keys()) + if len(okeys) == 0: + print(' No base options\n') + else: + coarr = [] + for k in okeys: + o = self.coredata.base_options[k] + coarr.append([k, o.description, o.value, '']) + self.print_aligned(coarr) + print('') print('Compiler arguments:') for (lang, args) in self.coredata.external_args.items(): print(' ' + lang + 'args', str(args)) diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 0186006..22b52e3 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -57,10 +57,6 @@ parser.add_argument('--buildtype', default='debug', choices=build_types, dest='b help='build type go use (default: %(default)s)') parser.add_argument('--strip', action='store_true', dest='strip', default=False,\ help='strip targets on install (default: %(default)s)') -parser.add_argument('--enable-gcov', action='store_true', dest='coverage', default=False,\ - help='measure test coverage') -parser.add_argument('--disable-pch', action='store_false', dest='use_pch', default=True,\ - help='do not use precompiled headers') parser.add_argument('--unity', action='store_true', dest='unity', default=False,\ help='unity build') parser.add_argument('--werror', action='store_true', dest='werror', default=False,\ diff --git a/mesonbuild/mgui.py b/mesonbuild/mgui.py index 6e57ce7..ffd1800 100644 --- a/mesonbuild/mgui.py +++ b/mesonbuild/mgui.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2013-2015 The Meson development team +# Copyright 2013-2016 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -249,14 +249,6 @@ class OptionForm: strip.setChecked(self.coredata.get_builtin_option('strip')) strip.stateChanged.connect(self.strip_changed) self.form.addRow('Strip on install', strip) - coverage = QCheckBox("") - coverage.setChecked(self.coredata.get_builtin_option('coverage')) - coverage.stateChanged.connect(self.coverage_changed) - self.form.addRow('Enable coverage', coverage) - pch = QCheckBox("") - pch.setChecked(self.coredata.get_builtin_option('use_pch')) - pch.stateChanged.connect(self.pch_changed) - self.form.addRow('Enable pch', pch) unity = QCheckBox("") unity.setChecked(self.coredata.get_builtin_option('unity')) unity.stateChanged.connect(self.unity_changed) @@ -317,20 +309,6 @@ class OptionForm: ns = True self.coredata.strip = ns - def coverage_changed(self, newState): - if newState == 0: - ns = False - else: - ns = True - self.coredata.coverage = ns - - def pch_changed(self, newState): - if newState == 0: - ns = False - else: - ns = True - self.coredata.use_pch = ns - def unity_changed(self, newState): if newState == 0: ns = False diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index b088117..0881f69 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -89,28 +89,21 @@ def list_target_files(target_name, coredata, builddata): def list_buildoptions(coredata, builddata): buildtype= {'choices': ['plain', 'debug', 'debugoptimized', 'release'], 'type' : 'combo', - 'value' : coredata.buildtype, + 'value' : coredata.builtin_options['buildtype'].value, 'description' : 'Build type', 'name' : 'type'} - strip = {'value' : coredata.strip, + strip = {'value' : coredata.builtin_options['strip'].value, 'type' : 'boolean', 'description' : 'Strip on install', 'name' : 'strip'} - coverage = {'value': coredata.coverage, - 'type' : 'boolean', - 'description' : 'Enable coverage', - 'name' : 'coverage'} - pch = {'value' : coredata.use_pch, - 'type' : 'boolean', - 'description' : 'Use precompiled headers', - 'name' : 'pch'} - unity = {'value' : coredata.unity, + unity = {'value' : coredata.builtin_options['unity'].value, 'type' : 'boolean', 'description' : 'Unity build', 'name' : 'unity'} - optlist = [buildtype, strip, coverage, pch, unity] + optlist = [buildtype, strip, unity] add_keys(optlist, coredata.user_options) add_keys(optlist, coredata.compiler_options) + add_keys(optlist, coredata.base_options) print(json.dumps(optlist)) def add_keys(optlist, options): @@ -121,14 +114,14 @@ def add_keys(optlist, options): optdict = {} optdict['name'] = key optdict['value'] = opt.value - if isinstance(opt, mesonlib.UserStringOption): + if isinstance(opt, coredata.UserStringOption): typestr = 'string' - elif isinstance(opt, mesonlib.UserBooleanOption): + elif isinstance(opt, coredata.UserBooleanOption): typestr = 'boolean' - elif isinstance(opt, mesonlib.UserComboOption): + elif isinstance(opt, coredata.UserComboOption): optdict['choices'] = opt.choices typestr = 'combo' - elif isinstance(opt, mesonlib.UserStringArrayOption): + elif isinstance(opt, coredata.UserStringArrayOption): typestr = 'stringarray' else: raise RuntimeError("Unknown option type") diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index 30a26ab..e2f7ca5 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -13,7 +13,7 @@ # limitations under the License. from . import mparser -from . import coredata, mesonlib +from . import coredata import os, re forbidden_option_names = coredata.builtin_options @@ -24,13 +24,16 @@ forbidden_prefixes = {'c_': True, 'objc_': True, 'objcpp_': True, 'vala_': True, - 'csharp_': True + 'csharp_': True, + 'swift_': True, + 'b_': True, } def is_invalid_name(name): if name in forbidden_option_names: return True - if name in forbidden_prefixes: + pref = name.split('_')[0] + '_' + if pref in forbidden_prefixes: return True return False |