diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-02-14 10:05:42 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-02-17 20:22:34 +0200 |
commit | deff35eef60223b5df6497e61e0cdcf1ad81f09f (patch) | |
tree | 3f76df4a13d3b8dc4c43abe184c954e8896acae1 | |
parent | 440d73902dc266ff25465d125b7f625e531b1225 (diff) | |
download | meson-deff35eef60223b5df6497e61e0cdcf1ad81f09f.zip meson-deff35eef60223b5df6497e61e0cdcf1ad81f09f.tar.gz meson-deff35eef60223b5df6497e61e0cdcf1ad81f09f.tar.bz2 |
Filter out UNIX flags from external deps when using the MSVC compiler
This is very useful to prevent compiler noise about invalid cflags; particularly
for the -mms-bitfields cflag which most libraries send to the mingw-gcc
compiler. More can be added later.
-rw-r--r-- | mesonbuild/backend/backends.py | 4 | ||||
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 2 | ||||
-rw-r--r-- | mesonbuild/compilers.py | 26 |
3 files changed, 26 insertions, 6 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index d6b8e7c..8256cee 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -255,7 +255,9 @@ class Backend(): if isinstance(target, build.SharedLibrary): commands += compiler.get_pic_args() for dep in target.get_external_deps(): - commands += dep.get_compile_args() + # Cflags required by external deps might have UNIX-specific flags, + # so filter them out if needed + commands += compiler.unix_compile_flags_to_native(dep.get_compile_args()) if isinstance(target, build.Executable): commands += dep.get_exe_args() diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 1a051c5..c0e204a 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1681,7 +1681,7 @@ rule FORTRAN_DEP_HACK custom_target_libraries = self.get_custom_target_provided_libraries(target) commands += extra_args commands += custom_target_libraries - commands = linker.unixtype_flags_to_native(commands) + commands = linker.unix_link_flags_to_native(commands) dep_targets = [self.get_dependency_filename(t) for t in dependencies] dep_targets += [os.path.join(self.environment.source_dir, target.subdir, t) for t in target.link_depends] diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index cb6b7c7..7cf152f 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -184,7 +184,10 @@ class Compiler(): def has_function(self, *args, **kwargs): raise EnvironmentException('Language %s does not support function checks.' % self.language) - def unixtype_flags_to_native(self, args): + def unix_link_flags_to_native(self, args): + return args + + def unix_compile_flags_to_native(self, args): return args class CCompiler(Compiler): @@ -1174,7 +1177,7 @@ class VisualStudioCCompiler(CCompiler): def get_option_link_args(self, options): return options['c_winlibs'].value - def unixtype_flags_to_native(self, args): + def unix_link_flags_to_native(self, args): result = [] for i in args: if i.startswith('-L'): @@ -1182,6 +1185,15 @@ class VisualStudioCCompiler(CCompiler): result.append(i) return result + def unix_compile_flags_to_native(self, args): + result = [] + for i in args: + # -mms-bitfields is specific to MinGW-GCC + if i == '-mms-bitfields': + continue + result.append(i) + return result + def get_include_args(self, path, is_system): if path == '': path = '.' @@ -1799,7 +1811,10 @@ class VisualStudioLinker(): def get_option_link_args(self, options): return [] - def unixtype_flags_to_native(self, args): + def unix_link_flags_to_native(self, args): + return args + + def unix_compile_flags_to_native(self, args): return args class ArLinker(): @@ -1845,5 +1860,8 @@ class ArLinker(): def get_option_link_args(self, options): return [] - def unixtype_flags_to_native(self, args): + def unix_link_flags_to_native(self, args): + return args + + def unix_compile_flags_to_native(self, args): return args |