Add no-warning args while building Vala C code
This is done by adding a new compiler method called 'no_warn_args' which returns the argument(s) required for the compiler to emit no warnings for that compilation. This take care of not disabling warnings for C code compiled into the BuildTarget. Also includes tests for ensuring all this. https://github.com/mesonbuild/meson/issues/864
This commit is contained in:
parent
b6b8d561b8
commit
4332df01b8
|
@ -327,11 +327,14 @@ class Backend():
|
||||||
extra_args.append(arg)
|
extra_args.append(arg)
|
||||||
return extra_args
|
return extra_args
|
||||||
|
|
||||||
def generate_basic_compiler_args(self, target, compiler):
|
def generate_basic_compiler_args(self, target, compiler, no_warn_args=False):
|
||||||
commands = []
|
commands = []
|
||||||
commands += self.get_cross_stdlib_args(target, compiler)
|
commands += self.get_cross_stdlib_args(target, compiler)
|
||||||
commands += compiler.get_always_args()
|
commands += compiler.get_always_args()
|
||||||
commands += compiler.get_warn_args(self.environment.coredata.get_builtin_option('warning_level'))
|
if no_warn_args:
|
||||||
|
commands += compiler.get_no_warn_args()
|
||||||
|
else:
|
||||||
|
commands += compiler.get_warn_args(self.environment.coredata.get_builtin_option('warning_level'))
|
||||||
commands += compiler.get_option_compile_args(self.environment.coredata.compiler_options)
|
commands += compiler.get_option_compile_args(self.environment.coredata.compiler_options)
|
||||||
commands += self.build.get_global_args(compiler)
|
commands += self.build.get_global_args(compiler)
|
||||||
commands += self.environment.coredata.external_args[compiler.get_language()]
|
commands += self.environment.coredata.external_args[compiler.get_language()]
|
||||||
|
|
|
@ -233,7 +233,7 @@ int dummy;
|
||||||
if isinstance(target, build.RunTarget):
|
if isinstance(target, build.RunTarget):
|
||||||
self.generate_run_target(target, outfile)
|
self.generate_run_target(target, outfile)
|
||||||
name = target.get_id()
|
name = target.get_id()
|
||||||
gen_src_deps = []
|
vala_gen_sources = []
|
||||||
if name in self.processed_targets:
|
if name in self.processed_targets:
|
||||||
return
|
return
|
||||||
if isinstance(target, build.Jar):
|
if isinstance(target, build.Jar):
|
||||||
|
@ -249,8 +249,7 @@ int dummy;
|
||||||
self.generate_swift_target(target, outfile)
|
self.generate_swift_target(target, outfile)
|
||||||
return
|
return
|
||||||
if 'vala' in target.compilers:
|
if 'vala' in target.compilers:
|
||||||
vala_output_files = self.generate_vala_compile(target, outfile)
|
vala_gen_sources = self.generate_vala_compile(target, outfile)
|
||||||
gen_src_deps += vala_output_files
|
|
||||||
self.scan_fortran_module_outputs(target)
|
self.scan_fortran_module_outputs(target)
|
||||||
self.process_target_dependencies(target, outfile)
|
self.process_target_dependencies(target, outfile)
|
||||||
self.generate_custom_generator_rules(target, outfile)
|
self.generate_custom_generator_rules(target, outfile)
|
||||||
|
@ -318,9 +317,10 @@ int dummy;
|
||||||
src_list.append(src)
|
src_list.append(src)
|
||||||
obj_list.append(self.generate_single_compile(target, outfile, src, True,
|
obj_list.append(self.generate_single_compile(target, outfile, src, True,
|
||||||
header_deps=header_deps))
|
header_deps=header_deps))
|
||||||
# Generate compilation targets for sources belonging to this target that
|
# Generate compilation targets for C sources generated from Vala
|
||||||
# are generated by other rules (this is only used for Vala right now)
|
# sources. This can be extended to other $LANG->C compilers later if
|
||||||
for src in gen_src_deps:
|
# necessary.
|
||||||
|
for src in vala_gen_sources:
|
||||||
src_list.append(src)
|
src_list.append(src)
|
||||||
if is_unity:
|
if is_unity:
|
||||||
unity_src.append(os.path.join(self.environment.get_build_dir(), src))
|
unity_src.append(os.path.join(self.environment.get_build_dir(), src))
|
||||||
|
@ -334,7 +334,7 @@ int dummy;
|
||||||
if self.environment.is_header(src):
|
if self.environment.is_header(src):
|
||||||
header_deps.append(src)
|
header_deps.append(src)
|
||||||
else:
|
else:
|
||||||
obj_list.append(self.generate_single_compile(target, outfile, src, True, [], header_deps))
|
obj_list.append(self.generate_single_compile(target, outfile, src, 'vala', [], header_deps))
|
||||||
# Generate compile targets for all the pre-existing sources for this target
|
# Generate compile targets for all the pre-existing sources for this target
|
||||||
for src in target.get_sources():
|
for src in target.get_sources():
|
||||||
if src.endswith('.vala'):
|
if src.endswith('.vala'):
|
||||||
|
@ -1614,7 +1614,11 @@ rule FORTRAN_DEP_HACK
|
||||||
commands += sargs
|
commands += sargs
|
||||||
for d in i.get_extra_build_dirs():
|
for d in i.get_extra_build_dirs():
|
||||||
commands += compiler.get_include_args(d, i.is_system)
|
commands += compiler.get_include_args(d, i.is_system)
|
||||||
commands += self.generate_basic_compiler_args(target, compiler)
|
commands += self.generate_basic_compiler_args(target, compiler,
|
||||||
|
# The code generated by valac is usually crap
|
||||||
|
# and has tons of unused variables and such,
|
||||||
|
# so disable warnings for Vala C sources.
|
||||||
|
no_warn_args=(is_generated == 'vala'))
|
||||||
for d in target.external_deps:
|
for d in target.external_deps:
|
||||||
if d.need_threads():
|
if d.need_threads():
|
||||||
commands += compiler.thread_flags()
|
commands += compiler.thread_flags()
|
||||||
|
|
|
@ -473,6 +473,10 @@ class CCompiler(Compiler):
|
||||||
def get_warn_args(self, level):
|
def get_warn_args(self, level):
|
||||||
return self.warn_args[level]
|
return self.warn_args[level]
|
||||||
|
|
||||||
|
def get_no_warn_args(self):
|
||||||
|
# Almost every compiler uses this for disabling warnings
|
||||||
|
return ['-w']
|
||||||
|
|
||||||
def get_soname_args(self, prefix, shlib_name, suffix, path, soversion):
|
def get_soname_args(self, prefix, shlib_name, suffix, path, soversion):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -2255,6 +2259,9 @@ end program prog
|
||||||
def get_warn_args(self, level):
|
def get_warn_args(self, level):
|
||||||
return ['-Wall']
|
return ['-Wall']
|
||||||
|
|
||||||
|
def get_no_warn_args(self):
|
||||||
|
return ['-w']
|
||||||
|
|
||||||
|
|
||||||
class GnuFortranCompiler(FortranCompiler):
|
class GnuFortranCompiler(FortranCompiler):
|
||||||
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None):
|
def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None):
|
||||||
|
@ -2292,6 +2299,10 @@ class G95FortranCompiler(FortranCompiler):
|
||||||
def get_always_args(self):
|
def get_always_args(self):
|
||||||
return ['-pipe']
|
return ['-pipe']
|
||||||
|
|
||||||
|
def get_no_warn_args(self):
|
||||||
|
# FIXME: Confirm that there's no compiler option to disable all warnings
|
||||||
|
return []
|
||||||
|
|
||||||
def gen_import_library_args(self, implibname):
|
def gen_import_library_args(self, implibname):
|
||||||
"""
|
"""
|
||||||
The name of the outputted import library
|
The name of the outputted import library
|
||||||
|
@ -2357,6 +2368,9 @@ class PGIFortranCompiler(FortranCompiler):
|
||||||
def get_warn_args(self, level):
|
def get_warn_args(self, level):
|
||||||
return PGIFortranCompiler.std_warn_args
|
return PGIFortranCompiler.std_warn_args
|
||||||
|
|
||||||
|
def get_no_warn_args(self):
|
||||||
|
return ['-silent']
|
||||||
|
|
||||||
|
|
||||||
class Open64FortranCompiler(FortranCompiler):
|
class Open64FortranCompiler(FortranCompiler):
|
||||||
std_warn_args = ['-fullwarn']
|
std_warn_args = ['-fullwarn']
|
||||||
|
|
Loading…
Reference in New Issue