]> git.sesse.net Git - vlc/commitdiff
Add sanity check for public headers
authorRémi Denis-Courmont <rem@videolan.org>
Thu, 24 Jan 2008 17:53:34 +0000 (17:53 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Thu, 24 Jan 2008 17:53:34 +0000 (17:53 +0000)
src/Makefile.am
src/test/headers.c [new file with mode: 0644]

index 876fe1017e9ff09b3335a82830bcd67717796265..861296fdfab2e5407f8665afa60430b3937ed449 100644 (file)
@@ -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 (file)
index 0000000..50b7188
--- /dev/null
@@ -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 <config.h> */
+/* 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 <vlc/vlc.h>
+#include <vlc/libvlc.h>
+#include <vlc/libvlc_structures.h>
+#include <vlc/mediacontrol.h>
+#include <vlc/mediacontrol_structures.h>
+
+int main (void)
+{
+    puts ("Public headers can be used for external compilation.");
+    return 0;
+}
+