summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-07-29 11:23:42 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-07-29 16:47:36 +0200
commit80923051b3e803bf5bdc118c3bac246a308497d6 (patch)
tree0ef4ea6ea1f870bce415ad449b4a7b6c54d36e0d
parent9748b3e9a0732a173337dcd64266e803a3c77c0e (diff)
downloadgobject-introspection-80923051b3e803bf5bdc118c3bac246a308497d6.tar.gz
autotools: start using AX_COMPILER_FLAGS, enable -Werror on CI
* This adds a new dependency on autoconf-archive. * Pass WARN_CFLAGS/WARN_LDFLAGS/WARN_SCANNERFLAGS to everything we control the source of * Disables all warning flags which make the build error out for now, we'll re-enable them in followup commits. * AX_COMPILER_FLAGS is used with the release flag always on so we don't get -Werror by default.
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--.gitlab-ci/Dockerfile1
-rw-r--r--Makefile-examples.am3
-rw-r--r--Makefile-gir.am2
-rw-r--r--Makefile-girepository.am13
-rw-r--r--Makefile-giscanner.am5
-rw-r--r--Makefile-tools.am9
-rw-r--r--configure.ac32
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/offsets/Makefile.am5
-rw-r--r--tests/repository/Makefile.am4
-rw-r--r--tests/scanner/Makefile.am4
12 files changed, 51 insertions, 39 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 36fcbae0..41063290 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -48,6 +48,7 @@ fedora-x86_64-autotools-python2:
variables:
CCACHE_BASEDIR: "${CI_PROJECT_DIR}"
CCACHE_DIR: "${CI_PROJECT_DIR}/_ccache"
+ CFLAGS: "-Werror"
script:
- sed -i 's|\[glib-2\.0 >= [0-9.]*\]|[glib-2.0 >= 1.0]|' configure.ac
- ./autogen.sh --with-python=python2
@@ -64,6 +65,7 @@ fedora-x86_64-autotools-python3:
variables:
CCACHE_BASEDIR: "${CI_PROJECT_DIR}"
CCACHE_DIR: "${CI_PROJECT_DIR}/_ccache"
+ CFLAGS: "-Werror"
script:
- sed -i 's|\[glib-2\.0 >= [0-9.]*\]|[glib-2.0 >= 1.0]|' configure.ac
- ./autogen.sh --with-python=python3
diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile
index 6d63ef21..e3083b47 100644
--- a/.gitlab-ci/Dockerfile
+++ b/.gitlab-ci/Dockerfile
@@ -2,6 +2,7 @@ FROM fedora:28
RUN dnf -y install \
autoconf \
+ autoconf-archive \
automake \
bison \
cairo-devel \
diff --git a/Makefile-examples.am b/Makefile-examples.am
index 8e5985bb..cc882a86 100644
--- a/Makefile-examples.am
+++ b/Makefile-examples.am
@@ -1,7 +1,8 @@
noinst_PROGRAMS += glib-print
glib_print_SOURCES = examples/glib-print.c
-glib_print_CFLAGS = $(GOBJECT_CFLAGS) -I$(top_srcdir)/girepository
+glib_print_CFLAGS = $(GOBJECT_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)/girepository
+glib_print_LDFLAGS = $(WARN_LDFLAGS)
glib_print_LDADD = libgirepository-1.0.la $(GOBJECT_LIBS)
EXTRA_DIST += \
diff --git a/Makefile-gir.am b/Makefile-gir.am
index 0b9cb177..2cd73586 100644
--- a/Makefile-gir.am
+++ b/Makefile-gir.am
@@ -197,7 +197,7 @@ GIRepository-2.0.gir: GObject-2.0.gir libgirepository-1.0.la
GIRepository_2_0_gir_LIBS = libgirepository-1.0.la
GIRepository_2_0_gir_SCANNERFLAGS = \
- --warn-all \
+ $(WARN_SCANNERFLAGS) \
--identifier-prefix=GI \
--symbol-prefix=g \
--c-include="girepository.h" \
diff --git a/Makefile-girepository.am b/Makefile-girepository.am
index f7f956a3..2af8c4a5 100644
--- a/Makefile-girepository.am
+++ b/Makefile-girepository.am
@@ -32,10 +32,12 @@ noinst_LTLIBRARIES += libgirepository-internals.la libgirepository-gthash.la
libgirepository_gthash_la_SOURCES = \
girepository/gthash.c
libgirepository_gthash_la_CFLAGS = \
+ $(WARN_CFLAGS) \
$(GIREPO_CFLAGS) \
$(GI_HIDDEN_VISIBILITY_CFLAGS) \
-I$(top_srcdir)/girepository
-
+libgirepository_gthash_la_LDFLAGS = \
+ $(WARN_LDFLAGS)
libgirepository_gthash_la_LIBADD = libcmph.la $(GIREPO_LIBS)
libgirepository_internals_la_SOURCES = \
@@ -50,10 +52,14 @@ libgirepository_internals_la_SOURCES = \
girepository/girwriter.h
libgirepository_internals_la_CFLAGS = \
+ $(WARN_CFLAGS) \
$(GIREPO_CFLAGS) \
$(GI_HIDDEN_VISIBILITY_CFLAGS) \
-I$(top_srcdir)/girepository
+libgirepository_internals_la_LDFLAGS = \
+ $(WARN_LDFLAGS)
+
libgirepository_internals_la_LIBADD = libgirepository-gthash.la $(GIREPO_LIBS)
libgirepository_1_0_la_SOURCES = \
@@ -83,12 +89,14 @@ libgirepository_1_0_la_SOURCES = \
girepository/givfuncinfo.c
libgirepository_1_0_la_CPPFLAGS = \
+ $(WARN_CFLAGS) \
$(GIREPO_CFLAGS) \
$(GI_HIDDEN_VISIBILITY_CFLAGS) \
-I$(top_srcdir)/girepository \
-DG_IREPOSITORY_COMPILATION
libgirepository_1_0_la_LIBADD = libgirepository-gthash.la $(GIREPO_LIBS)
libgirepository_1_0_la_LDFLAGS = \
+ $(WARN_LDFLAGS) \
$(EXTRA_LINK_FLAGS) \
-no-undefined -version-number 1:0:0
@@ -99,7 +107,8 @@ if !OS_WIN32
noinst_PROGRAMS += gi-dump-types
gi_dump_types_SOURCES = girepository/gdump.c girepository/gi-dump-types.c
-gi_dump_types_CFLAGS = $(GIO_UNIX_CFLAGS) $(GMODULE_CFLAGS)
+gi_dump_types_CFLAGS = $(GIO_UNIX_CFLAGS) $(GMODULE_CFLAGS) $(WARN_CFLAGS)
+gi_dump_types_LDFLAGS = $(WARN_LDFLAGS)
gi_dump_types_LDADD = $(GIO_UNIX_LIBS) $(GMODULE_LIBS)
endif
diff --git a/Makefile-giscanner.am b/Makefile-giscanner.am
index 8d7d8734..cf9f79a1 100644
--- a/Makefile-giscanner.am
+++ b/Makefile-giscanner.am
@@ -23,7 +23,8 @@ libgiscanner_la_SOURCES = \
giscanner/scannerparser.y
libgiscanner_la_CPPFLAGS = -I$(top_srcdir)/girepository -I$(top_srcdir)/giscanner
libgiscanner_la_LIBADD = $(GOBJECT_LIBS) $(GIO_LIBS)
-libgiscanner_la_CFLAGS = $(GOBJECT_CFLAGS) $(GIO_CFLAGS)
+libgiscanner_la_CFLAGS = $(GOBJECT_CFLAGS) $(GIO_CFLAGS) $(WARN_CFLAGS)
+libgiscanner_la_LDFLAGS = $(WARN_LDFLAGS)
# Python module
pkgpyexecdir = $(pkglibdir)/giscanner
@@ -109,10 +110,12 @@ nobase_dist_template_DATA = \
_giscanner_la_CFLAGS = \
$(PYTHON_INCLUDES) \
$(GOBJECT_CFLAGS) \
+ $(WARN_CFLAGS) \
-I$(top_srcdir)/giscanner
_giscanner_la_LIBADD = libgiscanner.la $(GOBJECT_LIBS)
_giscanner_la_LDFLAGS = \
+ $(WARN_LDFLAGS) \
-module -avoid-version \
-export-symbols-regex "init_giscanner|PyInit__giscanner"
diff --git a/Makefile-tools.am b/Makefile-tools.am
index 5dfa6c48..8c4a069b 100644
--- a/Makefile-tools.am
+++ b/Makefile-tools.am
@@ -25,7 +25,8 @@ g-ir-doc-tool: tools/g-ir-tool-template.in _giscanner.la Makefile
g_ir_compiler_SOURCES = tools/compiler.c
g_ir_compiler_CPPFLAGS = -I$(top_srcdir)/girepository
-g_ir_compiler_CFLAGS = $(GIO_CFLAGS)
+g_ir_compiler_CFLAGS = $(GIO_CFLAGS) $(WARN_CFLAGS)
+g_ir_compiler_LDFLAGS = $(WARN_LDFLAGS)
g_ir_compiler_LDADD = \
libgirepository-internals.la \
libgirepository-1.0.la \
@@ -33,14 +34,16 @@ g_ir_compiler_LDADD = \
g_ir_generate_SOURCES = tools/generate.c
g_ir_generate_CPPFLAGS = -I$(top_srcdir)/girepository
-g_ir_generate_CFLAGS = $(GIO_CFLAGS)
+g_ir_generate_CFLAGS = $(GIO_CFLAGS) $(WARN_CFLAGS)
+g_ir_generate_LDFLAGS = $(WARN_LDFLAGS)
g_ir_generate_LDADD = \
libgirepository-internals.la \
libgirepository-1.0.la \
$(GIREPO_LIBS)
g_ir_inspect_SOURCES = tools/g-ir-inspect.c
-g_ir_inspect_CFLAGS = $(GIO_CFLAGS) -I$(top_srcdir)/girepository
+g_ir_inspect_CFLAGS = $(GIO_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)/girepository
+g_ir_inspect_LDFLAGS = $(WARN_LDFLAGS)
g_ir_inspect_LDADD = \
libgirepository-1.0.la \
$(GIREPO_LIBS)
diff --git a/configure.ac b/configure.ac
index b33e56cf..9ae070c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,29 +59,15 @@ if test "$YACC" = :; then
AC_MSG_ERROR([bison not found but required])
fi
-
-changequote(,)dnl
-ensureflag() {
- flag="$1"; shift
- result="$@"
-
- case " ${result} " in
- *[\ \ ]${flag}[\ \ ]*) ;;
- *) result="${flag} ${result}" ;;
- esac
-
- echo ${result}
-}
-changequote([,])dnl
-
-if test "$GCC" = "yes"; then
- for flag in -Wall -Wchar-subscripts -Wmissing-declarations \
- -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align \
- -Wsign-compare -fno-strict-aliasing;
- do
- CFLAGS="$(ensureflag $flag $CFLAGS)"
- done
-fi
+# Default compiler warnings
+m4_ifndef([AX_COMPILER_FLAGS], [AC_MSG_ERROR(['autoconf-archive' missing])])
+AX_COMPILER_FLAGS(,, [yes])
+# These get triggered a lot, not worth it imo, but feel free to fix them
+AX_APPEND_COMPILE_FLAGS([-Wno-discarded-qualifiers -Wno-duplicated-branches -Wno-switch-enum])
+# FIXME: Fix the warnings and remove the flags
+AX_APPEND_COMPILE_FLAGS([-Wno-redundant-decls -Wno-switch-default -Wno-shadow -Wno-deprecated-declarations -Wno-cast-function-type -Wno-type-limits])
+AX_APPEND_COMPILE_FLAGS([-Wno-implicit-fallthrough -Wno-suggest-attribute=format -Wno-double-promotion -Wno-sign-compare])
+AX_APPEND_COMPILE_FLAGS([-Wno-incompatible-pointer-types])
# Checks for libraries.
AC_CHECK_LIB([dl], [dlopen])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d3e7c7f4..4bdb9c3b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,9 +6,6 @@ EXTRA_DIST=
BUILT_SOURCES=
CLEANFILES=
-AM_CFLAGS = $(GOBJECT_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS) -I$(srcdir)
-LIBADD = $(GOBJECT_LIBS)
-
testsdir = $(datadir)/gobject-introspection-1.0/tests
tests_DATA = \
everything.c \
@@ -20,7 +17,14 @@ tests_DATA = \
EXTRA_LTLIBRARIES = libeverything-1.0.la libgimarshallingtests-1.0.la
libeverything_1_0_la_SOURCES = everything.c
+libeverything_1_0_la_CFLAGS = $(GOBJECT_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS) $(WARN_CFLAGS) -I$(srcdir)
+libeverything_1_0_la_LDFLAGS = $(WARN_LDFLAGS)
+libeverything_1_0_la_LIBADD = $(GOBJECT_LIBS)
+
libgimarshallingtests_1_0_la_SOURCES = gimarshallingtests.c
+libgimarshallingtests_1_0_la_CFLAGS = $(GOBJECT_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS) $(WARN_CFLAGS) -I$(srcdir)
+libgimarshallingtests_1_0_la_LDFLAGS = $(WARN_LDFLAGS)
+libgimarshallingtests_1_0_la_LIBADD = $(GOBJECT_LIBS)
EXTRA_DIST += \
gimarshallingtests.h \
diff --git a/tests/offsets/Makefile.am b/tests/offsets/Makefile.am
index fa1c1001..269b0ce1 100644
--- a/tests/offsets/Makefile.am
+++ b/tests/offsets/Makefile.am
@@ -17,8 +17,9 @@ liboffsets_la_SOURCES = \
offsets.h \
offsets.c
liboffsets_la_CPPFLAGS = $(GIREPO_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS) -I$(top_srcdir)/tests
+liboffsets_la_CFLAGS = $(WARN_CFLAGS)
# dummy rpath to get built dynamically (huh?)
-liboffsets_la_LDFLAGS = -avoid-version -rpath $(libdir)
+liboffsets_la_LDFLAGS = $(WARN_LDFLAGS) -avoid-version -rpath $(libdir)
Offsets-1.0.gir: liboffsets.la offsets.h
Offsets_1_0_gir_INCLUDES = GObject-2.0
@@ -36,6 +37,8 @@ EXTRA_PROGRAMS += gitestoffsets
nodist_gitestoffsets_SOURCES = gitestoffsets.c
gitestoffsets_CPPFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository -I$(top_srcdir)/tests
+gitestoffsets_CFLAGS = $(WARN_CFLAGS)
+gitestoffsets_LDFLAGS = $(WARN_LDFLAGS)
gitestoffsets_LDADD = $(top_builddir)/libgirepository-1.0.la $(GIREPO_LIBS)
gitestoffsets.c: gen-gitestoffsets offsets.h Offsets-1.0.typelib
diff --git a/tests/repository/Makefile.am b/tests/repository/Makefile.am
index 6b4b782f..b6bde9d9 100644
--- a/tests/repository/Makefile.am
+++ b/tests/repository/Makefile.am
@@ -1,5 +1,5 @@
-AM_CFLAGS = $(GOBJECT_CFLAGS)
-AM_LDFLAGS = -module -avoid-version
+AM_CFLAGS = $(WARN_CFLAGS) $(GOBJECT_CFLAGS)
+AM_LDFLAGS = $(WARN_LDFLAGS) -module -avoid-version
LIBS = $(GOBJECT_LIBS)
EXTRA_PROGRAMS = gitestrepo giteststructinfo gitestthrows gitypelibtest
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index 91c4a3ee..f7075856 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -22,10 +22,10 @@ CLEANFILES += $(EXTRA_LTLIBRARIES)
GI_SCANNER_CFLAGS = -I$(top_srcdir)/tests
AM_CPPFLAGS = -I$(top_srcdir)/girepository
-AM_CFLAGS = $(GIO_CFLAGS) $(GOBJECT_CFLAGS) $(GTHREAD_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS) $(GI_SCANNER_CFLAGS)
+AM_CFLAGS = $(GIO_CFLAGS) $(GOBJECT_CFLAGS) $(GTHREAD_CFLAGS) $(GI_HIDDEN_VISIBILITY_CFLAGS) $(GI_SCANNER_CFLAGS) $(WARN_CFLAGS)
# -rpath needed to force libtool to build a shared library for a check_LTLIBRARIES
# target. See http://lists.gnu.org/archive/html/automake/2005-10/msg00107.html
-AM_LDFLAGS = -rpath /unused -avoid-version
+AM_LDFLAGS = $(WARN_LDFLAGS) -rpath /unused -avoid-version
LIBS = $(GOBJECT_LIBS) $(GTHREAD_LIBS)
libsletter_la_SOURCES = sletter.c sletter.h