diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 26 | ||||
-rw-r--r-- | mesonbuild/compilers/c.py | 17 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 15 | ||||
-rw-r--r-- | mesonbuild/compilers/cpp.py | 12 | ||||
-rw-r--r-- | mesonbuild/compilers/cuda.py | 3 | ||||
-rw-r--r-- | mesonbuild/compilers/d.py | 18 | ||||
-rw-r--r-- | mesonbuild/compilers/fortran.py | 18 | ||||
-rw-r--r-- | mesonbuild/compilers/objc.py | 6 | ||||
-rw-r--r-- | mesonbuild/compilers/objcpp.py | 6 | ||||
-rw-r--r-- | mesonbuild/coredata.py | 2 | ||||
-rw-r--r-- | mesonbuild/mconf.py | 16 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 1 |
12 files changed, 103 insertions, 37 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 5e2f863..16962a4 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1748,11 +1748,11 @@ rule FORTRAN_DEP_HACK%s outfilelist = genlist.get_outputs() extra_dependencies = [os.path.join(self.build_to_src, i) for i in genlist.extra_depends] for i in range(len(infilelist)): + curfile = infilelist[i] if len(generator.outputs) == 1: sole_output = os.path.join(self.get_target_private_dir(target), outfilelist[i]) else: - sole_output = '' - curfile = infilelist[i] + sole_output = '{}'.format(curfile) infilename = curfile.rel_to_builddir(self.build_to_src) base_args = generator.get_arglist(infilename) outfiles = genlist.get_outputs_for(curfile) @@ -1769,7 +1769,7 @@ rule FORTRAN_DEP_HACK%s for x in args] args = self.replace_outputs(args, self.get_target_private_dir(target), outfilelist) # We have consumed output files, so drop them from the list of remaining outputs. - if sole_output == '': + if len(generator.outputs) > 1: outfilelist = outfilelist[len(generator.outputs):] args = self.replace_paths(target, args, override_subdir=subdir) cmdlist = exe_arr + self.replace_extra_args(args, genlist) @@ -1792,7 +1792,11 @@ rule FORTRAN_DEP_HACK%s elem.add_item('DEPFILE', depfile) if len(extra_dependencies) > 0: elem.add_dep(extra_dependencies) - elem.add_item('DESC', 'Generating {!r}.'.format(sole_output)) + if len(generator.outputs) == 1: + elem.add_item('DESC', 'Generating {!r}.'.format(sole_output)) + else: + # since there are multiple outputs, we log the source that caused the rebuild + elem.add_item('DESC', 'Generating source from {!r}.'.format(sole_output)) if isinstance(exe, build.BuildTarget): elem.add_dep(self.get_target_filename(exe)) elem.add_item('COMMAND', cmd) @@ -2323,8 +2327,6 @@ rule FORTRAN_DEP_HACK%s if isinstance(target, build.Executable): # Currently only used with the Swift compiler to add '-emit-executable' commands += linker.get_std_exe_link_args() - # If gui_app is significant on this platform, add the appropriate linker arguments - commands += linker.get_gui_app_args(target.gui_app) # If export_dynamic, add the appropriate linker arguments if target.export_dynamic: commands += linker.gen_export_dynamic_link_args(self.environment) @@ -2357,6 +2359,15 @@ rule FORTRAN_DEP_HACK%s raise RuntimeError('Unknown build target type.') return commands + def get_target_type_link_args_post_dependencies(self, target, linker): + commands = [] + if isinstance(target, build.Executable): + # If gui_app is significant on this platform, add the appropriate linker arguments. + # Unfortunately this can't be done in get_target_type_link_args, because some misguided + # libraries (such as SDL2) add -mwindows to their link flags. + commands += linker.get_gui_app_args(target.gui_app) + return commands + def get_link_whole_args(self, linker, target): target_args = self.build_target_link_arguments(linker, target.link_whole_targets) return linker.get_link_whole_for(target_args) if len(target_args) else [] @@ -2535,6 +2546,9 @@ rule FORTRAN_DEP_HACK%s if need_threads: commands += linker.thread_link_flags(self.environment) + # Add link args specific to this BuildTarget type that must not be overridden by dependencies + commands += self.get_target_type_link_args_post_dependencies(target, linker) + # Add link args for c_* or cpp_* build options. Currently this only # adds c_winlibs and cpp_winlibs when building for Windows. This needs # to be after all internal and external libraries so that unresolved diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index a1a8fb9..3f3aba8 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -1152,7 +1152,7 @@ class CCompiler(Compiler): # flags, so when we are testing a flag like "-Wno-forgotten-towel", also # check the equivalent enable flag too "-Wforgotten-towel" if arg.startswith('-Wno-'): - args.append('-W' + arg[5:]) + args.append('-W' + arg[5:]) if arg.startswith('-Wl,'): mlog.warning('{} looks like a linker argument, ' 'but has_argument and other similar methods only ' @@ -1209,7 +1209,8 @@ class ClangCCompiler(ClangCompiler, CCompiler): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) ClangCompiler.__init__(self, compiler_type) default_warn_args = ['-Wall', '-Winvalid-pch'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -1243,7 +1244,8 @@ class ArmclangCCompiler(ArmclangCompiler, CCompiler): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) ArmclangCompiler.__init__(self, compiler_type) default_warn_args = ['-Wall', '-Winvalid-pch'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -1271,7 +1273,8 @@ class GnuCCompiler(GnuCompiler, CCompiler): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) GnuCompiler.__init__(self, compiler_type, defines) default_warn_args = ['-Wall', '-Winvalid-pch'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -1341,7 +1344,8 @@ class IntelCCompiler(IntelCompiler, CCompiler): IntelCompiler.__init__(self, compiler_type) self.lang_header = 'c-header' default_warn_args = ['-Wall', '-w3', '-diag-disable:remark'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra']} @@ -1383,7 +1387,8 @@ class VisualStudioCCompiler(CCompiler): # /showIncludes is needed for build dependency tracking in Ninja # See: https://ninja-build.org/manual.html#_deps self.always_args = ['/nologo', '/showIncludes'] - self.warn_args = {'1': ['/W2'], + self.warn_args = {'0': ['/W1'], + '1': ['/W2'], '2': ['/W3'], '3': ['/W4']} self.base_options = ['b_pch', 'b_ndebug', 'b_vscrt'] # FIXME add lto, pgo and the like diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 65df0e7..7955f3d 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -21,7 +21,7 @@ from .. import coredata from .. import mlog from .. import mesonlib from ..mesonlib import ( - EnvironmentException, MachineChoice, MesonException, OrderedSet, + EnvironmentException, MesonException, OrderedSet, version_compare, Popen_safe ) @@ -1578,8 +1578,8 @@ class GnuLikeCompiler(abc.ABC): return ['-Wl,--allow-shlib-undefined'] def get_gui_app_args(self, value): - if self.compiler_type.is_windows_compiler and value: - return ['-mwindows'] + if self.compiler_type.is_windows_compiler: + return ['-mwindows' if value else '-mconsole'] return [] def compute_parameters_with_absolute_paths(self, parameter_list, build_dir): @@ -1636,7 +1636,8 @@ class PGICompiler: self.compiler_type = compiler_type default_warn_args = ['-Minform=inform'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args, '3': default_warn_args} @@ -1937,7 +1938,8 @@ class ArmCompiler: self.id = 'arm' self.compiler_type = compiler_type default_warn_args = [] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + [], '3': default_warn_args + []} # Assembly @@ -2029,7 +2031,8 @@ class CcrxCompiler: # Assembly self.can_compile_suffixes.update('s') default_warn_args = [] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + [], '3': default_warn_args + []} diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index bad71f6..67de684 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -135,7 +135,8 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler): CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) ClangCompiler.__init__(self, compiler_type) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -166,7 +167,8 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler): CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) ArmclangCompiler.__init__(self, compiler_type) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -194,7 +196,8 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs) GnuCompiler.__init__(self, compiler_type, defines) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -272,7 +275,8 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler): self.lang_header = 'c++-header' default_warn_args = ['-Wall', '-w3', '-diag-disable:remark', '-Wpch-messages', '-Wnon-virtual-dtor'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra']} diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index 1ea67d3..66dcf33 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -28,7 +28,8 @@ class CudaCompiler(Compiler): self.exe_wrapper = exe_wrapper self.id = 'nvcc' default_warn_args = [] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Xcompiler=-Wextra'], '3': default_warn_args + ['-Xcompiler=-Wextra', '-Xcompiler=-Wpedantic']} diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 40906c5..f1580b6 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -380,6 +380,17 @@ class DCompiler(Compiler): # translate library link flag dcargs.append('-L=' + arg) continue + elif arg.startswith('-isystem'): + # translate -isystem system include path + # this flag might sometimes be added by C library Cflags via + # pkg-config. + # NOTE: -isystem and -I are not 100% equivalent, so this is just + # a workaround for the most common cases. + if arg.startswith('-isystem='): + dcargs.append('-I=' + arg[9:]) + else: + dcargs.append('-I') + continue elif arg.startswith('-L/') or arg.startswith('-L./'): # we need to handle cases where -L is set by e.g. a pkg-config # setting to select a linker search path. We can however not @@ -487,7 +498,8 @@ class GnuDCompiler(DCompiler): DCompiler.__init__(self, exelist, version, is_cross, arch, **kwargs) self.id = 'gcc' default_warn_args = ['-Wall', '-Wdeprecated'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} self.base_options = ['b_colorout', 'b_sanitize', 'b_staticpic', 'b_vscrt'] @@ -558,8 +570,10 @@ class LLVMDCompiler(DCompiler): def get_warn_args(self, level): if level == '2' or level == '3': return ['-wi', '-dw'] - else: + elif level == '1': return ['-wi'] + else: + return [] def get_buildtype_args(self, buildtype): if buildtype != 'plain': diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 59c4214..6c260b6 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -280,7 +280,8 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) GnuCompiler.__init__(self, compiler_type, defines) default_warn_args = ['-Wall'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -307,7 +308,8 @@ class G95FortranCompiler(FortranCompiler): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) self.id = 'g95' default_warn_args = ['-Wall'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-pedantic']} @@ -352,7 +354,8 @@ class IntelFortranCompiler(IntelCompiler, FortranCompiler): IntelCompiler.__init__(self, CompilerType.ICC_STANDARD) self.id = 'intel' default_warn_args = ['-warn', 'general', '-warn', 'truncated_source'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-warn', 'unused'], '3': ['-warn', 'all']} @@ -374,7 +377,8 @@ class PathScaleFortranCompiler(FortranCompiler): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) self.id = 'pathscale' default_warn_args = ['-fullwarn'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args, '3': default_warn_args} @@ -394,7 +398,8 @@ class FlangFortranCompiler(ClangCompiler, FortranCompiler): ClangCompiler.__init__(self, CompilerType.CLANG_STANDARD) self.id = 'flang' default_warn_args = ['-Minform=inform'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args, '3': default_warn_args} @@ -403,7 +408,8 @@ class Open64FortranCompiler(FortranCompiler): FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags) self.id = 'open64' default_warn_args = ['-fullwarn'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args, '3': default_warn_args} diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index cf58ffb..8dfd0a2 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -55,7 +55,8 @@ class GnuObjCCompiler(GnuCompiler, ObjCCompiler): ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) GnuCompiler.__init__(self, compiler_type, defines) default_warn_args = ['-Wall', '-Winvalid-pch'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -65,7 +66,8 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler): ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) ClangCompiler.__init__(self, compiler_type) default_warn_args = ['-Wall', '-Winvalid-pch'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage'] diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index add888f..e66d730 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -53,7 +53,8 @@ class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler): ObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) GnuCompiler.__init__(self, compiler_type, defines) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} @@ -63,7 +64,8 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler): ObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) ClangCompiler.__init__(self, compiler_type) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] - self.warn_args = {'1': default_warn_args, + self.warn_args = {'0': [], + '1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra', '-Wpedantic']} self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage'] diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index a026584..0e11f5c 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -834,7 +834,7 @@ builtin_options = { 'localstatedir': [UserStringOption, 'Localstate data directory', 'var'], 'sharedstatedir': [UserStringOption, 'Architecture-independent data directory', 'com'], 'werror': [UserBooleanOption, 'Treat warnings as errors', False], - 'warning_level': [UserComboOption, 'Compiler warning level to use', ['1', '2', '3'], '1'], + 'warning_level': [UserComboOption, 'Compiler warning level to use', ['0', '1', '2', '3'], '1'], 'layout': [UserComboOption, 'Build directory layout', ['mirror', 'flat'], 'mirror'], 'default_library': [UserComboOption, 'Default library type', ['shared', 'static', 'both'], 'shared'], 'backend': [UserComboOption, 'Backend to use', backendlist, 'ninja'], diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 18bb37b..cd9d35a 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -41,6 +41,7 @@ class Conf: if 'meson.build' in [os.path.basename(self.build_dir), self.build_dir]: self.build_dir = os.path.dirname(self.build_dir) self.build = None + self.max_choices_line_length = 60 if os.path.isdir(os.path.join(self.build_dir, 'meson-private')): self.build = build.load(self.build_dir) @@ -100,7 +101,20 @@ class Conf: if opt['choices']: choices_found = True if isinstance(opt['choices'], list): - choices_col.append('[{0}]'.format(', '.join(make_lower_case(opt['choices'])))) + choices_list = make_lower_case(opt['choices']) + current = '[' + while choices_list: + i = choices_list.pop(0) + if len(current) + len(i) >= self.max_choices_line_length: + choices_col.append(current + ',') + name_col.append('') + value_col.append('') + descr_col.append('') + current = ' ' + if len(current) > 1: + current += ', ' + current += i + choices_col.append(current + ']') else: choices_col.append(make_lower_case(opt['choices'])) else: diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index f0f287f..516c411 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -80,6 +80,7 @@ class CommandLineParser: def run_runpython_command(self, options): import runpy sys.argv[1:] = options.script_args + sys.path.insert(0, os.path.dirname(options.script_file)) runpy.run_path(options.script_file, run_name='__main__') return 0 |