diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2018-10-01 15:03:41 +0800 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-11-10 10:58:47 +0100 |
commit | 4fd6b1f3577aba1ddf8efff8f5cd81a487a50375 (patch) | |
tree | 804ec14ce96bfd4c7f432981e48f0872cb925340 /setup.py | |
parent | fba896c68699e6c883846063a7e572ec82093b21 (diff) | |
download | pygobject-4fd6b1f3577aba1ddf8efff8f5cd81a487a50375.tar.gz |
setup.py: Fix MSVC builds
The distutils C Compiler object for MSVC does not have a compiler
sub-attribute, so check the compiler type before we try to use that
sub-attribute. This will fix builds on MSVC using distutils.
Also, in place of checking the various GCC/CLang compiler flags for
compile-type warnings we want to look out for, force-include
msvc_recommended_pragmas.h when we are building with Visual Studio, as
we are doing in the other GNOME projects, to achive similar effects.
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 143 |
1 files changed, 75 insertions, 68 deletions
@@ -217,7 +217,7 @@ def filter_compiler_arguments(compiler, args): """ if compiler.compiler_type == "msvc": - # TODO + # TODO, not much of need for now. return [] extra = [] @@ -891,76 +891,83 @@ def add_ext_pkg_config_dep(ext, compiler_type, name): def add_ext_compiler_flags(ext, compiler, _cache={}): - cache_key = compiler.compiler[0] - if cache_key not in _cache: - - args = [ - "-Wall", - "-Warray-bounds", - "-Wcast-align", - "-Wdeclaration-after-statement", - "-Wduplicated-branches", - "-Wextra", - "-Wformat=2", - "-Wformat-nonliteral", - "-Wformat-security", - "-Wimplicit-function-declaration", - "-Winit-self", - "-Wjump-misses-init", - "-Wlogical-op", - "-Wmissing-declarations", - "-Wmissing-format-attribute", - "-Wmissing-include-dirs", - "-Wmissing-noreturn", - "-Wmissing-prototypes", - "-Wnested-externs", - "-Wnull-dereference", - "-Wold-style-definition", - "-Wpacked", - "-Wpointer-arith", - "-Wrestrict", - "-Wreturn-type", - "-Wshadow", - "-Wsign-compare", - "-Wstrict-aliasing", - "-Wstrict-prototypes", - "-Wundef", - "-Wunused-but-set-variable", - "-Wwrite-strings", - ] - - if sys.version_info[:2] != (3, 4): + if compiler.compiler_type == "msvc": + # MSVC: Just force-include msvc_recommended_pragmas.h so that + # we can look out for compiler warnings that we really + # want to look out for, and filter out those that don't + # really matter to us. + ext.extra_compile_args += ['-FImsvc_recommended_pragmas.h'] + else: + cache_key = compiler.compiler[0] + if cache_key not in _cache: + + args = [ + "-Wall", + "-Warray-bounds", + "-Wcast-align", + "-Wdeclaration-after-statement", + "-Wduplicated-branches", + "-Wextra", + "-Wformat=2", + "-Wformat-nonliteral", + "-Wformat-security", + "-Wimplicit-function-declaration", + "-Winit-self", + "-Wjump-misses-init", + "-Wlogical-op", + "-Wmissing-declarations", + "-Wmissing-format-attribute", + "-Wmissing-include-dirs", + "-Wmissing-noreturn", + "-Wmissing-prototypes", + "-Wnested-externs", + "-Wnull-dereference", + "-Wold-style-definition", + "-Wpacked", + "-Wpointer-arith", + "-Wrestrict", + "-Wreturn-type", + "-Wshadow", + "-Wsign-compare", + "-Wstrict-aliasing", + "-Wstrict-prototypes", + "-Wundef", + "-Wunused-but-set-variable", + "-Wwrite-strings", + ] + + if sys.version_info[:2] != (3, 4): + args += [ + "-Wswitch-default", + ] + args += [ - "-Wswitch-default", + "-Wno-incompatible-pointer-types-discards-qualifiers", + "-Wno-missing-field-initializers", + "-Wno-unused-parameter", + "-Wno-discarded-qualifiers", + "-Wno-sign-conversion", + "-Wno-cast-function-type", + "-Wno-int-conversion", ] - args += [ - "-Wno-incompatible-pointer-types-discards-qualifiers", - "-Wno-missing-field-initializers", - "-Wno-unused-parameter", - "-Wno-discarded-qualifiers", - "-Wno-sign-conversion", - "-Wno-cast-function-type", - "-Wno-int-conversion", - ] - - # silence clang for unused gcc CFLAGS added by Debian - args += [ - "-Wno-unused-command-line-argument", - ] - - args += [ - "-fno-strict-aliasing", - "-fvisibility=hidden", - ] - - # force GCC to use colors - if hasattr(sys.stdout, "isatty") and sys.stdout.isatty(): - args.append("-fdiagnostics-color") - - _cache[cache_key] = filter_compiler_arguments(compiler, args) - - ext.extra_compile_args += _cache[cache_key] + # silence clang for unused gcc CFLAGS added by Debian + args += [ + "-Wno-unused-command-line-argument", + ] + + args += [ + "-fno-strict-aliasing", + "-fvisibility=hidden", + ] + + # force GCC to use colors + if hasattr(sys.stdout, "isatty") and sys.stdout.isatty(): + args.append("-fdiagnostics-color") + + _cache[cache_key] = filter_compiler_arguments(compiler, args) + + ext.extra_compile_args += _cache[cache_key] du_build_ext = get_command_class("build_ext") |