From 42b03d10ecdcd1e9abbb73f32aa6d5bfb942eea3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Thu, 24 Jan 2008 17:53:34 +0000 Subject: [PATCH] Add sanity check for public headers --- src/Makefile.am | 25 +++++++++++++++++++++++-- src/test/headers.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/test/headers.c diff --git a/src/Makefile.am b/src/Makefile.am index 876fe1017e..861296fdfa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -371,8 +371,15 @@ misc/revision.c: ############################################################################### # Unit/regression test ############################################################################### -check_PROGRAMS = test_i18n_atof test_url test_utf8 test_control -dist_check_SCRIPTS = check_symbols +check_PROGRAMS = \ + test_i18n_atof \ + test_url \ + test_utf8 \ + test_headers \ + test_control \ + $(NULL) + +dist_check_SCRIPTS = check_symbols check_headers TESTS = $(check_PROGRAMS) $(dist_check_SCRIPTS) CFLAGS_tests = `$(VLC_CONFIG) --cflags libvlc` @@ -388,10 +395,24 @@ test_utf8_SOURCES = test/utf8.c test_utf8_LDADD = libvlc.la test_utf8_CFLAGS = $(CFLAGS_tests) +test_headers_SOURCES = test/headers.c +test_headers_CFLAGS = $(CFLAGS_tests) + test_control_SOURCES = control/testapi.c test_control_LDADD = libvlc-control.la test_control_CFLAGS = $(CFLAGS_tests) +check-local: + for h in `echo $(dist_pkginclude_HEADERS) $(pkginclude_HEADERS) | sed -e s,\.\./include/,,g`; \ + do \ + echo grep - "#include <$$h>" $(srcdir)/test/headers.c ; \ + if ! grep -- "#include <$$h>" $(srcdir)/test/headers.c ; \ + then \ + echo "Header $$h not included in test/headers.c!"; \ + exit 1; \ + fi ; \ + done + FORCE: @echo "Generated source cannot be phony. Go away." >&2 @exit 1 diff --git a/src/test/headers.c b/src/test/headers.c new file mode 100644 index 0000000000..50b7188519 --- /dev/null +++ b/src/test/headers.c @@ -0,0 +1,38 @@ +/***************************************************************************** + * headers.c: Test for public headers usability + ***************************************************************************** + * Copyright (C) 2007 Rémi Denis-Courmont + * $Id$ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +/* config.h is NOT installed, headers MUST NOT depend on it. + # include */ +/* One thing we don't check is the CPPFLAGS - these MUST be exposed publicly, + * e.g. using pkg-config or the broken old vlc-config. */ + +#include +#include +#include +#include +#include + +int main (void) +{ + puts ("Public headers can be used for external compilation."); + return 0; +} + -- 2.39.2